How can I switch users from within XFCE?

22,798

Solution 1

enter image description here

In a terminal:

sudo apt-get install xfswitch-plugin

During installation it will ask you to switch window manager - do not choose GDM, but stick with lightdm. N.B. since its a text screen press TAB to navigate to "OK" and press ENTER

Right-click and add a new panel item - User Switching

Solution 2

If you don't want to bring in the whole of gdm and dependencies, you can just create a launcher that achieves the same thing. Put this

#!/bin/sh
zenity --question --text "Switch user?" --title "New login" &&
gdmflexiserver --new

into a file called fast-user-switch, then do

chmod +x fast-user-switch
sudo mv fast-user-switch /usr/local/bin/

Then add a Launcher plugin to your panel, edit the menu and click the button with a white paper with a plus on it, there you can just type in fast-user-switch (it should auto-complete while you type if you did the past steps correctly), and select a nice icon (search for switch for a fitting one …)

Note: The next version of XFCE, 4.10, will include a Switch User button in the Actions plugin, and deprecate the session menu.

Note to the note: if you have kdm instead of gdm/lightdm (kdm+xfce may be an odd combination, but it happens), the 4.10 Switch User button doesn't work. However, the following bash script works, and additionally lets you either log in as a currently logged in user, or start a new login:

#!/bin/bash

set -f              # no globbing, so we can safely use *

# other_local[joe]=:0, other_local[bob]=:1 etc. for all active local
# users other than us:
unset other_local; declare -A other_local; 
while read -rd $'\t'; do
    IFS=$',\n' r=($REPLY)
    [[ "${#r[@]}" -ge 4 && "${r[4]}" != '*' && "${r[2]}" != '' && "${r[0]}" != '' ]] && other_local[${r[2]}]=${r[0]}
done < <(kdmctl list alllocal)
IFS=$',\n' r=($REPLY)
[[ "${#r[@]}" -ge 4 && "${r[4]}" != '*' && "${r[2]}" != '' && "${r[0]}" != '' ]] && other_local[${r[2]}]=${r[0]}


user_choice=$( printf "%s\n" "${!other_local[@]}" "New login" |\
    zenity --list --column User --text 'Switch to an active user, or start a new login:' --title 'Switch user?' ) || exit 1

case $user_choice in
    "New login" ) kdmctl reserve ;;
    * ) kdmctl activate "${other_local[$user_choice]}" ;;
esac

Solution 3

You can click your user name in the top panel and then select "Lock Screen." From the locked screen select "New Login" and it will take you back to the LightDM screen where you can click a different user name and enter the password. The first user is still logged in and you can switch back and forth this way.

Solution 4

gdmflexiserver did not work for me coz it was not there on my system.

I used dm-tool instead: https://bugs.launchpad.net/ubuntu/+source/xfswitch-plugin/+bug/1320560

Solution 5

Invoking dm-tool, with either the 'lock', or 'switch-to-greeter' option, will leave an xfce4 session vulnerable to a login without a password, as per the following bug report: https://bugs.launchpad.net/lightdm/+bug/904006.

Rather than chase the bug, the devs seem to be directing people to use light-locker, which is simple to use, and set up with secure defaults.

The following fix ensures that the 'switch user' option in the xfce4 panel invokes light-locker. There is no need to create a launcher plugin, or install additional gnomeware.

(1) Install light-locker (in my case from the Debian 8/Jessie stable repository).

(2) Replace /usr/local/bin/gdmflexiserver with:

#!/bin/bash
light-locker-command -l
# [End]

(3) reboot (full shutdown and restart, needed once only, to get the panel to activate the 'switch user' option - you may have smarter ways to get this done).

Each time I hit the 'switch user' menu option, there is a slight pause on a black screen before the login appears, which is not there when I use dm-tool, but it's good to know my session is fully locked.

Thanks to pomidorabelisima at https://bugs.launchpad.net/ubuntu/+source/xfswitch-plugin/+bug/1320560 (duplicate bug report) for the heads-up.

Share:
22,798

Related videos on Youtube

Jorge Castro
Author by

Jorge Castro

Updated on September 18, 2022

Comments

  • Jorge Castro
    Jorge Castro almost 2 years

    I am using xubuntu 11.10. I'd like to be able to switch users, and I'd like to be able to do this within the xfce user interface. I read somewhere that there might be an applet I can install, but I cannot seem to find it. Can someone help?

  • Martijn
    Martijn over 12 years
    Very nice! No need to install gdm this way...
  • Martijn
    Martijn over 12 years
    Switching back to my own session does require typing my password twice, though... (LightDM requires a password to get into my session, and xscreensaver does too).
  • user2081405
    user2081405 about 12 years
    Great! Now if only there was a way to add that to the Logout/Suspend/Hibernate menu instead of having it a separate entry...
  • Alois Mahdal
    Alois Mahdal over 11 years
    Awesome. The 2-line script worked like a charm on default installation of Ubuntu 12.04 LTS.
  • gov
    gov almost 11 years
    CAREFUL WITH THAT AXE, EUGENE! This will bring in the entire heavyweight Gnome... That's a bad choice if you run XFCE.