How do I create a popup banner before login with Lightdm?

7,472

The configuration file /etc/lightdm/lightdm.conf defines the available sessions. The sessions themselves are defined in /usr/share/xsessions. It should be not a problem to modify the default /usr/share/xsessions/ubuntu.desktop to wrap the gnome-session command around in a script that first displays the zenity dialog, and then either exits with a nonzero status or launches the gnome-session command.

Specifically:

  1. Create a file called /usr/bin/mysess.sh which contains, for example, the following:

    #!/bin/bash
    
    if  /usr/bin/zenity --question --text="`cat /etc/issue`" --no-wrap ; then gnome-session --session=ubuntu ; else exit 1 ; fi
    

    To edit this file, use

    gksu gedit /usr/bin/mysess.sh
    

    Also, make it executable

    sudo chmod a+x /usr/bin/mysess.sh
    
  2. Modify the file /usr/share/xsessions/ubuntu.desktop as follows:

    [Desktop Entry]
    Name=Ubuntu
    Comment=This session logs you into Ubuntu
    Exec=/usr/bin/mysess.sh
    TryExec=unity
    Icon=
    Type=Application
    X-Ubuntu-Gettext-Domain=gnome-session-3.0
    

Now, if anyone tries to log on, the person has to click "Yes" in order to log in; otherwise, it will return to the login screen.

Share:
7,472

Related videos on Youtube

Rich Loring
Author by

Rich Loring

Updated on September 18, 2022

Comments

  • Rich Loring
    Rich Loring over 1 year

    When Ubuntu was using gnome I was able to create a popup banner like the banner below before the login screen using zenity in the /etc/gdm/Init/Default. The line of code would be like this:

    if [ -f "/usr/bin/zenity" ]; then /usr/bin/zenity --info --text="`cat /etc/issue`" --no-wrap; else xmessage -file /etc/issue -button ok -geometry 540X480; fi
    

    How can I accomplish this with Unity?

    NOTICE TO USERS

    This is a computer system and/or it is directly connected to a local network system. It is for authorized use only. Users (authorized or unauthorized) have no explicit or implicit expectation of privacy.

    Any or all uses of this system and all files on this system may be intercepted, monitored, recorded, copied, audited, inspected, and disclosed to authorized site, Department of Energy, and law enforcement personnel, as well as authorized officials of other agencies, both domestic and foreign. By using this system, the user consents to such interception, monitoring, recording, copying, auditing, inspection, and disclosure at the discretion of authorized site or personnel.

    Unauthorized or improper use of this system may result in administrative disciplinary action and civil and criminal penalties. By continuing to use this system you indicate your awareness of and consent to these terms and conditions of use.

    LOG OFF IMMEDIATELY if you do not agree to the conditions stated in this warning.

    • Admin
      Admin almost 10 years
      This doesn't work in Ubuntu 12.04 :(