command to log out of LXDE directly

29,861

Solution 1

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

Solution 2

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. :)

Share:
29,861

Related videos on Youtube

Tam Borine
Author by

Tam Borine

Updated on September 18, 2022

Comments

  • Tam Borine
    Tam Borine over 1 year

    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

    • Admin
      Admin over 9 years
      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.
    • Admin
      Admin over 9 years
      If all else fails, try pkill lxsession.