From ba65e597ecb4e7fd8391b6824ea2ab881db0ba4c Mon Sep 17 00:00:00 2001 From: Alexander Rosenberg Date: Fri, 28 Nov 2025 16:32:55 -0800 Subject: [PATCH] Work on desktop setup --- laptop-lid-daemon | 2 ++ set-initial-kanshi-state | 43 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 45 insertions(+) create mode 100755 set-initial-kanshi-state diff --git a/laptop-lid-daemon b/laptop-lid-daemon index 36d4af4..e56f539 100755 --- a/laptop-lid-daemon +++ b/laptop-lid-daemon @@ -1,5 +1,7 @@ #!/usr/bin/env zsh +"${HOME}/scripts/set-initial-kanshi-state" + acpi_listen | while read event; do let num_outputs="$(wlr-randr --json | jq 'length')" if ((num_outputs <= 1)); then diff --git a/set-initial-kanshi-state b/set-initial-kanshi-state new file mode 100755 index 0000000..b5dd2da --- /dev/null +++ b/set-initial-kanshi-state @@ -0,0 +1,43 @@ +#!/usr/bin/zsh + +let monitor_count="$(wlr-randr --json | jq 'length')" +(( monitor_count <= 1 )) && exit + +# Wait for the socket +if ! [[ -S /run/user/1000/fr.emersion.kanshi.wayland-1 ]]; then + printf 'Waiting for socket ' 1>&2 + let i=0 + while ! [[ -S /run/user/1000/fr.emersion.kanshi.wayland-1 ]]; do + if (( i >= 20 )); then + printf '\nFailed to connect to socket!\n' 1>&2 + exit 1 + fi + i+=1 + printf '.' 1>&2 + sleep 0.1 + done + printf '\n' 1>&2 +fi + +get_current_profile() { + kanshictl status | jq -er '.current_profile' +} + +let i=0 +while ! get_current_profile >/dev/null; do + if (( i >= 5 )); then + break + fi + sleep 0.1 +done + +local current_profile="$(get_current_profile)" +local current_state="$(