#!/bin/bash source $HOME/.config/sway/bin/sway_helpers IMAGE=$HOME/.lockscreen.png LOCK_IMAGE=$HOME/.config/sway/bin/lock.png OUTPUT=$(swaymsg -t get_outputs -p | grep focused | cut -d " " -f 2) MEDIA_APP=playerctl SCROT_APP=grim SCROT_ARGS=" -o $OUTPUT -t png" LOCK_APP=swaylock LOCK_ARGS=" -f -F -e -s fill -c 000000 --indicator-radius 100 --indicator-thickness 20 -i $IMAGE" INHIBIT_FILE=$HOME/.inhibit_lock function _clean() { rm -vf $IMAGE } function _lock() { _check_inhibit $INHIBIT_FILE $MEDIA_APP pause _check_running $LOCK_APP $LOCK_APP $LOCK_ARGS } function _off() { swaymsg "output * dpms off" } function _on() { swaymsg "output * dpms on" } function _screenshot() { $SCROT_APP $SCROT_ARGS $IMAGE convert -blur 4x4 $IMAGE $IMAGE convert -composite -gravity center $IMAGE $LOCK_IMAGE $IMAGE } ## main _log LOCK INFO args: $* _check_app $LOCK_APP _check_app $SCROT_APP case "$1" in i*) _set_inhibit $INHIBIT_FILE $2 ;; lock) _on _screenshot _lock _clean ;; lockonly) _lock _clean ;; off) _screenshot _off ;; on) _on _clean ;; screenshot) _on _screenshot ;; *) echo "invalid argument \"$1\"" echo "arguments: [inhibit [on|off]|lock|lockonly|off|on|screenshot]" esac