sway: fix screenshots on lock
This commit is contained in:
parent
9ecb2f2a68
commit
2dc0b34814
2 changed files with 74 additions and 16 deletions
78
bin/lock
78
bin/lock
|
@ -1,13 +1,71 @@
|
|||
#!/bin/bash
|
||||
IMAGE=/tmp/screen_locked.png
|
||||
APP=grim
|
||||
IMAGE=$HOME/.lockscreen.jpg
|
||||
SCROT_APP=grim
|
||||
SCROT_ARGS=" -t jpeg"
|
||||
LOCK_APP=swaylock
|
||||
LOCK_ARGS=" -f -c 000000 -i $IMAGE"
|
||||
|
||||
which $APP &> /dev/null
|
||||
if [ $? -eq 0 ]; then
|
||||
$APP $IMAGE
|
||||
|
||||
function _app_exists() {
|
||||
which $1 &> /dev/null
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "ERROR: missing app \"$1\""
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
function _clean() {
|
||||
rm -vf $IMAGE
|
||||
}
|
||||
|
||||
function _lock() {
|
||||
_app_exists $LOCK_APP
|
||||
$LOCK_APP $LOCK_ARGS
|
||||
}
|
||||
|
||||
function _off() {
|
||||
swaymsg "output * dpms off"
|
||||
}
|
||||
|
||||
function _on() {
|
||||
swaymsg "output * dpms on"
|
||||
}
|
||||
|
||||
function _screenshot() {
|
||||
_app_exists $SCROT_APP
|
||||
$SCROT_APP $SCROT_ARGS $IMAGE
|
||||
convert -blur 4x4 $IMAGE $IMAGE
|
||||
swaylock -f -c 000000 -i $IMAGE
|
||||
rm -v $IMAGE
|
||||
else
|
||||
swaylock -f -c 000000
|
||||
fi
|
||||
}
|
||||
|
||||
mkdir -p $HOME/log
|
||||
echo "lock: $(date) args: $*" >> $HOME/log/lock.log
|
||||
|
||||
case "$1" in
|
||||
lock)
|
||||
_on
|
||||
_screenshot
|
||||
_lock
|
||||
_clean
|
||||
;;
|
||||
lockonly)
|
||||
_lock
|
||||
_clean
|
||||
;;
|
||||
off)
|
||||
_screenshot
|
||||
_off
|
||||
;;
|
||||
on)
|
||||
_on
|
||||
_clean
|
||||
;;
|
||||
screenshot)
|
||||
_on
|
||||
_screenshot
|
||||
;;
|
||||
*)
|
||||
echo "invalid argument \"$1\"."
|
||||
echo "arguments: [lock|lockonly|off|on|screenshot]"
|
||||
esac
|
||||
|
||||
|
||||
|
|
12
config
12
config
|
@ -32,12 +32,12 @@ output * bg $background fill
|
|||
|
||||
### Idle configuration
|
||||
exec swayidle -w \
|
||||
timeout 600 'swaymsg "output * dpms off"' \
|
||||
resume 'swaymsg "output * dpms on"' \
|
||||
timeout 900 '$lock_cmd' \
|
||||
timeout 1800 'systemctl suspend-then-hibernate' \
|
||||
before-sleep '$lock_cmd'
|
||||
bindsym $mod+Ctrl+Escape exec $lock_cmd
|
||||
timeout 600 '$lock_cmd off' \
|
||||
resume '$lock_cmd on' \
|
||||
timeout 900 '$lock_cmd lockonly' \
|
||||
timeout 1800 '$lock_cmd suspend' \
|
||||
before-sleep 'systemctl suspend-then-hibernat'
|
||||
bindsym $mod+Ctrl+Escape exec '$lock_cmd lock'
|
||||
|
||||
### Input configuration
|
||||
# You can get the names of your inputs by running: swaymsg -t get_inputs
|
||||
|
|
Loading…
Reference in a new issue