Work on desktop setup some more

This commit is contained in:
2025-11-28 22:04:03 -08:00
parent 546ac9c306
commit 0cbff84080
2 changed files with 15 additions and 21 deletions

View File

@ -3,17 +3,5 @@
"${HOME}/scripts/set-initial-kanshi-state" "${HOME}/scripts/set-initial-kanshi-state"
acpi_listen | while read event; do acpi_listen | while read event; do
let num_outputs="$(wlr-randr --json | jq 'length')" "${HOME}/scripts/set-initial-kanshi-state"
if ((num_outputs <= 1)); then
kanshictl switch default
else
case "${event}" in
'button/lid LID open')
kanshictl switch docked-open
;;
'button/lid LID close')
kanshictl switch docked-closed
;;
esac
fi
done done

View File

@ -1,11 +1,8 @@
#!/usr/bin/zsh #!/usr/bin/zsh
let monitor_count="$(wlr-randr --json | jq 'length')"
(( monitor_count <= 1 )) && exit
# Wait for the socket # Wait for the socket
if ! [[ -S /run/user/1000/fr.emersion.kanshi.wayland-1 ]]; then if ! [[ -S /run/user/1000/fr.emersion.kanshi.wayland-1 ]]; then
printf 'Waiting for socket ' 1>&2 printf 'Waiting for socket .' 1>&2
let i=0 let i=0
while ! [[ -S /run/user/1000/fr.emersion.kanshi.wayland-1 ]]; do while ! [[ -S /run/user/1000/fr.emersion.kanshi.wayland-1 ]]; do
if (( i >= 20 )); then if (( i >= 20 )); then
@ -13,25 +10,34 @@ if ! [[ -S /run/user/1000/fr.emersion.kanshi.wayland-1 ]]; then
exit 1 exit 1
fi fi
i+=1 i+=1
printf '.' 1>&2
sleep 0.1 sleep 0.1
printf '.' 1>&2
done done
printf '\n' 1>&2 printf '\n' 1>&2
fi fi
get_current_profile() { get_current_profile() {
kanshictl status | jq -er '.current_profile' local profile
profile="$(kanshictl status | jq -er '.current_profile')"
(( $? )) && return 1
: ${(P)1::="${profile}"}
} }
local current_profile
let i=0 let i=0
while ! get_current_profile >/dev/null; do while ! get_current_profile current_profile >/dev/null; do
if (( i >= 5 )); then if (( i >= 5 )); then
break break
fi fi
sleep 0.1 sleep 0.1
done done
local current_profile="$(get_current_profile)" local monitor_count_str="$(wlr-randr --json | jq 'length')"
[[ "${monitor_count_str}" =~ '[0-9]+' ]] || exit
let monitor_count="${monitor_count_str}"
(( monitor_count <= 1 )) && [[ "${current_profile}" != 'default' ]] \
&& kanshictl switch default
local current_state="$(</proc/acpi/button/lid/LID0/state)" local current_state="$(</proc/acpi/button/lid/LID0/state)"
if [[ "${current_profile}" = *open* ]] && if [[ "${current_profile}" = *open* ]] &&