#!/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 -o $(swaymsg -p -t get_outputs | grep Output | head -n1 | sed -e 's/Output //g' -e 's/ ''.*$//g') $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 notify-send 'Welcome back!'