Hello all. I’m trying to launch a login message in 11.3 using /etc/motd. I’ve searched around and seen that some users have accomplished this by editing /etc/x11/xdm/xsession.d . I want to add something along the lines of
xmessage -file /etc/motd/ -center -buttons Accept -default Accept
I have tried inserting this line into a few files mentioned in posts in other forums but none seem to correlate with OpenSUSE 11.3. If anyone provide any insight, I would appreciate it.
Providing you’re using xdm, you could write that command in /etc/X11/xdm/Xsession. Dont’ forget to put a “&” at the end. I will work for ‘traditionnal’ wms like twm, icewm, fvwm, etc. However for Gnome, KDE, Xfce and LXDE sessions, you should rather create a .desktop file with that command and put it in /etc/xdg/autostart if you want this message to appear for all users.
[Desktop Entry]
X-SuSE-translate=true
Name=Welcome
Type=Application
Exec=xmessage -file /etc/motd -center -buttons Accept -default Accept
Terminal=false
Comment=Display the content of /etc/motd at session login
copy/paste the code above, save as /etc/xdg/autostart/welcome.desktop.
That should do it.
Wow, thanks for the quick response! After searching around a little more, I came to the same conclusion to run this from the /etc/xdg/autostart folder. I found a neat program that takes messages a bit further than xmessage. It is called zenity. It seems that zenity is much more flexible albit complicated than xmessage. Currently I’ve got the message working using /etc/xdg/autostart solution but now I’d like to see if I can make it popup before the desktop loads or at least force the focus to this window. If anything else loads up, this message gets hidden underneath everything else hence why I’d like to get it into the xsession.d file.
Hey, just to follow up, I wrote a bash script which I placed in /etc/profile.local
This does what I want it to do rather well. For SSH sessions, the GUI interaction is negated and instead a message with the time & date are delivered.
# Interactive Login Consent Banner w/SSH Detection & Support
# Created 11/18/2010 - Brian R Dwyer - Morrisville State College
SSH=$(env | grep SSH_CONNECTION)
if "$SSH" ]
then
echo "By connecting to this node, you accept the Terms of Use."
date
else
zenity --info \
--text="$(cat /etc/motd)" --title="CITA Domain Usage Consent"
ANSWER=$(xmessage "Do you acknowledge consent?" -center -buttons Decline,Accept -print)
if "$ANSWER" = "Decline" ]
then
zenity --info \
--text "Decline responses to the Consent Banner are automatically logged off. Goodbye." --timeout 15
exit
else
zenity --info \
--text "CITA Domain - Please wait while you are logged in." --timeout 3
fi
fi
#End of Login Consent Banner
You’ll get a “cannot open display” error if you happen to log in locally in console mode. You should replace the first “else” with
elif "$DISPLAY" ] ; then
Thanks for the heads up. I’m relatively inexperienced with bash scripting and any input is appreciated. Do I need to declare DISPLAY like I did SSH? I haven’t inserted that line of code in yet because I’m unsure of what substuting that line will do and I don’t want to lock myself out of my system.
This script is acting a little funky though, sometimes after clicking accept or decline on the xmessage dialog, it reverts back to the initial zenity MOTD dialog. I’m sure I did something silly. It doesn’t cause any errors or anything like that, sometimes it loops. When this occurs, it always functions perfectly after clicking accept or decline again. I am puzzled as to why sometimes it works flawlessly and sometimes this occurs. The only language I am familiar with creating loops and if statements is VB. This does seem awfully similar though.
No! X does set DISPLAY. If you set DISPLAY yourself checking whether it is empty won’t tell you if you are under X or not. One case where you would set DISPLAY is for example inside a SSH connection (with X tunneling enabled) if you want to run a GUI application on the server and have it displayed on your client.
Here’s a better way to do it (probably not the best one but it works if you’re using kdm ) :
For ssh, you could simply put the message in a banner file defined in /etc/ssh/sshd_config with the option Banner. Example:
Banner /etc/sshWelcome
For X login (over kdm) you can add this code (in red) in /etc/X11/xdm/Xstartup. But make a copy of the original and of the new file:
# If login is disabled, give an appropriate message
# and exit if normal user knock on.
#
if test -r $NOLOGIN ; then
$xmessage -file $NOLOGIN -timeout 10 -default okay -center
test "$RUID" != "0" && exit 1
fi
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#zenity --info --text="$(cat /etc/motd)" --title="CITA Domain Usage Consent"
zenity --question --text="Do you acknowledge consent?" --title="CITA Domain Usage Consent"
case $? in
0)
zenity --info --text "CITA Domain - Please wait while you are logged in." --timeout=3
;;
1)
zenity --info --text "Decline responses to the Consent Banner are automatically logged off. Goodbye." --timeout=15
exit
;;
esac
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# Find out if this is a local or remote connection
#
LOCATION=${DISPLAY%:*}
LINE=:${DISPLAY#*:}