bugfix: HDMI monitor not enabled using wlopm on sway

This commit is contained in:
cho 2024-01-31 19:06:43 +07:00
parent 914a103b10
commit cd7428e975
2 changed files with 15 additions and 4 deletions

View File

@ -1,8 +1,15 @@
#!/bin/zsh
if [[ -z "$1" ]]; then
if [[ -z "$1" ]] && [[ "$WINDOW_MANAGER" == "river" ]] ; then
swayidle -w \
timeout 310 'swaylock' \
timeout 360 "wlopm --off '*'" resume "wlopm --on '*'" \
timeout 300 'wlopm --off "*"' resume 'wlopm --on "*"' \
before-sleep "swaylock"
fi
if [[ -z "$1" ]] && [[ "$WINDOW_MANAGER" == "sway" ]] ; then
swayidle -w \
timeout 310 'swaylock' \
timeout 300 'swaymsg "output * dpms off"' resume 'swaymsg "output * dpms on"' \
before-sleep "swaylock"
fi

View File

@ -13,7 +13,8 @@ esac
case "$(printf "🔒 lock\n🚪 leave $WM\n♻ renew $WM\n🐻 hibernate\n🔃 reboot\n🖥 shutdown\n💤 sleep\n📺 display off\n set background\n start idle\n kill swayidle\n fcitx5\n kill fcitx5\n start emacs daemon\n kill emacs daemon\n restart emacs daemon\ntoggle sworkstyle" | wofi -L 17 --cache-file=/dev/null --show=dmenu -i -p 'action')" in
'🔒 lock')
setsid -f swaylock
setsid -f sleep 2 && swayidle -w timeout 1 'wlopm --off "*"' resume 'wlopm --on "*" && kill $#'
if [ "$WINDOW_MANAGER" == "river" ]; then setsid -f sleep 2 && swayidle -w timeout 1 'wlopm --off "*"' resume 'wlopm --on "*" && kill $#' ; fi
if [ "$WINDOW_MANAGER" == "sway" ]; then setsid -f sleep 2 && swayidle -w timeout 1 'swaymsg "output * dpms off"' resume 'swaymsg "output * dpms on" && kill $#' ; fi
;;
"🚪 leave $WM")
if [ "$WINDOW_MANAGER" == "sway" ]; then swaymsg exit ; fi
@ -28,7 +29,10 @@ case "$(printf "🔒 lock\n🚪 leave $WM\n♻ renew $WM\n🐻 hibernate\n
'🔃 reboot') $ctl reboot -i ;;
'🖥️ shutdown') $ctl poweroff -i ;;
#'📺 display off') swayidle -w timeout 1 'swaymsg "output * dpms off"' resume 'swaymsg "output * dpms on" && kill $#' ;;
'📺 display off') swayidle -w timeout 1 'wlopm --off "*"' resume 'wlopm --on "*" && kill $#' ;;
'📺 display off')
if [ "$WINDOW_MANAGER" == "river" ]; then setsid -f sleep 2 && swayidle -w timeout 1 'wlopm --off "*"' resume 'wlopm --on "*" && kill $#' ; fi
if [ "$WINDOW_MANAGER" == "sway" ]; then setsid -f sleep 2 && swayidle -w timeout 1 'swaymsg "output * dpms off"' resume 'swaymsg "output * dpms on" && kill $#' ; fi
;;
' set background') change-background ;;
' start idle') killall swayidle && sleep 1; setsid -f idle && notify-send 'idle started.';;
' kill swayidle') killall swayidle && notify-send 'idle killed.';;