Xfce Forum

Sub domains
 

You are not logged in.

#1 2022-01-10 11:32:18

friday
Member
Registered: 2022-01-10
Posts: 3

How to rearrange icons in logout menu?

Hi,

I'm using Xubuntu 20.04. When I press power off button on computer and hit enter then I've got logout. I would like to have power off machine instead logout.

1. Is possible to rearrange icons in logout menu to swap places "logout" with "turn off" icons?
2. Or maybe is possible to automaticly focus on "turn off" button? (power off button, hit enter to shutdown)

Offline

#2 2022-01-10 12:03:28

ToZ
Administrator
From: Canada
Registered: 2011-06-02
Posts: 11,485

Re: How to rearrange icons in logout menu?

Hello and welcome.

friday wrote:

1. Is possible to rearrange icons in logout menu to swap places "logout" with "turn off" icons?

Unfortunately, no - not that I am aware of. It's hard-coded to display that way.

2. Or maybe is possible to automaticly focus on "turn off" button? (power off button, hit enter to shutdown)

There was a discussion about that here with some options.

.

Here is an idea around another option that might work (I haven't tested this yet) assuming systemd:

  1. Have xfce4-power-manager pass on processing of the power key to systemd:

    xfconf-query -c xfce4-power-manager -p /xfce4-power-manager/logind-handle-power-key -n -t bool -s true
  2. Have systemd ignore the power key (/etc/systemd/logind.conf):

    HandlePowerKey=ignore
  3. Create your own script/dialog to run when the power key is pressed (maybe something as simple as "systemctl poweroff") and create a shortcut for it in Settings Manager > Keyboard > Application shortcuts. When asked to press a key to associate to the shortcut, press the power button.

I'll see if I can find time to test this.


Please remember to mark your thread [SOLVED] to make it easier for others to find
--- How To Ask For Help | FAQ | Developer Wiki  |  Community | Contribute ---

Offline

#3 2022-01-10 12:28:55

KBar
Member
Registered: 2021-11-05
Posts: 689

Re: How to rearrange icons in logout menu?

Hello and welcome to our forum!

  1. A resounding yes. You need to include the following two lines in your gtk.css file, which is located in $HOME/.config/gtk-3.0/gtk.css. If it doesn't exist yet, simply create it.
    Here is the default layout of the logout dialog on Xubuntu 20.04:
    tXMTFRB.png

    This code:

    .xfsm-logout-buttons > box:first-child button:nth-child(1) { margin-left: 168px; margin-right: -168px; }
    
    .xfsm-logout-buttons > box:first-child button:nth-child(3) { margin-left: -168px; margin-right: 168px; }

    swapped the position of Log Out and Shut Down buttons like so:
    LyCX0cJ.png
    You'll most likely going to need to adjust the numbers to fit your theme and layout. They are opposite numbers; just remember that for the first button, the right margin is negative (you're pushing it from left to right) and for the third button, the left margin is negative (you're pulling it from right to left).

  2. Try what ToZ suggested but I'd imagine this will be difficult to achieve as it seems to be hard-coded

Last edited by KBar (2022-01-10 12:41:00)


Remember to edit the subject of your topic to include the [SOLVED] tag once you're satisfied with the answers or have found a solution (in which case, don't forget to share it as well), so that other members of the community can quickly refer to it and save their time. Pretty please! tongue

Offline

#4 2022-01-10 12:57:51

friday
Member
Registered: 2022-01-10
Posts: 3

Re: How to rearrange icons in logout menu?

KBar wrote:
.xfsm-logout-buttons > box:first-child button:nth-child(1) { margin-left: 168px; margin-right: -168px; }
.xfsm-logout-buttons > box:first-child button:nth-child(3) { margin-left: -168px; margin-right: 168px; }

Thanks. This is just visual swap because focus is always on "logout" button even if is on "turn off" position smile

Offline

#5 2022-01-10 13:04:40

KBar
Member
Registered: 2021-11-05
Posts: 689

