sway: update sway_exit script with icons, adapt sway_suspend, update config accordingly
This commit is contained in:
parent
0271bfb5d9
commit
ac387d4c1b
3 changed files with 28 additions and 9 deletions
|
@ -1,4 +1,20 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
export PATH=$PATH:$HOME/.config/sway/bin
|
export PATH=$PATH:$HOME/.config/sway/bin
|
||||||
bash -c "$(echo -e 'sway_lock lock\nsystemctl suspend\nswaymsg reload\nswaymsg exit' | \
|
IMG_BASE=$HOME/.local/share/icons/Tela-circle-dark
|
||||||
wofi --dmenu --prompt 'exit menu')"
|
IMG_LOCK=$IMG_BASE/scalable/apps/system-log-out.svg
|
||||||
|
CMD_LOCK="sway_lock lock"
|
||||||
|
IMG_SUSPEND=$IMG_BASE/scalable/apps/system-suspend.svg
|
||||||
|
CMD_SUSPEND="sway_suspend suspend"
|
||||||
|
IMG_RELOAD=$IMG_BASE/scalable/apps/system-software-update.svg
|
||||||
|
CMD_RELOAD="swaymsg reload"
|
||||||
|
IMG_EXIT=$IMG_BASE/scalable/apps/system-restart.svg
|
||||||
|
CMD_EXIT="swaymsg exit"
|
||||||
|
|
||||||
|
echo -e "img:$IMG_LOCK:text:$CMD_LOCK
|
||||||
|
img:$IMG_SUSPEND:text:$CMD_SUSPEND
|
||||||
|
img:$IMG_RELOAD:text:$CMD_RELOAD
|
||||||
|
img:$IMG_EXIT:text:$CMD_EXIT" | \
|
||||||
|
wofi --dmenu --prompt "exit menu" | while read line; do
|
||||||
|
bash -c "$line"
|
||||||
|
done
|
||||||
|
|
||||||
|
|
|
@ -3,13 +3,15 @@ source $HOME/.config/sway/bin/sway_helpers
|
||||||
BAT_PATH=/sys/class/power_supply
|
BAT_PATH=/sys/class/power_supply
|
||||||
BAT=BAT0
|
BAT=BAT0
|
||||||
MODE=suspend-then-hibernate
|
MODE=suspend-then-hibernate
|
||||||
|
MEDIA_APP=playerctl
|
||||||
INHIBIT_FILE=$HOME/.inhibit_suspend
|
INHIBIT_FILE=$HOME/.inhibit_suspend
|
||||||
|
|
||||||
## helpers
|
## helpers
|
||||||
# 0: charging
|
# 1: discharging
|
||||||
# 1: discharging/unknown
|
# 0: charging/full
|
||||||
function _state() {
|
function _state() {
|
||||||
f=$BAT_PATH/$BAT/status
|
f=$BAT_PATH/$BAT/status
|
||||||
|
# default to discharging when status file not found
|
||||||
s=1
|
s=1
|
||||||
if [ -e $f ]; then
|
if [ -e $f ]; then
|
||||||
s=$(grep -c Discharging $f)
|
s=$(grep -c Discharging $f)
|
||||||
|
@ -22,6 +24,7 @@ function _suspend() {
|
||||||
state=$(_state)
|
state=$(_state)
|
||||||
force=${1:-0}
|
force=${1:-0}
|
||||||
if [ $state -eq 1 -o $force -eq 1 ]; then
|
if [ $state -eq 1 -o $force -eq 1 ]; then
|
||||||
|
$MEDIA_APP stop
|
||||||
systemctl $MODE
|
systemctl $MODE
|
||||||
else
|
else
|
||||||
_log SUSPEND INFO aborting. state: $state, force: $force
|
_log SUSPEND INFO aborting. state: $state, force: $force
|
||||||
|
@ -35,14 +38,14 @@ case $1 in
|
||||||
i*)
|
i*)
|
||||||
_set_inhibit $INHIBIT_FILE $2
|
_set_inhibit $INHIBIT_FILE $2
|
||||||
;;
|
;;
|
||||||
suspend)
|
suspend-battery)
|
||||||
_suspend 0
|
_suspend 0
|
||||||
;;
|
;;
|
||||||
force)
|
suspend)
|
||||||
_suspend 1
|
_suspend 1
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
echo "invalid argument: \"$1\""
|
echo "invalid argument: \"$1\""
|
||||||
echo "arguments: [inhibit [on|off]|suspend|force]"
|
echo "arguments: [inhibit [on|off]|suspend-battery|suspend]"
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
4
config
4
config
|
@ -70,8 +70,8 @@ exec swayidle -w \
|
||||||
timeout 1800 '$lock_cmd off' \
|
timeout 1800 '$lock_cmd off' \
|
||||||
resume '$lock_cmd on' \
|
resume '$lock_cmd on' \
|
||||||
timeout 2700 '$lock_cmd lockonly' \
|
timeout 2700 '$lock_cmd lockonly' \
|
||||||
timeout 3600 '$suspend_cmd suspend' \
|
timeout 3600 '$suspend_cmd suspend-battery' \
|
||||||
timeout 7200 '$suspend_cmd force' \
|
timeout 7200 '$suspend_cmd suspend' \
|
||||||
before-sleep '$lock_cmd lock'
|
before-sleep '$lock_cmd lock'
|
||||||
bindsym $mod+Ctrl+Escape exec '$lock_cmd lock'
|
bindsym $mod+Ctrl+Escape exec '$lock_cmd lock'
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue