Switch from way-displays to kanshi

This commit is contained in:
2025-08-21 04:46:15 -07:00
parent 2ee4b47086
commit 59e6c14c1b
2 changed files with 15 additions and 6 deletions

View File

@ -1,18 +1,25 @@
#!/usr/bin/env zsh
let just_list=0
local operation="-d"
local operation="--on"
local jq_filter_neg="| not"
local ignored=()
while getopts 'ldi:' name; do
case "${name}" in
h)
echo 'enable-displays-for-sleep [-l] [-d] [-i]'
echo '-d disable instead of enable'
echo '-l print the list of display that would be changed'
echo '-i ignore display'
echo 'By default, enable displays.'
;;
l)
just_list=1
;;
d)
jq_filter_neg=""
operation="-s"
operation="--off"
;;
i)
ignored+="${OPTARG}"
@ -31,7 +38,9 @@ displays=(${displays:|ignored})
if ((just_list)); then
printf '%s\0' ${displays}
else
flags=()
for display in ${displays}; do
way-displays "${operation}" DISABLED "${display}"
flags+=(--output "${display}" "${operation}")
done
(( ${#flags} )) && wlr-randr ${flags}
fi

View File

@ -22,7 +22,7 @@ function run {
swaylock ${empty_flag} --color '#000000'
else
# get the list of currently disabled monitors so we don't touch them
local ignored=("${(0)$(way-displays-enable -l)}")
local ignored=("${(0)$(enable-displays-for-sleep -l)}")
local ignored_args=()
for name in ${ignored}; do
# quote so it can be safely passed to swayidle
@ -30,8 +30,8 @@ function run {
done
swayidle -w -C /dev/null \
timeout 15 "way-displays-enable -d ${ignored}" \
resume "way-displays-enable {$ignored}" &
timeout 15 "enable-displays-for-sleep -d ${ignored}" \
resume "enable-displays-for-sleep {$ignored}" &
local swayidle_pid="${!}"
swaylock ${empty_flag} ${img_flags}
kill "${swayidle_pid}"