2023-12-03 13:36:10 +08:00
|
|
|
#!/bin/sh
|
|
|
|
#
|
|
|
|
# Modified from sway's locking script
|
|
|
|
|
|
|
|
|
2023-12-03 14:28:53 +08:00
|
|
|
if [[ ! $(which swayidle 2> /dev/null) ]]; then
|
|
|
|
notify-send "ERROR" "Swayidle not found"
|
|
|
|
exit 1
|
2023-12-03 13:36:10 +08:00
|
|
|
fi
|
|
|
|
|
2023-12-03 16:56:43 +08:00
|
|
|
choice=$(echo -e "suspend\nshutdown\npoweroff\nreboot\nlock" | wofi -d --prompt " Choose power option" -Oalphabetical)
|
|
|
|
|
|
|
|
|
2023-12-03 13:36:10 +08:00
|
|
|
if test "$choice" = lock ; then
|
2023-12-28 22:02:02 +08:00
|
|
|
# don't sleep when power on
|
2023-12-03 16:56:43 +08:00
|
|
|
if acpi -a | grep -q on; then
|
2023-12-28 22:02:02 +08:00
|
|
|
sleep_time=86400
|
2023-12-03 16:56:43 +08:00
|
|
|
else
|
|
|
|
sleep_time=10
|
|
|
|
fi
|
|
|
|
sleep 0.3
|
|
|
|
|
2023-12-03 13:36:10 +08:00
|
|
|
bright=`light`
|
2023-12-03 16:56:43 +08:00
|
|
|
|
2023-12-03 13:36:10 +08:00
|
|
|
swayidle -w \
|
2023-12-15 13:57:38 +08:00
|
|
|
timeout 5 "light -S 1" resume "light -S $bright" \
|
|
|
|
timeout $sleep_time 'hyprctl dispatch dpms off' resume 'hyprctl dispatch dpms on' \
|
|
|
|
&
|
2023-12-03 13:36:10 +08:00
|
|
|
idlepid=$!
|
2023-12-03 16:56:43 +08:00
|
|
|
|
2023-12-03 14:28:53 +08:00
|
|
|
# swaylock -e -c 282828 --inside-color 00000003
|
2023-12-07 11:31:31 +08:00
|
|
|
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
|
2023-12-03 16:56:43 +08:00
|
|
|
|
2023-12-03 13:36:10 +08:00
|
|
|
kill $idlepid
|
2023-12-03 16:56:43 +08:00
|
|
|
|
|
|
|
pkill waybar
|
2023-12-03 13:36:10 +08:00
|
|
|
hyprctl dispatch dpms on
|
2023-12-03 16:56:43 +08:00
|
|
|
hyprctl dispatch exec waybar
|
2023-12-03 13:36:10 +08:00
|
|
|
light -S $bright
|
2023-12-03 14:28:53 +08:00
|
|
|
elif test -n "$choice"; then
|
2023-12-07 11:31:31 +08:00
|
|
|
systemctl $choice
|
2023-12-03 13:36:10 +08:00
|
|
|
fi
|