diff options
author | B Stack <bgstack15@gmail.com> | 2020-03-10 22:05:48 -0400 |
---|---|---|
committer | B Stack <bgstack15@gmail.com> | 2020-03-10 22:05:48 -0400 |
commit | e59268441a9f46f806e74c9bc8ddc9a0b224c60d (patch) | |
tree | 15cfc2f066261d4fa9e222995646ec4af2271031 /src/usr/libexec | |
parent | WIP: add lm-helper (diff) | |
download | logout-manager-e59268441a9f46f806e74c9bc8ddc9a0b224c60d.tar.gz logout-manager-e59268441a9f46f806e74c9bc8ddc9a0b224c60d.tar.bz2 logout-manager-e59268441a9f46f806e74c9bc8ddc9a0b224c60d.zip |
add DRYRUN and bash_completion to lm-helper
Diffstat (limited to 'src/usr/libexec')
-rwxr-xr-x | src/usr/libexec/logout-manager/lm-helper | 52 |
1 files changed, 44 insertions, 8 deletions
diff --git a/src/usr/libexec/logout-manager/lm-helper b/src/usr/libexec/logout-manager/lm-helper index c5e37f1..e791f28 100755 --- a/src/usr/libexec/logout-manager/lm-helper +++ b/src/usr/libexec/logout-manager/lm-helper @@ -1,4 +1,6 @@ #!/bin/sh +# Dependencies: +# Devuan: wmctrl case "${1}" in help) # show this help screen { @@ -10,24 +12,58 @@ case "${1}" in } ;; options) # used by bash_completion function HIDDEN - grep -E '^\s{3}[A-Za-z]+\)' "${0}" | tr -dc '[A-Za-z\n]' | grep -vE 'options|help' + grep -E '^\s{3}[A-Za-z]+\)' "${0}" | awk '{print $1}' | tr -dc '[A-Za-z\n]' | grep -vE 'options|help' ;; lock) # lock the current screen - xscreensaver --locknow + if test -z "${DRYRUN}" ; + then + xscreensaver --locknow + else + echo "xscreensaver --locknow" + fi ;; logout) # log out the current user of the graphical session - echo "Gotta say unh! Feature not yet implemented." 1>&2 - exit 1 + # determine DE/WM and act accordingly + _wm="$( wmctrl -m | awk '/Name:/{$1="";print;}' | xargs )" + case "${_wm}" in + Fluxbox) + if test -z "${DRYRUN}" ; + then + fluxbox-remote exit + else + echo "fluxbox-remote exit" + fi + ;; + *) + echo "Gotta say unh! Feature not yet implemented for \"${_wm}\"" 1>&2 + exit 1 + ;; + esac ;; hibernate) # save system state to disk and power off - # linux only - printf 'disk' | tee /sys/power/state + # this method is linux only + if test -z "${DRYRUN}" ; + then + printf 'disk' | tee /sys/power/state + else + echo "printf 'disk' | tee /sys/power/state" + fi ;; shutdown) # power off - shutdown -h now + if test -z "${DRYRUN}" ; + then + shutdown -h now + else + echo "shutdown -h now" + fi ;; reboot) # restart the system - shutdown -r now + if test -z "${DRYRUN}" ; + then + shutdown -r now + else + echo "shutdown -r now" + fi ;; *) # HIDE echo "invalid choice: ${1}" 1>&2 |