Skip to content

Commit

Permalink
Fix query processing for yabai v4.0.0 (#1)
Browse files Browse the repository at this point in the history
* fix query processing for yabai v4.0.0

* add yabai compatibility to readme
  • Loading branch information
kcmyang authored Sep 30, 2022
1 parent bb46bf1 commit ecb062b
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 7 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
## v0.2.0 - 30 Sep 2022

### Changes

- Fix processing of yabai query result to accomodate new data format
(see https://github.com/koekeishiya/yabai/issues/775)

## v0.1.2 - 13 Jan 2022

### Changes
Expand Down
7 changes: 5 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,11 @@ A simple menu bar spaces indicator for the yabai window manager, written for Ham
## Installation

Compatibility:
- Tested on Big Sur (macOS 11).
- Not tested on Monterery (macOS 12).
- yabai
- Tested on v4.0.0^.
- Untested on v5.0.0^.
- macOS
- Tested on Monterery (macOS 12).

Prerequisites:
- Install and configure [yabai](https://github.com/koekeishiya/yabai).
Expand Down
12 changes: 7 additions & 5 deletions yabai-bar.lua
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ end

local YabaiBar = {}

-- Constructor
-- Constructor.
-- Params:
-- exec - the absolute path of the yabai executable to use
function YabaiBar:new(exec)
local yabaiBar = {
bar = hs.menubar.new(),
Expand Down Expand Up @@ -43,9 +45,9 @@ function YabaiBar:new(exec)
return setmetatable(yabaiBar, self)
end

-- Update
-- Updates the bar by querying yabai.
function YabaiBar:update()
hs.task.new(self.exec, function(exitCode, stdOut, stdErr)
hs.task.new(self.exec, function(exitCode, stdOut, _)
if exitCode ~= 0 then return end

local spaces = hs.json.decode(stdOut)
Expand All @@ -56,10 +58,10 @@ function YabaiBar:update()
local nums = {}

for i = 1, #spaces do
if spaces[i].focused == 1 then
if spaces[i]["has-focus"] then
-- Focused
nums[i] = hs.styledtext.new(i, self.focusedStyle)
elseif spaces[i].visible == 1 then
elseif spaces[i]["is-visible"] then
-- Not focused, but visible
nums[i] = hs.styledtext.new(i, self.visibleStyle)
elseif spaces[i]["first-window"] ~= 0 then
Expand Down

0 comments on commit ecb062b

Please sign in to comment.