Results 1 to 10 of 10

Thread: LightDM login and logout scripts

  1. #1
    Join Date
    Oct 2011
    Beans
    6

    LightDM login and logout scripts

    Hello,

    Please, is there any way to setup a login and logout script in LightDM, like there was in GDM by /etc/gdm/PreSession/Default and /etc/gdm/PostSession/Default

    Thanks,
    Ivan

  2. #2
    Join Date
    Nov 2010
    Location
    Berlin, Germany
    Beans
    4,534
    Distro
    Xubuntu 12.04 Precise Pangolin

    Re: LightDM login and logout scripts

    This should do it, the bold-marked options, add them to your "/etc/lightdm/lightdm.conf":
    Code:
    #
    # General configuration
    #
    # start-default-seat = True to always start one seat if none are defined in the configuration
    # greeter-user = User to run greeter as
    # minimum-display-number = Minimum display number to use for X servers
    # minimum-vt = First VT to run displays on
    # user-authority-in-system-dir = True if session authority should be in the system location
    # guest-account-script = Script to be run to setup guest account
    # log-directory = Directory to log information to
    # run-directory = Directory to put running state in
    # cache-directory = Directory to cache to
    # xsessions-directory = Directory to find X sessions
    # xgreeters-directory = Directory to find X greeters
    #
    [LightDM]
    #start-default-seat=true
    #greeter-user=lightdm
    #minimum-display-number=0
    #minimum-vt=7
    #user-authority-in-system-dir=false
    #guest-account-script=guest-account
    #log-directory=/var/log/lightdm
    #run-directory=/var/run/lightdm
    #cache-directory=/var/cache/lightdm
    #xsessions-directory=/usr/share/xsessions
    #xgreeters-directory=/usr/share/xgreeters
    
    #
    # Seat defaults
    #
    # xserver-command = X server command to run
    # xserver-layout = Layout to pass to X server
    # xserver-config = Config file to pass to X server
    # xserver-allow-tcp = True if TCP/IP connections are allowed to this X server
    # xdmcp-manager = XDMCP manager to connect to (implies xserver-allow-tcp=true)
    # xdmcp-port = XDMCP UDP/IP port to communicate on
    # xdmcp-key = Authentication key to use for XDM-AUTHENTICATION-1 (stored in keys.conf)
    # greeter-session = Session to load for greeter
    # greeter-hide-users = True to hide the user list
    # user-session = Session to load for users
    # allow-guest = True if guest login is allowed
    # guest-session = Session to load for guests (overrides user-session)
    # session-wrapper = Wrapper script to run session with
    # display-setup-script = Script to run when starting a greeter session (runs as root)
    # greeter-setup-script = Script to run when starting a greeter (runs as root)
    # session-setup-script = Script to run when starting a user session (runs as root)
    # session-cleanup-script = Script to run when quitting a user session (runs as root)
    # autologin-guest = True to log in as guest by default
    # autologin-user = User to log in with by default (overrides autologin-guest)
    # autologin-user-timeout = Number of seconds to wait before loading default user
    # autologin-session = Session to load for automatic login (overrides user-session)
    # exit-on-failure = True if the daemon should exit if this seat fails
    #
    [SeatDefaults]
    #xserver-command=X
    #xserver-layout=
    #xserver-config=
    #xserver-allow-tcp=false
    #xdmcp-manager=
    #xdmcp-port=177
    #xdmcp-key=
    #greeter-session=example-gtk-gnome
    #greeter-hide-users=false
    #user-session=default
    #allow-guest=true
    #guest-session=UNIMPLEMENTED
    #session-wrapper=lightdm-session
    #display-setup-script=
    #greeter-setup-script=
    #session-setup-script=
    #session-cleanup-script=
    #autologin-guest=false
    #autologin-user=
    #autologin-user-timeout=0
    #autologin-session=UNIMPLEMENTED
    #exit-on-failure=false
    
    #
    # Seat configuration
    #
    # Each seat must start with "Seat:".
    # Uses settings from [SeatDefaults], any of these can be overriden by setting them in this section.
    #
    #[Seat:0]
    
    #
    # XDMCP Server configuration
    #
    # enabled = True if XDMCP connections should be allowed
    # port = UDP/IP port to listen for connections on
    # key = Authentication key to use for XDM-AUTHENTICATION-1 or blank to not use authentication (stored in keys.conf)
    #
    # The authentication key is a 56 bit DES key specified in hex as 0xnnnnnnnnnnnnnn.  Alternatively
    # it can be a word and the first 7 characters are used as the key.
    #
    [XDMCPServer]
    #enabled=false
    #port=177
    #key=
    
    #
    # VNC Server configuration
    #
    # enabled = True if VNC connections should be allowed
    # port = TCP/IP port to listen for connections on
    #
    [VNCServer]
    #enabled=false
    #port=5900
    #width=1024
    #height=768
    #depth=8
    Source: "/usr/share/doc/lightdm/lightdm.conf"

    Regards.

  3. #3
    Join Date
    Oct 2011
    Beans
    6

    Re: LightDM login and logout scripts

    Yes, that worked well Thank you

  4. #4
    Join Date
    May 2008
    Location
    United Kingdom
    Beans
    4,274
    Distro
    Ubuntu 14.04 Trusty Tahr

    Re: LightDM login and logout scripts

    I have this same problem.

    However:

    The session-cleanup-script does indeed run, but it runs after logging out instead of beforehand.

    As I have an encrypted folder, this means that the script is unable to do what it is meant to do on my files.

    How do I resolve that problem, and run the clean-up script before the actual logout, or at least before the decrypted folder is dismounted? Is there a run-level or some other mechanism?
    Full Circle Magazine :: Cheap Linux stickers :: Problems with WINE?
    In my day, we had outdoors in which to run, play, and socialise. Now we have computers to do those.

  5. #5
    Join Date
    Apr 2013
    Beans
    1

    Re: LightDM login and logout scripts

    Unfortunately this blog is the best documentation of the session-cleanup-script-option, that I found. That's why I'm posting my solution here.

    I wanted a cleanup-possibility on a by-user-basis... this is how i did it:

    in /etc/lightdm/lightdm.conf:
    Code:
    user-session=ubuntu
    greeter-session=unity-greeter
    session-cleanup-script=/usr/local/bin/lightdm_cleanup.sh
    in /usr/local/bin/lightdm_cleanup.sh:
    Code:
    #! /bin/sh
    if [ -e $HOME/.lightdm_cleanup.sh ]; then su -c "$HOME/.lightdm_cleanup.sh" $USER; fi
    now every user can create his own .lightdm_cleanup.

  6. #6
    Join Date
    May 2008
    Location
    United Kingdom
    Beans
    4,274
    Distro
    Ubuntu 14.04 Trusty Tahr

    Re: LightDM login and logout scripts

    Quote Originally Posted by johnklemen View Post
    I wanted a cleanup-possibility on a by-user-basis... this is how i did it…
    Gosh, I had forgotten about this thread! There is another thread where I have done exactly as you have done (see post #9 of that thread).

    However, there still remains a problem (post #20):

    The script runs when I log out by restarting the machine, but it does not run when I merely log out without restarting. So, restarting will run the script, but logging out and then either logging back in or restarting will not run the script.

    I have yet to find a solution to that problem.
    Full Circle Magazine :: Cheap Linux stickers :: Problems with WINE?
    In my day, we had outdoors in which to run, play, and socialise. Now we have computers to do those.

  7. #7
    Join Date
    Apr 2012
    Location
    Quebec, Canada
    Beans
    261
    Distro
    Ubuntu 12.04 Precise Pangolin

    Re: LightDM login and logout scripts

    For some reason, I never got this to work.

    Here's my lightdm.conf file:

    Code:
    [SeatDefaults]
    user-session=ubuntu
    greeter-session=unity-greeter
    display-setup-script=/etc/lightdm/lightdmxrandr.sh
    allow-guest=false
    session-setup-script=/home/Scripts/wallpaper_logon.sh
    session-cleanup-script=/home/Scripts/wallpaper_logoff.sh
    I have an XML file as background, which LightDM does not display (Instead, I can choose a custom background for LightDM!). However, during login, the wallpaper does not fade, and I would love to.

    When I log in, LightDM would be supposed to run this script (Yes, my scripts are executables):

    Code:
    #!/bin/sh
    sleep 4
    gsettings set org.gnome.desktop.background picture-options 'stretched'
    gsettings set org.gnome.desktop.background picture-uri file:///usr/share/backgrounds/friendship_v3/background-1.xml
    Nothing happen. Running the script manually, or adding it to startup applications work, however...

    And at logoff, I want to change it back to LightDM background:

    Code:
    #!/bin/sh
    gsettings set org.gnome.desktop.background picture-uri file:///usr/share/backgrounds/LoginWallpaper4.jpg
    sleep 2
    gnome-session-quit --no-prompt
    gnome-session-quit --no-prompt actually logoff properly, if I run the script manually.

    This is really confusing. Where are my wallpapers supposed to be located? In my Home, or in /Etc/Lightdm ? Same question for the login and logoff scripts ?

    Thank you!

  8. #8
    Join Date
    May 2008
    Location
    United Kingdom
    Beans
    4,274
    Distro
    Ubuntu 14.04 Trusty Tahr

    Re: LightDM login and logout scripts

    GameX2, I'm not entirely sure about your situation. I have two questions:

    1. Which version of Ubuntu are you using?
    2. Why do you have the sleep commands in your scripts? Try doing this again without the sleep.
    Full Circle Magazine :: Cheap Linux stickers :: Problems with WINE?
    In my day, we had outdoors in which to run, play, and socialise. Now we have computers to do those.

  9. #9
    Join Date
    Apr 2012
    Location
    Quebec, Canada
    Beans
    261
    Distro
    Ubuntu 12.04 Precise Pangolin

    Re: LightDM login and logout scripts

    Quote Originally Posted by Paddy Landau View Post
    GameX2, I'm not entirely sure about your situation. I have two questions:

    1. Which version of Ubuntu are you using?
    2. Why do you have the sleep commands in your scripts? Try doing this again without the sleep.
    Thanks for your reply.

    I now use Ubuntu 13.04, but I also have Ubuntu 12.04 installed on the same computer. I can't get it to work on both versions.

    I can put my script "LoginWallpaper.sh" in my startup applications, and it's working. The reason why I have to put the sleep command, is that otherwise, I login, and the background immediately change (Right now, without any delay. I don't see the background fading). I want to avoid such a rapid change. My goal: I have a custom LightDM background - when I login, I still see the LightDM background, then 3-4 seconds later, the background fade to my XML.

    If I run the script Wallpaper_Logoff.sh manually, which set my Desktop background identical to the LightDM background and log me out automatically, this work. But I can't make the script run everytime I logoff/reboot/shutdown.

    A workaround would probably be to run this script, only at login:

    Code:
    gsettings set org.gnome.desktop.background picture-uri file:///usr/share/backgrounds/LoginWallpaper4.jpg
    sleep 4
    gsettings set org.gnome.desktop.background picture-options 'stretched'
    gsettings set org.gnome.desktop.background picture-uri file:///usr/share/backgrounds/friendship_v3/background-1.xml
    At login, I assume LightDM would immediately change my desktop background to the current LightDM background (This sentence sound weird.. Well, my current Desktop background would be identical to the LightDM background). Then 4 seconds later, when the Desktop will appear, the background should fade to the other one.

    Can I even run the command " gsettings set org.gnome.desktop.background picture " from LightDM at all ? I've tried so many times, and never got it working. Even tried changing ownership of the backgrounds to root or "LightDM", no luck.


    Thank you very much.

  10. #10
    Join Date
    May 2008
    Location
    United Kingdom
    Beans
    4,274
    Distro
    Ubuntu 14.04 Trusty Tahr

    Re: LightDM login and logout scripts

    Quote Originally Posted by GameX2 View Post
    Can I even run the command " gsettings set org.gnome.desktop.background picture " from LightDM at all?
    That's a good question. Remember that LightDM runs as root, as I recall, so you'd have to run gsettings as yourself:
    Code:
    su "${USER}" --command gsettings
    Beware if you have other users on the same computer, as the code will affect them. You can put in a condition (replace gamex2 with your user name):
    Code:
    if [[ "${USER}" == 'gamex2' ]]
    then
            su "${USER}" --command gsettings
    fi
    This is not something that I have tried, particularly XML wallpaper (I didn't realise that it was possible), so I cannot be sure that this will work.
    Full Circle Magazine :: Cheap Linux stickers :: Problems with WINE?
    In my day, we had outdoors in which to run, play, and socialise. Now we have computers to do those.

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
  •