fixed suspend :) (lock now doesn't fork when --suspend flag is passed)

This commit is contained in:
Rick van Lieshout 2019-02-22 09:15:10 +01:00
parent caec5d5d04
commit d60e9c848f
2 changed files with 14 additions and 8 deletions

View File

@ -6,8 +6,6 @@ tmpbg='/tmp/screen.png'
# detect whether spotify is running
isPlaying=$(~/.config/i3/scripts/spotify-cli.sh status);
(( $# )) && { icon=$1; }
scrot "$tmpbg"
convert "$tmpbg" -scale 10% -scale 1000% "$tmpbg"
convert "$tmpbg" "$icon" -gravity center -composite -matte "$tmpbg"
@ -15,9 +13,17 @@ convert "$tmpbg" "$icon" -gravity center -composite -matte "$tmpbg"
# Stop music if playing
~/.config/i3/scripts/spotify-cli.sh pause
i3lock -n -f -i "$tmpbg";
# check whether the lockscreen is being activated because of a suspend
if [[ $* == *--suspend ]]; then
# if it is, simply lock without no-fork
i3lock -f -i "$tmpbg";
else
# if it isn't suspended, enable no-fork
i3lock -n -f -i "$tmpbg";
# if spotify was playing before we locked, resume.
if [ $isPlaying == "Playing" ]; then
~/.config/i3/scripts/spotify-cli.sh play
fi;
# if spotify was playing before we locked, resume.
if [ $isPlaying == "Playing" ]; then
~/.config/i3/scripts/spotify-cli.sh play
fi;
fi

View File

@ -3,7 +3,7 @@
# check if locked
if !(pgrep -x "i3lock" > /dev/null)
then
bash ~/.config/i3/scripts/i3lock.sh
bash ~/.config/i3/scripts/i3lock.sh --suspend
fi
systemctl suspend