Skip to content

Commit d24a040

Browse files
authored
Remove jq dependency. Remove shell script to call yabai. Remove lib.json module. Refactor stackline.query from an unnecessary object-oriented design to a functional design. Cleanup stackline.lib.utils (#75)
- Fixed: Icons don't change when toggling showIcons (#68) - Fixed: Failure to parse json output from `yabai` that contains `inf` values (might fix #46) - Removed external dependency on `jq` - Removed shell script used to call out to `yabai` - Replaced third-party json library with `hs.json` - Refactored unnecessary object-orientation out of `stackline.query` - Cleaned up `stackline.lib.utils`
1 parent 5ff03c8 commit d24a040

File tree

13 files changed

+753
-2791
lines changed

13 files changed

+753
-2791
lines changed

README.md

Lines changed: 46 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<!-- vim: set tw=0 :-->
22
![stackline-logo](https://user-images.githubusercontent.com/1683979/90966915-1f9b1400-e48d-11ea-8cbb-0ceea6fcfc39.png)
33
<p>
4-
<img alt="Version" src="https://img.shields.io/badge/version-0.1.60-blue.svg?cacheSeconds=2592000" />
4+
<img alt="Version" src="https://img.shields.io/badge/version-0.1.61-blue.svg?cacheSeconds=2592000" />
55
<a href="#" target="_blank">
66
<img alt="License: MIT" src="https://img.shields.io/badge/License-MIT-yellow.svg" />
77
</a>
@@ -11,42 +11,39 @@
1111
1212
**Latest update**
1313

14-
[📣 Update: improved configuration: please review docs for 💔️ breaking changes!](https://github.com/AdamWagner/stackline/issues/33)
14+
2021-06-06: Fixes & cleanup (`v0.1.61`)
1515

16-
See changes in more detail in the [changelog](https://github.com/AdamWagner/stackline/wiki/Changelog).
16+
- Fixed: Icons don't change when toggling showIcons (#68)
17+
- Fixed: Failure to parse json output from `yabai` that contains `inf` values (might fix #46)
18+
- Removed external dependency on `jq`
19+
- Removed shell script used to call out to `yabai`
20+
- Replaced third-party json library with `hs.json`
21+
- Refactored unnecessary object-orientation out of `stackline.query`
22+
- Cleaned up `stackline.lib.utils`
1723

18-
**Up next**
19-
20-
[🛠️ In progress: Refactoring for testability → Unit tests](https://github.com/AdamWagner/stackline/issues/26)
21-
22-
You can find all the info below and more in the [wiki](https://github.com/AdamWagner/stackline/wiki/Install-dependencies).
24+
See [changelog](https://github.com/AdamWagner/stackline/wiki/Changelog).
2325

26+
Everything below & more is in the [wiki](https://github.com/AdamWagner/stackline/wiki/Install-dependencies).
2427

2528
## What is stackline & why would I want to use it?
2629

27-
`stackline` adds simple, unobtrusive visual indicators to complement `yabai`'s window stacking functionality.
28-
29-
A 'stack' is a generalized subset of a tabbed UI that enables multiple macOS windows to occupy the same screen space and behave as a single unit. A stack lets a user…
30-
31-
- add & remove windows from a stack
32-
- navigate between stacked windows
33-
- _understand the contents of a stack at a glance_
30+
`stackline` adds unobtrusive visual indicators to complement `yabai`'s window stacking functionality.
3431

32+
A 'stack' enables multiple macOS windows to occupy the same screen space and behave as a single unit.
3533

36-
Stacks are a recent addition (June 2020) to the (_excellent!_) macOS tiling window manager [koekeishiya/yabai](https://github.com/koekeishiya/yabai). See [yabai #203](https://github.com/koekeishiya/yabai/issues/203) for more info about `yabai`'s stacking feature. Currently, `yabai` does not provide a visual indication of a stack's active window or the inactive windows below. This makes it easy to forget about the stacked windows that aren't visible.
37-
38-
Enter `stackline`: simple, unobtrusive visual indicators that complement `yabai` window stacks.
34+
Stacks are a recent addition (June 2020) to the (_excellent!_) macOS tiling window manager [koekeishiya/yabai](https://github.com/koekeishiya/yabai). See [yabai #203](https://github.com/koekeishiya/yabai/issues/203) for more info about `yabai`'s stacking feature. Currently, there's no built-in UI for stacks, which makes it easy to forget about stacked windows that aren't visible or get disoriented.
3935

36+
Enter `stackline`: unobtrusive visual indicators that complement `yabai` window stacks.
4037

4138
![stackline-demo](https://user-images.githubusercontent.com/1683979/90967233-08f6bc00-e491-11ea-9b0a-d75f248ce4b1.gif)
4239

4340
### Features
4441

45-
- 🚦 **See your stacks**. Window indicators show you which BSP leaves are stacks & how many windows each stack contains
46-
- 🔦 **App icons**. Toggle icons on to know exactly which apps are stacked where. Toggle icons off and get a slim minimalistic indicator that doesn't get in the way.
47-
- 🧘‍♂️️ **Smart positioning**. Whichever mode you prefer, indicators always stay out of the way on the outside edge of the window (nearest the screen edge). `stackline v0.1.55` has full support for multi-monitor setups, too.
48-
- 🧮 **Always in sync**. stackline keeps track of stacks as you move between spaces, resize windows, and add or remove stacks.
49-
- 🕹**Flexible control**. Control stackline via shell commands, or access the instance directly via Hammerspoon.
42+
- 🚦 **Window indicators** show the position and window count of stacks
43+
- 🔦 Use **app icons** to show apps inside stacks or slim indicators to save space
44+
- 🧘 **Smart positioning**. Indicators stay on the outside edge of the window nearest the screen edge
45+
- 🕹️ **Flexible control**. Control stackline via shell commands, or access the instance directly via hammerspoon.
46+
- 🖥**Multi-monitor support** introduced in `stackline v0.1.55`
5047

5148
<table>
5249
<tbody>
@@ -66,17 +63,16 @@ Enter `stackline`: simple, unobtrusive visual indicators that complement `yabai`
6663
</table>
6764

6865

69-
## Getting started with stackline
66+
## Quickstart
7067

7168
### Prerequisites
7269

7370
- https://github.com/koekeishiya/yabai ([install guide](https://github.com/koekeishiya/yabai/wiki/Installing-yabai-(latest-release)))
7471
- https://github.com/Hammerspoon/hammerspoon ([getting started guide](https://www.hammerspoon.org/go/))
75-
- https://github.com/stedolan/jq (`brew install jq`)
7672

7773
See [wiki](https://github.com/AdamWagner/stackline/wiki/Install-&-configure-dependencies#user-content-configure-yabai-stacks) for example keybindings to create and navigate between stacks.
7874

79-
### Installing stackline
75+
### Installation
8076

8177
1. [Clone the repo into ~/.hammerspoon/stackline](https://github.com/AdamWagner/stackline/wiki/Install-stackline#1-clone-the-repo-into-hammerspoonstackline)
8278
2. [Install the hammerspoon cli tool](https://github.com/AdamWagner/stackline/wiki/Install-stackline#2-install-the-hammerspoon-cli-tool)
@@ -89,18 +85,15 @@ git clone https://github.com/AdamWagner/stackline.git ~/.hammerspoon/stackline
8985

9086
# Make stackline run when hammerspoon launches
9187
cd ~/.hammerspoon
92-
echo 'stackline = require "stackline.stackline.stackline"' >> init.lua
88+
echo 'stackline = require "stackline"' >> init.lua
9389
echo 'stackline:init()' >> init.lua
9490
```
9591

9692
Now your `~/.hammerspoon` directory should look like this:
9793

98-
9994
```
10095
├── init.lua
10196
└── stackline
102-
├── bin
103-
│   └── yabai-get-stack-idx
10497
├── conf.lua
10598
├── stackline
10699
│   ├── configmanager.lua
@@ -116,9 +109,21 @@ Now your `~/.hammerspoon` directory should look like this:
116109

117110
#### 2. Install the hammerspoon cli tool
118111

112+
This is an optional step. It's required to send configuration commands to `stackline` from scripts, for example:
113+
114+
```sh
115+
# Toggle boolean values with the hs cli
116+
hs -c "stackline.config:toggle('appearance.showIcons')"
117+
```
119118
1. Ensure Hammerspoon is running
120119
2. Open the hammerspoon console via the menu bar
121120
3. Type `hs.ipc.cliInstall()` and hit return
121+
4. Confirm that `hs` is available by entering the following in your terminal (shell):
122+
123+
```sh
124+
❯ which hs
125+
/usr/local/bin/hs
126+
```
122127

123128
<table>
124129
<tbody>
@@ -137,27 +142,14 @@ Now your `~/.hammerspoon` directory should look like this:
137142
</tbody>
138143
</table>
139144

145+
### Usage
140146

141-
Finally, confirm that `hs` is now available by entering the following in your terminal (shell):
147+
- Launch `yabai` (or make sure it's running) (`brew services start yabai`)
148+
- Launch `hammerspoon` (or make sure it's running) (`open -a "Hammerspoon"`)
142149

143-
```sh
144-
❯ which hs
145-
/usr/local/bin/hs
146-
```
147-
148-
### RETRO? GO! FIDO? GO! GUIDANCE…
149-
150-
We're almost there!
151-
152-
```sh
153-
# Launch yabai (or make sure it's running)
154-
brew services start yabai
155-
156-
# Launch hammerspoon (or make sure it's running)
157-
open -a "Hammerspoon"
158-
```
150+
**Create a window stack**
159151

160-
Now, assuming you've been issuing these commands from a terminal and _also_ have a browser window open on the same space, make sure your terminal is positioned immediately to the _left_ of Safari and issue the following command (or use [keybindings](https://github.com/AdamWagner/stackline/wiki/Install-dependencies)) to create a stack:
152+
Now, assuming you've been issuing these commands from a terminal and _also_ have a browser window open on the same space, make sure your terminal is positioned immediately to the _left_ of your browser and issue the following command (or use [keybindings](https://github.com/AdamWagner/stackline/wiki/Install-dependencies)) to create a stack:
161153

162154
```sh
163155
yabai -m window --stack next
@@ -167,27 +159,20 @@ Did the terminal window expand to cover the area previously occupied by Safari?
167159

168160
<img width="50%" src="https://user-images.githubusercontent.com/1683979/90969027-53376780-e4a8-11ea-88c9-354f43b0a4ef.png" />
169161

170-
If the icons are a bit too heavy for you, you can toggle minimalist mode by turning the icons off:
162+
You can toggle minimalist mode by turning the icons off:
171163

172164
```sh
173165
hs -c 'stackline.config:toggle("appearance.showIcons")'
174166
```
175167

176-
177168
<img width="50%" src="https://user-images.githubusercontent.com/1683979/90969026-52063a80-e4a8-11ea-885d-9dd5b1409f20.png" />
178169

179-
The minimalist stack indicator style is shown here ↑
180-
181-
See the wiki to [for details about how to do this with a key binding!](https://github.com/AdamWagner/stackline/wiki/Keybindings).
170+
See the wiki to [for details about how to do this with a key binding](https://github.com/AdamWagner/stackline/wiki/Keybindings).
182171

183172

184-
## Help us get to v1.0.0!
185-
186-
Give a ⭐️ if you think (a more fully-featured version of) stackline would be useful!
187-
188173
## Thanks to contributors!
189174

190-
All are welcome (actually, _please_ help us, 🤣️)! Feel free to dive in by opening an [issue](https://github.com/AdamWagner/stackline/issues/new) or submitting a PR.
175+
All are welcome. Feel free to dive in by opening an [issue](https://github.com/AdamWagner/stackline/issues/new) or submitting a PR.
191176

192177
[@alin23](https://github.com/alin23) initially proposed the [concept for stackline here](https://github.com/koekeishiya/yabai/issues/203#issuecomment-652948362) and encouraged [@AdamWagner](https://github.com/AdamWagner) to share the mostly-broken proof-of-concept publicly. Since then, [@alin23](https://github.com/alin23) dramatically improved upon the initial proof-of-concept with [#13](https://github.com/AdamWagner/stackline/pull/13), has some pretty whiz-bang functionality on deck with [#17](https://github.com/AdamWagner/stackline/pull/17), and has been a great thought partner/reviewer.
193178

@@ -199,13 +184,15 @@ All are welcome (actually, _please_ help us, 🤣️)! Feel free to dive in by o
199184

200185
[@AdamWagner](https://github.com/AdamWagner) wrote the initial proof-of-concept (POC) for stackline.
201186

187+
Give a ⭐️ if you think (a more fully-featured version of) stackline would be useful!
188+
202189
### …on the shoulders of giants
203190

204191
Thanks to [@koekeishiya](gh-koekeishiya) without whom the _wonderful_ [yabai](https://github.com/koekeishiya/yabai) would not exist, and projects like this would have no reason to exist.
205192

206193
Similarly, thanks to [@dominiklohmann](https://github.com/dominiklohmann), who has helped _so many people_ make chunkwm/yabai "do the thing" they want and provides great feedback on new and proposed yabai features.
207194

208-
Thanks to [@cmsj](https://github.com/cmsj), [@asmagill](https://github.com/asmagill), and all of the contributors to [hammerspoon](https://github.com/Hammerspoon/hammerspoon) for making macOS APIs accessible to the rest of us!
195+
Thanks to [@cmsj](https://github.com/cmsj), [@asmagill](https://github.com/asmagill), and all of the contributors to [hammerspoon](https://github.com/Hammerspoon/hammerspoon) for making macos APIs accessible to the rest of us!
209196

210197
Thanks to the creators & maintainers of the lua utility libaries [underscore.lua](https://github.com/mirven/underscore.lua), [lume.lua](https://github.com/rxi/lume), and [self.lua](https://github.com/M1que4s/self).
211198

bin/yabai-get-stack-idx

Lines changed: 0 additions & 5 deletions
This file was deleted.

conf.lua

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@ c.features = {}
88
c.advanced = {}
99

1010
-- Paths
11-
c.paths.getStackIdxs = hs.configdir .. '/stackline/bin/yabai-get-stack-idx'
12-
c.paths.jq = '/usr/local/bin/jq'
1311
c.paths.yabai = '/usr/local/bin/yabai'
1412

1513
-- Appearance
@@ -43,6 +41,6 @@ c.features.fzyFrameDetect.fuzzFactor = 30 -- Window frame dime
4341
c.features.winTitles = 'not_implemented' -- Valid options: false, true, 'when_switching', 'not_implemented'
4442
c.features.dynamicLuminosity = 'not_implemented' -- Valid options: false, true, 'not_implemented'
4543

46-
c.advanced.maxRefreshRate = 0.3 -- How aggressively to refresh Stackline. Higher = slower response time + less battery drain
44+
c.advanced.maxRefreshRate = 0.5 -- How aggressively to refresh Stackline. Higher = slower response time + less battery drain
4745

4846
return c

init.lua

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
-- Simplify requiring stackline from ~/hammerspoon/init.lua
2+
3+
package.path = os.getenv'HOME' ..'/.hammerspoon/stackline/?.lua;' .. package.path
4+
return require 'stackline.stackline'

0 commit comments

Comments
 (0)