diff --git a/README.md b/README.md index 0b93b8d..20333bf 100644 --- a/README.md +++ b/README.md @@ -15,9 +15,6 @@ Currently, [stackline](https://github.com/AdamWagner/stackline) is a proof-of-co There is much crucial fuctionality that is either missing or broken. For example, stack indicators do not refresh when: 1. the tree is rotated or mirrored -2. updating padding or gap values -3. a stacked window is warped out of the stack -4. app icons are toggled on/off ## What is stackline & why do I need it? @@ -69,17 +66,21 @@ cmd + ctrl - right : yabai -m window east --stack $(yabai -m query --windows --w ### Installing stackline 1. Clone the repo into ~/.hammerspoon/stackline -2. Install the hammerspoon cli tool +2. Add stackline to your Hammerspoon init.lua file 3. Add signals to ~/.yabairc #### 1. Clone the repo into ~/.hammerspoon/stackline ```sh -# Get the repo git clone https://github.com/AdamWagner/stackline.git ~/.hammerspoon/stackline +``` + +#### 2. Add stackline to your Hammerspoon init.lua file -# Make stackline run when hammerspoon launches +```sh cd ~/.hammerspoon +echo 'require("hs.ipc")' >> init.lua +echo 'hs.ipc.cliInstall()' >> init.lua echo 'require "stackline.stackline.core"' >> init.lua ``` @@ -90,6 +91,7 @@ Now your `~/.hammerspoon` directory should look like this: ├── stackline │ ├── bin │ │ └── yabai-get-stacks +│ │ └── yabai-add-signals │ ├── stackline │ │ ├── core.lua │ │ ├── stack.lua @@ -103,48 +105,10 @@ Now your `~/.hammerspoon` directory should look like this: ``` -#### 2. Install the hammerspoon cli tool - -Open the hammerspoon console via the menu bar, type `hs.ipc.cliInstall()`, and hit return. - -Confirm that `hs` is now available: - -```sh -❯ which hs -/usr/local/bin/hs -``` - #### 3. Add signals to ~/.yabairc -Add signals to `~/.yabairc`: - ```sh -STACKLINE_EVENTS="\ - application_activated \ - application_front_switched \ - application_hidden \ - application_launched \ - application_terminated \ - application_visible \ - window_created \ - window_deminimized \ - window_focused \ - window_minimized \ - window_resized" - -yabai -m signal --add \ - event="window_destroyed" \ - label="stackline_window_destroyed" \ - action="echo ':window_destroyed' | /usr/local/bin/hs -m stackline-events" - -for event in $STACKLINE_EVENTS -do - yabai -m signal --add \ - event="$event" \ - label="stackline_$event" \ - app!="Hammerspoon" \ - action="echo ':$event' | /usr/local/bin/hs -m stackline-events" -done +echo '$HOME/.hammerspoon/stackline/yabai-add-signals' >> ~/.yabairc ``` ### RETRO? GO! FIDO? GO! GUIDANCE… diff --git a/bin/yabai-add-signals b/bin/yabai-add-signals new file mode 100755 index 0000000..f8c3a85 --- /dev/null +++ b/bin/yabai-add-signals @@ -0,0 +1,32 @@ +#!/bin/dash + +STACKLINE_EVENTS="\ + application_activated \ + application_front_switched \ + application_hidden \ + application_launched \ + application_terminated \ + application_visible \ + window_created \ + window_deminimized \ + window_focused \ + window_minimized \ + window_resized" + +yabai -m signal --add \ + event="window_destroyed" \ + label="stackline_window_destroyed" \ + action="echo ':window_destroyed' | /usr/local/bin/hs -m stackline-events" +yabai -m signal --add \ + event="space_changed" \ + label="stackline_space_changed" \ + action="echo ':space_changed' | /usr/local/bin/hs -m stackline-events" + +for event in $STACKLINE_EVENTS +do + yabai -m signal --add \ + event="$event" \ + label="stackline_$event" \ + app!="Hammerspoon" \ + action="echo ':$event' | /usr/local/bin/hs -m stackline-events" +done \ No newline at end of file diff --git a/stackline/core.lua b/stackline/core.lua index 8afe86f..8d3ccd3 100644 --- a/stackline/core.lua +++ b/stackline/core.lua @@ -20,6 +20,7 @@ wsi = Stack:newStackManager(showIcons) local shouldRestack = tut.Set{ "application_terminated", "application_launched", + "space_changed", "window_created", "window_destroyed", "window_resized", @@ -64,6 +65,8 @@ function yabaiSignalHandler(_, msgID, msg) event = msg:match(".+:([%a_]+)") if shouldRestack[event] then + print(string.format("Recreating the stack because of yabai event: %s", event)) + wsi.cleanup() wsi = Stack:newStackManager(showIcons) end