Switch from way-displays to kanshi
This commit is contained in:
@ -1,18 +1,25 @@
|
|||||||
#!/usr/bin/env zsh
|
#!/usr/bin/env zsh
|
||||||
|
|
||||||
let just_list=0
|
let just_list=0
|
||||||
local operation="-d"
|
local operation="--on"
|
||||||
local jq_filter_neg="| not"
|
local jq_filter_neg="| not"
|
||||||
local ignored=()
|
local ignored=()
|
||||||
|
|
||||||
while getopts 'ldi:' name; do
|
while getopts 'ldi:' name; do
|
||||||
case "${name}" in
|
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)
|
l)
|
||||||
just_list=1
|
just_list=1
|
||||||
;;
|
;;
|
||||||
d)
|
d)
|
||||||
jq_filter_neg=""
|
jq_filter_neg=""
|
||||||
operation="-s"
|
operation="--off"
|
||||||
;;
|
;;
|
||||||
i)
|
i)
|
||||||
ignored+="${OPTARG}"
|
ignored+="${OPTARG}"
|
||||||
@ -31,7 +38,9 @@ displays=(${displays:|ignored})
|
|||||||
if ((just_list)); then
|
if ((just_list)); then
|
||||||
printf '%s\0' ${displays}
|
printf '%s\0' ${displays}
|
||||||
else
|
else
|
||||||
|
flags=()
|
||||||
for display in ${displays}; do
|
for display in ${displays}; do
|
||||||
way-displays "${operation}" DISABLED "${display}"
|
flags+=(--output "${display}" "${operation}")
|
||||||
done
|
done
|
||||||
|
(( ${#flags} )) && wlr-randr ${flags}
|
||||||
fi
|
fi
|
@ -22,7 +22,7 @@ function run {
|
|||||||
swaylock ${empty_flag} --color '#000000'
|
swaylock ${empty_flag} --color '#000000'
|
||||||
else
|
else
|
||||||
# get the list of currently disabled monitors so we don't touch them
|
# 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=()
|
local ignored_args=()
|
||||||
for name in ${ignored}; do
|
for name in ${ignored}; do
|
||||||
# quote so it can be safely passed to swayidle
|
# quote so it can be safely passed to swayidle
|
||||||
@ -30,8 +30,8 @@ function run {
|
|||||||
done
|
done
|
||||||
|
|
||||||
swayidle -w -C /dev/null \
|
swayidle -w -C /dev/null \
|
||||||
timeout 15 "way-displays-enable -d ${ignored}" \
|
timeout 15 "enable-displays-for-sleep -d ${ignored}" \
|
||||||
resume "way-displays-enable {$ignored}" &
|
resume "enable-displays-for-sleep {$ignored}" &
|
||||||
local swayidle_pid="${!}"
|
local swayidle_pid="${!}"
|
||||||
swaylock ${empty_flag} ${img_flags}
|
swaylock ${empty_flag} ${img_flags}
|
||||||
kill "${swayidle_pid}"
|
kill "${swayidle_pid}"
|
||||||
|
Reference in New Issue
Block a user