Re: How to rearrange icons in logout menu?

friday wrote:

Thanks. This is just visual swap because focus is always on "logout" button even if is on "turn off" position smile

Both the subject and your first question only ask about rearranging icons, which is a cosmetic action. Sorry if I misunderstood you.

As to your second question, see my second point above and ToZ's answer. I don't believe it's possible to do what you want without resorting to scripts or downright modifying the source code, which currently has this block:

button = xfsm_logout_dialog_button (_("_Log Out"), "xfsm-logout",
                                      "system-log-out", NULL,
                                      XFSM_SHUTDOWN_LOGOUT, dialog);

  gtk_box_pack_start (GTK_BOX (hbox), button, TRUE, TRUE, 0);
  gtk_widget_show (button);
  gtk_widget_grab_focus (button);

As you can see, it's set to grab focus.

If you have mnemonics enabled, just press Alt+D to Shut Down. Alt+R is for Restart and Alt+L is for Log Out.

Last edited by KBar (2022-01-10 13:09:34)


Remember to edit the subject of your topic to include the [SOLVED] tag once you're satisfied with the answers or have found a solution (in which case, don't forget to share it as well), so that other members of the community can quickly refer to it and save their time. Pretty please! tongue

Offline

#6 2022-01-10 16:29:11

friday
Member
Registered: 2022-01-10
Posts: 3

Re: How to rearrange icons in logout menu?

KBar wrote:

Both the subject and your first question only ask about rearranging icons, which is a cosmetic action. Sorry if I misunderstood you

It's ok, you understood well. This is my fault. I thought it would be enough to swap buttons.

Offline

#7 2022-01-10 16:38:50

KBar
Member
Registered: 2021-11-05
Posts: 689

Re: How to rearrange icons in logout menu?

I think ToZ' workaround that imitates Tab presses a couple of times is the most optimal. I'd probably do the same, except in a more convoluted and superfluous way. tongue


Remember to edit the subject of your topic to include the [SOLVED] tag once you're satisfied with the answers or have found a solution (in which case, don't forget to share it as well), so that other members of the community can quickly refer to it and save their time. Pretty please! tongue

Offline

#8 2022-01-10 16:52:03

ToZ
Administrator
From: Canada
Registered: 2011-06-02
Posts: 11,485

Re: How to rearrange icons in logout menu?

KBar wrote:

This code:

.xfsm-logout-buttons > box:first-child button:nth-child(1) { margin-left: 168px; margin-right: -168px; }

.xfsm-logout-buttons > box:first-child button:nth-child(3) { margin-left: -168px; margin-right: 168px; }

Cool. I had no idea. Even an old dog learns new tricks every once in a while.


Please remember to mark your thread [SOLVED] to make it easier for others to find
--- How To Ask For Help | FAQ | Developer Wiki  |  Community | Contribute ---

Offline

#9 2024-01-14 17:48:25

chang-zhao
Member
Registered: 2023-11-20
Posts: 42

Re: How to rearrange icons in logout menu?

I made a program that allows to have preferred (Shutdown/Reboot) buttons focused:
https://codeberg.org/chang-zhao/shutdown-gtk

Then it calls XFCE session manager to actually perform the corresponding logout action.

The only problem is to start it instead of the regular XFCE session manager (perhaps with udev rule for Power button or something?). I just set a hotkey to use for shutdown (Super-Escape), and for my purposes it's OK.

Options:

Options:
  -h, --help      show this help message and exit
  -r, --reboot    Reboot button will be focused initially
  -s, --shutdown  Shutdown button will be focused initially
  -q, --quiet     Don't print the info message
  -p, --preserve  Save the current session on shutdown

shutdown-gtk1.webp

Offline

Registered users online in this topic: 0, guests: 1
[Bot] ClaudeBot

Board footer

Powered by FluxBB
Modified by Visman

[ Generated in 0.012 seconds, 8 queries executed - Memory usage: 575.28 KiB (Peak: 592.13 KiB) ]