Results 1 to 8 of 8

Thread: How to execute a script on logut in Ubuntu 14.04

  1. #1
    Join Date
    Nov 2014
    Beans
    45

    How to execute a script on logut in Ubuntu 14.04

    http://askubuntu.com/questions/29331...down-in-ubuntu

    In this thread it gets explained where to put a script so it executes everytime one logs out of ubuntu.

    The file /etc/lightdm/lightdm.conf is missing in my installation of Ubuntu 14.04.

    Where is i gone?
    Wehere can i paste the line session-cleanup-script=/path/to/script to execute the script i created on logout.

    Thanks if you helping.

  2. #2
    Join Date
    Jul 2013
    Location
    Wisconsin
    Beans
    4,952

    Re: How to execute a script on logut in Ubuntu 14.04

    What kinds of cleanup do you envision?

    Do-an-action-upon-logout may be unreliable, because some sessions end without a logout.
    Power failures, hardware failures, and several kinds of crashes may end a session. Sometimes merely resetting the X server, other times causing real grief.

    One answer:
    In 14.04, systemd-logind (provided by the libsystemd-login0 package) emits a dbus signal when a session logs in or out.
    You can easily write a listener for those signals. It may need a little logic to read the signal and determine if it should launch the script.

  3. #3
    Join Date
    Aug 2014
    Beans
    Hidden!
    Distro
    Ubuntu 16.04 Xenial Xerus

    Re: How to execute a script on logut in Ubuntu 14.04

    Not sure if this still works but from my notes.... "In 14.04 add to /usr/share/lightdm/lightdm.conf.d/50-unity-greeter.conf"
    Code:
    gksudo gedit /usr/share/lightdm/lightdm.conf.d/50-unity-greeter.conf
    You will probably need to restart to reload lightdm, then your session-cleanup-script should work on next logout.
    Last edited by CantankRus; March 7th, 2015 at 10:34 AM.

  4. #4
    Join Date
    Nov 2014
    Beans
    45

    Re: How to execute a script on logut in Ubuntu 14.04

    Quote Originally Posted by ian-weisser View Post
    What kinds of cleanup do you envision?

    Do-an-action-upon-logout may be unreliable, because some sessions end without a logout.
    Power failures, hardware failures, and several kinds of crashes may end a session. Sometimes merely resetting the X server, other times causing real grief.

    One answer:
    In 14.04, systemd-logind (provided by the libsystemd-login0 package) emits a dbus signal when a session logs in or out.
    You can easily write a listener for those signals. It may need a little logic to read the signal and determine if it should launch the script.
    What i want to achieve is that a script running
    Code:
    sdmem -llfv
    will execute upon logout.
    The idea behind it is to install ubuntu to a thumbdrive withan encrypted home partition. Before i leave the house i shut down my netbook, plugin the usb drive, start the system, login, start recording using cheese or motion, logout and leave the house.
    This should in my theory prevent an intruder to perform a cold boot attack in order to extract the login password, or the home directory encryption key and perform any changes on my hardware before leaving the appartment and make it look for me as if nothing has happened.
    I have read about some special cases in which sdmem would not be able to fully wipe the RAM and one person told me i should try out TRESOR but first i want to finish with this task.




    Quote Originally Posted by CantankRus View Post
    Not sure if this still works but from my notes.... "In 14.04 add to /usr/share/lightdm/lightdm.conf.d/50-unity-greeter.conf"
    Code:
    gksudo gedit /usr/share/lightdm/lightdm.conf.d/50-unity-greeter.conf
    You will probably need to restart to reload lightdm, then your session-cleanup-script should work on next logout.
    Thank you i will try it the way you described.

  5. #5
    Join Date
    Nov 2014
    Beans
    45

    Re: How to execute a script on logut in Ubuntu 14.04

    I have edited the 50-unity-greeter.conf adding the line:
    session-cleanup-script=/home/ubunt/Dokumente/Scripts/sdmem.sh in the end of the file.
    Then i saved the file and rebooted.
    After entering my login credentials i was presented with a black screen.
    I restored my Laptop and am wondering if i misunderstood something and made a mistake editing the greeter.conf file or what else might cause the failure.
    One of the first things i did on this laptop was applying the brightness fix as described in the following link.
    http://itsfoss.com/fix-brightness-ubuntu-1310/
    Could this change cause a problem?

  6. #6
    Join Date
    Nov 2014
    Beans
    45

    Re: How to execute a script on logut in Ubuntu 14.04

    Anyone?

  7. #7
    Join Date
    Aug 2014
    Beans
    Hidden!
    Distro
    Ubuntu 16.04 Xenial Xerus

    Re: How to execute a script on logut in Ubuntu 14.04

    Test something simple to run when you logout.
    eg I just use this to clear recent in nautilus
    lightdm-session-cleanup.sh
    Code:
    #!/bin/bash
    
    ## Clears Recent in nautilus
    echo > /home/glen/.local/share/recently-used.xbel
    Edit for your username

    and my /usr/share/lightdm/lightdm.conf.d/50-unity-greeter.conf file...
    Code:
    [SeatDefaults]
    greeter-session=unity-greeter
    session-cleanup-script=/home/glen/scripts/lightdm-session-cleanup.sh
    Edit for path to script
    Check recent in nautilus before and after you logout.

    If recent files are cleared, problem is in your original script.
    Post the script your using.
    Last edited by CantankRus; March 9th, 2015 at 06:08 AM.

  8. #8
    Join Date
    Nov 2014
    Beans
    45

    Re: How to execute a script on logut in Ubuntu 14.04

    Big thanks for the help CantankRus i guess the problem was the -v in the script because it works now without.

    #!/bin/bash

    sdmem -llf

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
  •