9

To log out of LXDE, I can click on the "Start" menu, click "Logout" and when the menu pops up click on "logout" again.

Or I can type lxde-logout in my terminal and when the menu opens, click on "logout".

Both options are too cumbersome. I need a command which will log me out immediately, without menu, or without other options.

Is this possible ?

I am using LXDE on Debian Wheezy

Martin Vegter
  • 358
  • 75
  • 236
  • 411
  • In Gnome you can use dbus to logout: dbus-send --session --type=method_call --print-reply --dest=org.gnome.SessionManager /org/gnome/SessionManager org.gnome.SessionManager.Logout uint32:1 2>&1 && return. I have never used LXDE but according to these pages (1, 2) similar objects/methods should be available. So, you could try something like: dbus-send --session --type=method_call --print-reply --reply-timeout=2000 --dest=org.lxde.SessionManager /org/lxde/SessionManager org.lxde.SessionManager.Logout uint32:1 2>&1 && return. – don_crissti Nov 30 '14 at 02:51
  • If all else fails, try pkill lxsession. – don_crissti Nov 30 '14 at 02:52

5 Answers5

5

I think you can just run this command to log out.

$ pkill -SIGTERM -f lxsession

Also if you go poking through the LXDE GitHub page there's a section at the end of this URL: https://github.com/lxde/lxsession.

Excerpt

==== Log out ===

Simply executing this command:

  lxsession-logout

This will give you a good-looking logout dialog. If gdm is installed, lxsession can do shutdown/reboot/suspend via gdm. (These options are not available if gdm is not running.)

If you want to customize this logout box further, try this:

  lxsession-logout --prompt "Your custom message" --banner "Your logo" \
    --side "left | top | right | bottom (The position of the logo)"

We create a script /usr/bin/lxde-logout to do this:

  #!/bin/sh 

  /usr/bin/lxsession-logout --banner \
      "/usr/share/lxde/images/logout-banner.png" --side top

You can put this logout script in the menu of your window manager or desktop panel. Then, you can logout via clicking from the menu.

References

slm
  • 369,824
1

As indicated above, simply execute the command

pkill -9 -f lxsession

Note that examining the source of lxsession-logout, you will find there are no command line arguments you can pass it to bypass the menu. lxde-logut is simply a script which runs lxsession-logout. Since it seems as though you want a very quick way to logout, the pkill command listed above may require to much typing. Fortunately, there are two things you can do to speed this up and minimize keystrokes/button clicks.

1) Create an alias for the command.

alias quitnow="pkill -9 -f lxsession"

Substitute in whatever unused word you want for quitnow. Be careful though, you don't want a typo that immediately logs you out of your session.

2) Edit the /usr/bin/lxde-logout file. As indicated above, it currently just runs lxsession-logout. It also happens to be what is run when you click the logout button on your menu. Thus you can change it to read

#!/bin/sh
pkill -9 -f lxsession

Though I would leave the lxsession-logout line as a comment so in case you want to restore its original behavior. Note that this results in the potential for logging out on accidental mouse clicks.

3) Create a separate script and add it to the menu.

4) Create a key binding by adding the following to your ~/.config/openbox/lxde-rc.xml file. I would put this right before the </keyboard> tag.

<keybind key="C-q">
  <action name="Execute">
    <command>pkill -9 -f lxsession</command>
  </action>
</keybind>

Note that this is a duplicate of the file /etc/xdg/openbox/rc.xml.

Option 4 is probably the best since it retains original functionality and gives you the quick departure. Just choose your keys wisely. :)

R Schultz
  • 462
0

Just run lxsession. It will log out and should present the login screen for a new session.

iyrin
  • 1,895
0

Some of the answers so far are more cumbersome than the methods mentioned by OP, which he considers too cumbersome; others don't quite do what OP is asking for, which is a complete shutdown. (I may be mistaken, but if the openbox session is simply killed, won't the user simply be dropped to the DM? Doesn't sound like that's what the OP wants.)

Wheezy still uses sysv-init, right? The comment under the initial post comes close to what you're looking for. Test the command in a terminal first; once you're sure it works the way you want, add a keybinding for it in your ~/.config/openbox/lxde-rc.xml. (Make sure it's a key combination you will not accidentally type, because it will shut down your computer immediately.) The answer from R Schultz shows how to make such a keybinding; just replace the pkill line with the dbus-send one.

If you've migrated from sysv-init to systemd, you can use systemctl poweroff instead of the dbus-send line.

0

This will work in LXDE and most other environments. It doesn't require knowledge of the environment or sudo group privilege. It kills all processes the user has running, effectively logging them out.

pkill -KILL -u your username
AdminBee
  • 22,803
stanely
  • 101