1
1
mirror of https://github.com/rywng/dotfiles.git synced 2024-10-30 23:51:51 +08:00
dotfiles/.config/sway/scripts/logout.sh

42 lines
1.0 KiB
Bash
Raw Normal View History

2024-01-06 11:35:43 +08:00
#!/bin/bash
2023-12-15 13:57:38 +08:00
#
# Modified from sway's locking script
if [[ ! $(which swayidle 2> /dev/null) ]]; then
notify-send "ERROR" "Swayidle not found"
exit 1
fi
choices=("suspend" "poweroff" "reboot" "lock")
2024-01-13 11:38:48 +08:00
choice=$(printf "%s\n" "${choices[@]}" | fuzzel -d --prompt "󰚥: ")
2023-12-15 13:57:38 +08:00
2022-06-25 21:26:38 +08:00
if test "$choice" = lock ; then
2023-12-15 13:57:38 +08:00
# sleep less when power on
2024-02-27 18:46:56 +08:00
if acpi -a | grep -q on; then
sleep_time=3600
else
sleep_time=10
fi
2023-12-15 13:57:38 +08:00
sleep 0.3
2023-10-10 21:24:00 +08:00
bright=`light`
2023-12-15 13:57:38 +08:00
2023-10-10 21:24:00 +08:00
swayidle -w \
timeout 5 "light -S 1" resume "light -S $bright" \
2023-12-15 13:57:38 +08:00
timeout $sleep_time 'swaymsg "output * power off"' resume 'swaymsg "output * power on"' \
2023-10-10 21:24:00 +08:00
&
idlepid=$!
2024-01-05 18:34:36 +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
2023-10-10 21:24:00 +08:00
kill $idlepid
swaymsg "output * power on"
light -S $bright
2023-12-15 13:57:38 +08:00
elif test -n "$choice"; then
systemctl $choice
2022-06-25 21:26:38 +08:00
fi