2024-01-06 11:35:43 +08:00
|
|
|
#!/bin/bash
|
2023-12-15 13:57:38 +08:00
|
|
|
#
|
|
|
|
# Modified from sway's locking script
|
2024-03-21 10:41:45 +08:00
|
|
|
# TODO: remove bashism
|
2023-12-15 13:57:38 +08:00
|
|
|
|
2024-03-21 10:41:45 +08:00
|
|
|
if [[ ! $(which swayidle 2>/dev/null) ]]; then
|
|
|
|
notify-send "ERROR" "Swayidle not found"
|
|
|
|
exit 1
|
2023-12-15 13:57:38 +08:00
|
|
|
fi
|
|
|
|
|
2024-02-18 15:28:35 +08:00
|
|
|
choices=("suspend" "poweroff" "reboot" "lock")
|
2024-03-06 21:30:43 +08:00
|
|
|
choice=$(printf "%s\n" "${choices[@]}" | fuzzel -d --prompt "🔌: ")
|
2023-12-15 13:57:38 +08:00
|
|
|
|
2024-03-21 10:41:45 +08:00
|
|
|
if test "$choice" = lock; then
|
|
|
|
sleep 0.3
|
2024-04-22 21:08:35 +08:00
|
|
|
# playerctl stop
|
2024-03-21 10:41:45 +08:00
|
|
|
|
2024-04-22 21:08:35 +08:00
|
|
|
bright=$(xbacklight -get)
|
2024-03-21 10:41:45 +08:00
|
|
|
|
|
|
|
swayidle -w \
|
2024-04-22 21:08:35 +08:00
|
|
|
timeout 5 "xbacklight -set 0" resume "xbacklight -set $bright" \
|
2024-03-21 10:41:45 +08:00
|
|
|
&
|
2024-04-22 21:08:35 +08:00
|
|
|
# timeout $sleep_time 'swaymsg "output * power off"' resume 'swaymsg "output * power on"' \
|
2024-03-21 10:41:45 +08:00
|
|
|
idlepid=$!
|
|
|
|
|
2024-11-11 17:09:51 +08:00
|
|
|
swaylock -e -c 282828 --inside-color 00000003
|
|
|
|
# swaylock -S --effect-blur "12x12" --effect-greyscale --effect-vignette 0.5:0.5 --inside-color 28282860 \
|
|
|
|
# -e --ring-color 00000000 --line-color 00000000 --indicator --clock --text-color ebdbb2
|
2024-03-21 10:41:45 +08:00
|
|
|
|
|
|
|
kill $idlepid
|
|
|
|
swaymsg "output * power on"
|
2024-04-22 21:08:35 +08:00
|
|
|
xbacklight -set $bright
|
2023-12-15 13:57:38 +08:00
|
|
|
elif test -n "$choice"; then
|
2024-03-21 10:41:45 +08:00
|
|
|
systemctl $choice
|
2022-06-25 21:26:38 +08:00
|
|
|
fi
|