1
1
mirror of https://github.com/rywng/dotfiles.git synced 2024-10-30 23:51:51 +08:00
dotfiles/.config/hypr/scripts/logout.sh
2023-12-03 16:56:43 +08:00

44 lines
1.1 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" | 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 $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 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
fi