From 8ab3d786bbb9365b50c0a20a9009037c532d5eec Mon Sep 17 00:00:00 2001 From: P. J. McDermott Date: Fri, 15 Jun 2018 00:47:50 -0400 Subject: bin/xsession: Warn about other sessions on shutdown/reboot --- diff --git a/bin/xsession b/bin/xsession index 3b1cf86..9b985f6 100755 --- a/bin/xsession +++ b/bin/xsession @@ -3,6 +3,22 @@ set -eu actions_icons='/usr/share/icons/gnome/16x16/actions' +awk_who_script=' + BEGIN { + display_ere = " [(]" display "[)]$"; + printed = 0; + } + { + if (!match($0, display_ere)) { + if (!printed) { + print("\n\nThe following sessions will be " \ + "hung up:\n"); + printed = 1; + } + print(" " $0 ""); + } + } + ' do_logout() { @@ -19,7 +35,8 @@ do_shutdown() { zenity --question --title='Shut Down' \ --window-icon="${actions_icons}/system-shutdown.png" \ - --text='Are you sure you want to shut down this system?' \ + --text="Are you sure you want to shut down this system?$(who | \ + awk -v "display=${DISPLAY}" "${awk_who_script}")" \ --ok-label='Shut Down' --cancel-label='Cancel' && \ sudo shutdown -hP now @@ -30,7 +47,8 @@ do_reboot() { zenity --question --title='Reboot' \ --window-icon="${actions_icons}/system-shutdown.png" \ - --text='Are you sure you want to reboot this system?' \ + --text="Are you sure you want to reboot this system?$(who | \ + awk -v "display=${DISPLAY}" "${awk_who_script}")" \ --ok-label='Reboot' --cancel-label='Cancel' && \ sudo reboot -- cgit v0.9.1