added sway-locker

* a little script to..lock sway
This commit is contained in:
surtur 2020-04-29 12:42:07 +02:00
parent 4758e95287
commit e6b82f10ee
Signed by: wanderer
GPG Key ID: 19CE1EC1D9E0486D

41
bin/sway-locker Executable file

@ -0,0 +1,41 @@
#!/bin/bash
# Inhibit screen locker when media players are running
# Cheap method, add missing players to regex
isrunning=1
player=`ps -u $USER | grep -Ec "(rhythmbox|totem|mpv|vlc|*mplayer)"`
if [ "$player" -ge "$isrunning" ]; then
if [ "$1" == "-t" ]; then
dbus-send --type=method_call --dest=org.mpris.MediaPlayer2.vlc /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.PlayPause
else
if [ "$1" != "-f" ]; then
exit 1
fi
fi
fi
revert() {
swaymsg "output * dpms on"
rm -Rf $HOME/.tmp
}
wdir=$HOME/.tmp/lckr
screen1=$wdir/l1.png
icon=/usr/share/pixmaps/fedora-logo-sprite.png # with style
lwaucj=$wdir/nuvdsp.png
mkdir -p $wdir && chmod 1700 $wdir
grim $screen1 # take a screenshot
convert $screen1 -scale 10% -scale 1000% $screen1
convert $screen1 $icon -gravity center -composite -matte $lwaucj && rm $screen1
# Lock screen using swaylock showing number of failed attempts, not forking,
# ignoring empty password (possibly without unlock indicator (-u))
swaylock -f -n -e -i "$lwaucj" || swaylock -f -e -n -c 141414 # just dark-grey
trap revert exit
# EXIT HUP INT TERM - 0 1 3 15
revert