Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix query processing for yabai v4.0.0 #1

Merged
merged 2 commits into from
Sep 30, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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