Xfce Forum

Sub domains
 

You are not logged in.

#1 2014-03-06 16:15:10

the98
Member
Registered: 2009-11-10
Posts: 62

[Script] User switching: XFCE & LightDM

After struggling a little with GDM3 and Debian dependencies, I decided to dump that DM and start using LightDM. My only problem was getting LightDM to work with multiple users logged in at the same time, buy I realized this was very easy. Then I needed to make it easy for my whole family, something similar to what XFSWITCH does. So I created a simple bash script for this task.

All you need to do is install LightDM and Zenity. Then we're going to create a file, I named it usrchg.

# nano /usr/bin/usrchg

You're going to copy this into the file and save it:

#!/bin/bash

zenity --question --title="User Switching" \
   --text="Do you want to switch to another user?"

if [ $? -eq 0 ] ; then 
   dm-tool switch-to-greeter
else
   exit 0
fi

Give it permissions to execute it as a regular user:

chmod 755 /usr/bin/usrchg

And you're done.

You can create a Launcher that runs the script usrchg, and set the same icon as XFSWITCH, like so:

FTEZ5iK.png

And place the launcher in your Panel:

xFkzBnN.png

And when clicking on the laucher, you get this simple prompt:

U3UdcHn.png

Hope you guys like it!

I'm open for suggestions to improve this script.

Regards.

Offline

#2 2014-03-06 19:36:04

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

Re: [Script] User switching: XFCE & LightDM

Nice. Thanks for sharing.

What would be helpful is using this tool to also deal with existing open sessions. For example, if I already have a session open and if I switch from your session, I should go back to my original session as opposed to a new second session.

"man dm-tool" lists some interesting options:
- switch-to-user (will switch to user session if it exists or create a new one)
- switch-to-guest (for a kiosk-like guest login)
- list-seats (to list existing logged in sessions)


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 2014-05-25 10:25:23

Jerry3904
Member
Registered: 2013-11-09
Posts: 863

Re: [Script] User switching: XFCE & LightDM

We have been looking at this after a user request, and have made some modifications:

#!/bin/bash

yad --question --title="User Switching" \
 --text="This tool allows you to switch to a different user without closing down your current session.

To return to the original user, simply press Ctrl-Alt-F7. Go back again with Ctrl-Alt-F8.

Do you want to switch to another user?"

if [ $? -eq 0 ] ; then 
dm-tool switch-to-greeter 

else
 exit 0

fi

The Ctrl-Alt-F7/F8 toggle works like a charm. BTW: we substituted yad for zenity b/c it's already installed and we keep the footprint small--to my eyes it actually looks better.

Last edited by Jerry3904 (2014-05-25 19:23:28)


MX-23 (based on Debian Stable) with our flagship Xfce 4.18.

Offline

#4 2014-06-13 19:22:13

the98
Member
Registered: 2009-11-10
Posts: 62

Re: [Script] User switching: XFCE & LightDM

Thanks Jerry. Are you a XFCE dev? Are you going to include this simple code as a plugin? It may be easier for some people to install it as a plugin, like xfswitch is.

Offline

#5 2014-06-13 19:39:42

Jerry3904
Member
Registered: 2013-11-09
Posts: 863

Re: [Script] User switching: XFCE & LightDM

the98 wrote:

Thanks Jerry. Are you a XFCE dev? Are you going to include this simple code as a plugin? It may be easier for some people to install it as a plugin, like xfswitch is.

Nope, just a user with a small amount of knowledge about scripts and a large amount of curiosity. But thanks for even thinking I might be!

