summaryrefslogtreecommitdiffstats
path: root/bin
diff options
context:
space:
mode:
authorP. J. McDermott <pj@pehjota.net>2018-06-15 00:47:50 (EDT)
committer P. J. McDermott <pj@pehjota.net>2018-06-15 00:47:50 (EDT)
commit3283e2189c57074107d4a58956335b5e567187c6 (patch)
tree2aae6eeae032537eef3bfee812a47db5bb56d228 /bin
parent6f8dc6eb9a6d7dc302eb4f6184caa6febe2de414 (diff)
downloadfluxbox-3283e2189c57074107d4a58956335b5e567187c6.zip
fluxbox-3283e2189c57074107d4a58956335b5e567187c6.tar.gz
fluxbox-3283e2189c57074107d4a58956335b5e567187c6.tar.bz2
bin/xsession: Warn about other sessions on shutdown/reboot
Diffstat (limited to 'bin')
-rwxr-xr-xbin/xsession22
1 files changed, 20 insertions, 2 deletions
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("<tt><small> " $0 "</small></tt>");
+ }
+ }
+ '
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