1
1
mirror of https://github.com/rywng/dotfiles.git synced 2024-11-22 02:41:50 +08:00

Update sleep script

This commit is contained in:
Ryan 2023-12-03 16:56:43 +08:00
parent df203dc51c
commit b7863e2f61

View File

@ -8,19 +8,35 @@ if [[ ! $(which swayidle 2> /dev/null) ]]; then
exit 1
fi
choice=`echo -e "suspend\nshutdown\npoweroff\nreboot\nlock" | wofi -d --prompt "󰚥 Choose power option" -Oalphabetical`
choice=$(echo -e "suspend\nshutdown\npoweroff\nreboot\nlock" | wofi -d --prompt "󰚥 Choose power option" -Oalphabetical)
if test "$choice" = lock ; then
# sleep less when power on
if acpi -a | grep -q on; then
sleep_time=3600
else
sleep_time=10
fi
sleep 0.3
bright=`light`
swayidle -w \
timeout 5 "light -S 1" resume "light -S $bright" \
timeout 10 'hyprctl dispatch dpms off' resume 'hyprctl dispatch dpms on' \
timeout $sleep_time 'hyprctl dispatch dpms off' resume 'hyprctl dispatch dpms on' \
&
idlepid=$!
# swaylock -e -c 282828 --inside-color 00000003
swaylock -S --effect-blur "5x5" --effect-vignette 0.5:0.5 --inside-color 00000003 \
-e --ring-color 00000005 --line-color 00000035
swaylock -S --effect-blur "12x12" --effect-greyscale --effect-vignette 0.5:0.5 --inside-color 00000000 \
-e --ring-color 00000000 --line-uses-inside --indicator --clock --text-color 689d6a
kill $idlepid
pkill waybar
hyprctl dispatch dpms on
hyprctl dispatch exec waybar
light -S $bright
elif test -n "$choice"; then
loginctl $choice