We are including that in our point release of MX-14.1 that is about to be released, where it is a menu item ("MX Switch User") and also one of the small icons at the top of Whisker menu. Since it is licensed under GPL 3 (http://www.mepiscommunity.org/doc_mx/mx … cense.html) it is available for anyone interested.


MX-23 (based on Debian Stable) with our flagship Xfce 4.18.

Offline

#6 2014-06-17 18:38:54

gxagar
Member
Registered: 2012-03-14
Posts: 86

Re: [Script] User switching: XFCE & LightDM

Jerry3904 and the98,

This is fantastic!  You guys are fantastic.  If i had a community, I'd want you in it.  As many other users, I'd rather that the "switch user" feature of the native XFCE4 Action Button work seamlessly with LightDM, but this is absolutely the next best thing and the best workaround out there.

I am posting this from MX-14 Live.  I am delighted by the work that the Mepis/AntiX community has done.  I have always been interested in a Debian Stable that moves forward just a little faster than Debian Stable.  There have been others, but their communities failed me.  With folks like you participating in the MX-14 Project, I expect that it will live long and prosper.  I sure hope so.  I will follow it and help it where I can.  Firstly, I intend to seed the torrent as soon as it is created.  After that, who knows.  I look forward to MX-14.1 and seeing your contribution to it "in print".  It must feel very rewarding.  I have some older machines that are prime candidates for this distro.  Let the test drives begin.  Also, as many others, I would be interested in a 64-bit version for my newer machines.  If you built it, we will come.  If I can figger a way to help with it's development, I will.

Best Regards,

Gary

Last edited by gxagar (2014-07-01 19:12:38)


Linuxers Live by a CODE!

Offline

#7 2014-06-17 19:22:56

Jerry3904
Member
Registered: 2013-11-09
Posts: 863

Re: [Script] User switching: XFCE & LightDM

Thanks for the good words! We would love to have your help as we move forward from the point release, so take a look at 14.1 and join the Forum!


MX-23 (based on Debian Stable) with our flagship Xfce 4.18.

Offline

#8 2014-06-17 23:36:34

gxagar
Member
Registered: 2012-03-14
Posts: 86

Re: [Script] User switching: XFCE & LightDM

You're Very Welcome.  And...elegant, I meant to say the most elegant workaround too.

I have implemented this on DebStab, DebTest, and my new testbed MX-14 install.  Gonna give it a good lookover before I deploy it to my BOINC cluster (group really).

I used the updated script, and in both Debians had to change yad to zenity, as Debian doesn't have yad.  Works Great!

I hope the XFCE Devs pick up on this and incorporate it into the Switch User section of their Action Buttons.  It'd be simpler for all distros.

I am duly impressed by other features in MX.  I expect to join the forum soon.  Look for gmagar.

More Regards,

Gary

Last edited by gxagar (2014-06-17 23:55:57)


Linuxers Live by a CODE!

Offline

#9 2014-06-18 00:47:36

Jerry3904
Member
Registered: 2013-11-09
Posts: 863

Re: [Script] User switching: XFCE & LightDM

Will look for you!  14.1 is uploading right now, so we should have download and torrent ready in the morning on the website download page.

I'm on the Dev mailing list so may run it by them to s.ee if there's any interest

Last edited by Jerry3904 (2014-06-18 00:48:26)


MX-23 (based on Debian Stable) with our flagship Xfce 4.18.

Offline

#10 2014-06-23 18:17:26

the98
Member
Registered: 2009-11-10
Posts: 62

Re: [Script] User switching: XFCE & LightDM

Jerry, thanks for clarifying.

I think yad is not available on Debian's repository.

Offline

#11 2014-06-23 18:44:27

Jerry3904
Member
Registered: 2013-11-09
Posts: 863

Re: [Script] User switching: XFCE & LightDM

That's right, it is a fork of zenity with reasonably recent debs available on getdeb: http://ftp.dk.debian.org/getdeb/ubuntu/pool/apps/y/yad/

Zenity will work, just not as clean a look IMHO.


MX-23 (based on Debian Stable) with our flagship Xfce 4.18.

Offline

#12 2014-06-24 18:57:19

gxagar
Member
Registered: 2012-03-14
Posts: 86

Re: [Script] User switching: XFCE & LightDM

I wouldn't suggest this for everybody, especially noobies.

I commented out all the lines in the script except "dm-tool switch-to-greeter".  This keeps the yad or zenity dialogue box from showing up at all and takes me straight to the greeter. 

This works for me because I have different users set up for different purposes on my box and I am all of them.


Linuxers Live by a CODE!

Offline

#13 2014-06-28 00:19:39

the98
Member
Registered: 2009-11-10
Posts: 62

Re: [Script] User switching: XFCE & LightDM

Why would you make a script if you commented out all the lines except for the one that calls the DM???

Just make a launcher calling dm-tool switch-to-greeter command.

Offline

#14 2014-07-01 19:26:59

gxagar
Member
Registered: 2012-03-14
Posts: 86

Re: [Script] User switching: XFCE & LightDM

the98,

Because I'm not as smart as you.  I just did what I thought of first.  I do what my KnowledgeBase and SkillSet allows me to do at the moment.  But your idea is better.  In an earlier post, I forgot to give you credit for the original script.  I'm sorry.  I have since edited that post and corrected this oversight.  I don't mind saying again, you guys are fantastic.  This is a tool that XFCE has lacked for awhile.  Thanks for it.

If I'm thinkin' right, a Launcher is just a GUI for, and that creates, a Script.  Different paths, same result.  But now, thanks to you, I'm a little smarter, knowledgder, and skillder.  More weapons in my arsenal is better.  More tools in my kit makes work easier.  That's one reason I hang in the forums. 

Thanks again.


Linuxers Live by a CODE!

Offline

#15 2014-07-01 21:07:45

the98
Member
Registered: 2009-11-10
Posts: 62

Re: [Script] User switching: XFCE & LightDM

Come on man, don't make such a big deal about it, you make blush tongue

I haven't done something extraordinary with this simple script, nor with the launcher suggestion, but I'm glad I can help.

Offline

#16 2014-07-01 21:43:16

gxagar
Member
Registered: 2012-03-14
Posts: 86

Re: [Script] User switching: XFCE & LightDM

Humility is good.  But you script writers amaze me and enable the rest of us to do what we do.  Don't sell yourself short.  More folks should gush over you.  Appreciation is good.  Expressed and Communicated appreciation is better.


Linuxers Live by a CODE!

Offline

#17 2014-07-12 16:47:51

the98
Member
Registered: 2009-11-10
Posts: 62

Re: [Script] User switching: XFCE & LightDM

Just to point out something obvious, you can make Whisker Menu run this script. BTW, a feature similar to what's available on Whiskers Menu would be nice on the classic Applications Menu. I mean, the same concept; a button that let's change to a different user, and the possibility to configure the command that will run when pressed.

Offline

#18 2014-07-12 18:39:24

Jerry3904
Member
Registered: 2013-11-09
Posts: 863

Re: [Script] User switching: XFCE & LightDM

That's how we have it set up now for the MX-14.2 point release. We put the script in our /usr/ location, then used Whiskermenu to set it up: right-click the icon > Properties > Behavior tab: check Switch Users and navigate to the file.


MX-23 (based on Debian Stable) with our flagship Xfce 4.18.

Offline

#19 2014-07-14 04:05:55

the98
Member
Registered: 2009-11-10
Posts: 62

Re: [Script] User switching: XFCE & LightDM

Great smile

Offline

#20 2014-10-04 20:58:36

nemoinis
Member
Registered: 2014-10-04
Posts: 2

Re: [Script] User switching: XFCE & LightDM

As many other users, I'd rather that the "switch user" feature of the native XFCE4 Action Button work seamlessly with LightDM, but this is absolutely the next best thing and the best workaround out there.

As far as I know, to make the "switch user" feature work you just need an equivalent to gdmflexiserver installed.
The following script works for me, saved as /usr/local/bin/gdmflexiserver:

#!/bin/sh
#pretend to be gdmflexiserver so the XFCE action plugin's Switch User function works

#lock the current session
xscreensaver-command -lock

#then pass on the request to lightdm
exec dm-tool switch-to-greeter

Make sure it's executable, (maybe also logout and back in) and you should be in business.
The "xscreensaver" part is optional but is good for security...

Offline

#21 2015-02-05 07:57:25

Zirneklitis
Member
Registered: 2015-02-05
Posts: 1

Re: [Script] User switching: XFCE & LightDM

the98 wrote:

Thanks Jerry. Are you a XFCE dev? Are you going to include this simple code as a plugin? It may be easier for some people to install it as a plugin, like xfswitch is.

You may use the hacked  xfswitch-plugin:  the source of the hacked version. It is modified to work in LightDM/Xfce environment.

The binaries for Fedora users are available as well:
i386;
x86_64.

Offline

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

Board footer

Powered by FluxBB
Modified by Visman

[ Generated in 0.017 seconds, 9 queries executed - Memory usage: 624.3 KiB (Peak: 657.15 KiB) ]