mirror of
https://github.com/rywng/dotfiles.git
synced 2024-11-22 10:51:49 +08:00
format script code
This commit is contained in:
parent
0618d4cd1d
commit
947364f20f
@ -1,41 +1,41 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
#
|
#
|
||||||
# Modified from sway's locking script
|
# Modified from sway's locking script
|
||||||
|
# TODO: remove bashism
|
||||||
|
|
||||||
|
if [[ ! $(which swayidle 2>/dev/null) ]]; then
|
||||||
if [[ ! $(which swayidle 2> /dev/null) ]]; then
|
notify-send "ERROR" "Swayidle not found"
|
||||||
notify-send "ERROR" "Swayidle not found"
|
exit 1
|
||||||
exit 1
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
choices=("suspend" "poweroff" "reboot" "lock")
|
choices=("suspend" "poweroff" "reboot" "lock")
|
||||||
choice=$(printf "%s\n" "${choices[@]}" | fuzzel -d --prompt "🔌: ")
|
choice=$(printf "%s\n" "${choices[@]}" | fuzzel -d --prompt "🔌: ")
|
||||||
|
|
||||||
|
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
|
||||||
|
playerctl stop
|
||||||
|
|
||||||
if test "$choice" = lock ; then
|
bright=$(light)
|
||||||
# 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 'swaymsg "output * power off"' resume 'swaymsg "output * power on"' \
|
||||||
|
&
|
||||||
|
idlepid=$!
|
||||||
|
|
||||||
swayidle -w \
|
# swaylock -e -c 282828 --inside-color 00000003
|
||||||
timeout 5 "light -S 1" resume "light -S $bright" \
|
swaylock -S --effect-blur "12x12" --effect-greyscale --effect-vignette 0.5:0.5 --inside-color 28282860 \
|
||||||
timeout $sleep_time 'swaymsg "output * power off"' resume 'swaymsg "output * power on"' \
|
-e --ring-color 00000000 --line-color 00000000 --indicator --clock --text-color ebdbb2
|
||||||
&
|
|
||||||
idlepid=$!
|
|
||||||
|
|
||||||
# swaylock -e -c 282828 --inside-color 00000003
|
kill $idlepid
|
||||||
swaylock -S --effect-blur "12x12" --effect-greyscale --effect-vignette 0.5:0.5 --inside-color 28282860 \
|
swaymsg "output * power on"
|
||||||
-e --ring-color 00000000 --line-color 00000000 --indicator --clock --text-color ebdbb2
|
light -S $bright
|
||||||
|
|
||||||
kill $idlepid
|
|
||||||
swaymsg "output * power on"
|
|
||||||
light -S $bright
|
|
||||||
elif test -n "$choice"; then
|
elif test -n "$choice"; then
|
||||||
systemctl $choice
|
systemctl $choice
|
||||||
fi
|
fi
|
||||||
|
Loading…
Reference in New Issue
Block a user