diff options
Diffstat (limited to 'src/usr/libexec')
-rwxr-xr-x | src/usr/libexec/logout-manager/lm-helper | 74 |
1 files changed, 74 insertions, 0 deletions
diff --git a/src/usr/libexec/logout-manager/lm-helper b/src/usr/libexec/logout-manager/lm-helper new file mode 100755 index 0000000..6372827 --- /dev/null +++ b/src/usr/libexec/logout-manager/lm-helper @@ -0,0 +1,74 @@ +#!/bin/sh +# Dependencies: +# Devuan: wmctrl sudo +# el7: wmctrl sudo +case "${1}" in + help) # show this help screen + { + echo "Usage: ${0}: [command]" + echo "used by logout-manager to perform actions like reboot, lock screen, etc." + echo "" + echo "Commands:" + grep -E '^\s{3}[A-Za-z]+\)' "${0}" | tr -dc '[A-Za-z\n ]' | sed -r -e 's/\s+/ /g;' | grep -v "HIDDEN\s*$" | while read a therest ; do echo " ${a}: ${therest}" ; done + } + ;; + options) # used by bash_completion function HIDDEN + 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 + if test -z "${DRYRUN}" ; + then + xscreensaver --locknow + else + echo "xscreensaver --locknow" + fi + ;; + logout) # log out the current user of the graphical session + # 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 + # 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 + if test -z "${DRYRUN}" ; + then + shutdown -h now + else + echo "shutdown -h now" + fi + ;; + reboot) # restart the system + if test -z "${DRYRUN}" ; + then + shutdown -r now + else + echo "shutdown -r now" + fi + ;; + *) # HIDE + echo "invalid choice: ${1}" 1>&2 + exit 1 + ;; +esac +: |