Combine screen lock script for i3 and sway
This commit is contained in:
@ -1,31 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
set -x
|
||||
|
||||
# check if i3lock is running
|
||||
if ps -e | grep " i3lock$"; then
|
||||
echo "i3lock is already running!"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
OPTIONAL_CMDS="scrot lockscreen-blur"
|
||||
|
||||
for CMD in $OPTIONAL_CMDS; do
|
||||
echo "checking $CMD"
|
||||
if ! command -v "$CMD" &> /dev/null
|
||||
then
|
||||
echo "$CMD could not be found, falling back to basic mode."
|
||||
|
||||
i3lock -c 302f3b "$@"
|
||||
|
||||
exit 0
|
||||
fi
|
||||
done
|
||||
|
||||
TMP_IMG="/tmp/lock.png"
|
||||
|
||||
scrot - | lockscreen-blur -o "$TMP_IMG" -b 20 --stamp ~/.config/sway/ferris-stamp.png
|
||||
|
||||
i3lock -nef --image="$TMP_IMG" "$@"
|
||||
|
||||
rm "$TMP_IMG"
|
||||
41
tree/.local/bin/screenlock.tpl
Executable file
41
tree/.local/bin/screenlock.tpl
Executable file
@ -0,0 +1,41 @@
|
||||
#!/bin/sh
|
||||
|
||||
TMP_IMG="/tmp/lock.png"
|
||||
|
||||
{% if hostname == "sputnik" %}
|
||||
|
||||
LOCKPROG=i3lock
|
||||
LOCKARGS="-nef --image=$TMP_IMG"
|
||||
LOCKARGS_NOCOOL="-c 302f3b"
|
||||
OPTIONAL_CMDS="scrot lockscreen-blur"
|
||||
SCREENCAP="scrot -"
|
||||
BLUR_FACTOR=20
|
||||
|
||||
{% elif hostname == "sputnik" %}
|
||||
|
||||
LOCKPROG=swaylock
|
||||
LOCKARGS="--config ~/.config/sway/swaylock.config --image $TMP_IMG"
|
||||
LOCKARGS_NOCOOL="--config ~/.config/sway/swaylock.config --color 302f3b"
|
||||
OPTIONAL_CMDS="grim lockscreen-blur"
|
||||
SCREENCAP="grim -t ppm -"
|
||||
BLUR_FACTOR=40
|
||||
|
||||
{% else %}
|
||||
echo "screenlock not configured for this system"
|
||||
exit 1
|
||||
{% end %}
|
||||
|
||||
for CMD in $OPTIONAL_CMDS; do
|
||||
if ! command -v "$CMD" &> /dev/null
|
||||
then
|
||||
echo "$CMD could not be found, falling back to basic mode."
|
||||
|
||||
$LOCKPROG $LOCKARGS_NOCOOL "$@"
|
||||
|
||||
exit 0
|
||||
fi
|
||||
done
|
||||
|
||||
$SCREENCAP | lockscreen-blur -o $TMP_IMG -b $BLUR_FACTOR --stamp ~/.config/wallpapers/ferris-stamp.png
|
||||
|
||||
$LOCKPROG $LOCKARGS "$@"
|
||||
@ -1,28 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
# check if swaylock is running
|
||||
if ps -e | grep " swaylock$"; then
|
||||
echo "swaylock is already running!"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
OPTIONAL_CMDS=("convert" "python3" "grim", "lockscreen-blur")
|
||||
|
||||
for CMD in $OPTIONAL_CMDS; do
|
||||
if ! command -v "$CMD" &> /dev/null
|
||||
then
|
||||
echo "$CMD could not be found, falling back to basic mode."
|
||||
|
||||
swaylock --config ~/.config/sway/swaylock.config --color 302f3b "$@"
|
||||
|
||||
exit 0
|
||||
fi
|
||||
done
|
||||
|
||||
TMP_IMG="/tmp/lock.png"
|
||||
|
||||
grim -t ppm - | lockscreen-blur -o "$TMP_IMG" -b 40 --stamp ~/.config/sway/ferris-stamp.png
|
||||
|
||||
swaylock --config ~/.config/sway/swaylock.config --image "$TMP_IMG" "$@"
|
||||
|
||||
rm "$TMP_IMG"
|
||||
Reference in New Issue
Block a user