1
1
mirror of https://github.com/rywng/dotfiles.git synced 2024-11-15 15:31:50 +08:00
dotfiles/.config/hypr/scripts/logout.sh
2024-01-13 12:10:07 +08:00

44 lines
1.0 KiB
Bash
Executable File

#!/bin/sh
#
# Modified from sway's locking script
if [[ ! $(which swayidle 2> /dev/null) ]]; then
notify-send "ERROR" "Swayidle not found"
exit 1
fi
choice=$(echo -e "suspend\nshutdown\npoweroff\nreboot\nlock" | fuzzel -d --prompt "󰚥: ")
if test "$choice" = lock ; then
# don't sleep when power on
if acpi -a | grep -q on; then
sleep_time=86400
else
sleep_time=10
fi
sleep 0.3
bright=`light`
swayidle -w \
timeout 5 "light -S 1" resume "light -S $bright" \
timeout $sleep_time 'hyprctl dispatch dpms off' resume 'hyprctl dispatch dpms on' \
&
idlepid=$!
# 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
kill $idlepid
pkill waybar
hyprctl dispatch dpms on
hyprctl dispatch exec waybar
light -S $bright
elif test -n "$choice"; then
systemctl $choice
fi