Results 1 to 4 of 4

Thread: Runnung a bash script when on "Switch User"

  1. #1
    Join Date
    Nov 2009
    Beans
    16

    Question Runnung a bash script when on "Switch User"

    Hi,

    I've had my first dabbel with bash and got a working script going for each user on session start which checks if a NAS share is mounted and if it is unmounts it and mounts as the current user. This works great but now I have a problem, on the first "Switch User" the script is executed as the session for the new user starts. Switching back however the drive is mounted as the previous user, running the script works so it appears that what works for the session start (.config/autostart) doesn't handle this user switching and I guess that makes sense.

    Sooooo, question is, how to run my little script again when a session restarts for each user after a "Switch User" happens?

    Thanks in advance for any pointers, I've looked for a list of events I could hook in to but had no luck so I guess I'm not using the right terminology for Ubuntu?

  2. #2
    Join Date
    Nov 2009
    Beans
    16

    Re: Runnung a bash script when on "Switch User"

    Me again

    Is there a better place to ask this? I see lots of views but no answers...

  3. #3
    Join Date
    Dec 2014
    Beans
    2,579

    Re: Runnung a bash script when on "Switch User"

    Switching users produces a lot of activity on the dbus. You might be able to do something using 'gdbus' or 'dbus-monitor' on the system dbus on the path '/org/freedesktop/login1' and the interface 'org.freedesktop.login1.Session'

  4. #4
    Join Date
    May 2009
    Location
    Fareham, UK
    Beans
    1,524
    Distro
    Ubuntu 16.04 Xenial Xerus

    Re: Runnung a bash script when on "Switch User"

    What's your overall goal here. If I were in this situation I wouldn't have the share remount each time someone logs out, this seems excessive. You would be better investing a little time into setting up correct user directories and having the overall nas just mounted by one (main/admin) user. Alternatively the nas would be owned by the main user and permissions would be applied to other users via groups.
    Catch me on Freenode - imark

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •