dotfiles

Obligatory dotfiles repo
git clone git://git.danielmoch.com/dotfiles.git
Log | Files | Refs

commit 7c930376668b3392c078a2cd225116bd526f4120
parent b57721fd3456d028dcb2f4e22ff01f37993bbcaf
Author: Daniel Moch <daniel@danielmoch.com>
Date:   Sun, 28 Jan 2018 12:57:59 -0500

Handle edge cases in "my lock" and "my standby"

Light locker is the main culprit in terms of non-standard behavior. Just
issue DPMS and standy commands rather than calling light-locker
directly.

Diffstat:
M.local/bin/my | 39++++++++++++++++++++++++++-------------
1 file changed, 26 insertions(+), 13 deletions(-)

diff --git a/.local/bin/my b/.local/bin/my @@ -18,6 +18,21 @@ __mylog() echo "$1 (`date +'%m/%d/%Y %H:%M:%S'`): $2" >> $log } +__getlocker() +{ + for locker in light-locker cinnamon-screensaver gnome-screensaver xscreensaver + do + if type $locker-command > /dev/null 2>&1 && ps -U $LOGNAME -o cmd= | grep ^[^_[:space:]]*$locker > /dev/null 2>&1 + then + echo $locker + exit 0 + fi + done + + __mylog "__getlocker" "No screen locker running" + exit 1 +} + case $command in term) : ${XDG_CURRENT_DESKTOP:=${XDG_SESSION_DESKTOP:-X-Generic}} @@ -55,22 +70,14 @@ case $command in lock) sleep 1 - for locker in light-locker cinnamon-screensaver gnome-screensaver xscreensaver - do - if type $locker-command > /dev/null 2>&1 && ps -U $LOGNAME -o cmd= | grep ^[^_[:space:]]*$locker > /dev/null 2>&1 - then - locker="$locker-command -l" - locker_running=1 - break - fi - done + locker=`__getlocker` - if [ -z "$locker_running" ] + [ -z "$locker" ] && exit 1 + if [ "$locker" = "light-locker" ] then - __mylog "my lock" "No screen locker running" - exit 1 + exec xset dpms force off else - exec $locker + exec $locker-command -l fi ;; wallpaper) @@ -80,6 +87,12 @@ case $command in standby) if type systemctl > /dev/null 2>&1 then + locker=`__getlocker` + [ -z "$locker" ] && exit 1 + if [ ! "$locker" = "light-locker" ] + then + $locker-command -l + fi exec systemctl hybrid-sleep else __mylog "my standby" "No handler found"