Skip to content

Commit a1b45cd

Browse files
committed
Fix Headspace
Some time back, I started storing the space in hs.settings as a string instead of a table. This let me access the full range of keys stored in that table, where hs.settings doesn't let you store images. References: 6681eff
1 parent 7b937dc commit a1b45cd

File tree

1 file changed

+11
-12
lines changed

1 file changed

+11
-12
lines changed

init.lua

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -96,11 +96,12 @@ function m:start()
9696
m.watcher = hs.application.watcher.new(function(appName, event, hsapp)
9797
if event == hs.application.watcher.launched then
9898
local appConfig = m.config.applications[hsapp:bundleID()]
99+
local space = m.getSpace()
99100

100101
if not m.allowed(appConfig) then
101102
hs.alert(
102103
"🛑: " .. hsapp:name() .. "\n" ..
103-
"📂: " .. hs.settings.get("headspace").text,
104+
"📂: " .. space.text,
104105
moduleStyle
105106
)
106107
hsapp:kill()
@@ -450,18 +451,16 @@ m.allowed = function(appConfig)
450451
if appConfig.whitelisted then
451452
return true
452453
else
453-
local space = hs.settings.get("headspace")
454-
if space then
455-
if space.whitelist then
456-
return fn.some(space.whitelist, function(tag)
457-
return fn.contains(m.tagged[tag], appConfig.bundleID)
454+
local space = m.getSpace()
455+
if space.whitelist then
456+
return fn.some(space.whitelist, function(tag)
457+
return fn.contains(m.tagged[tag], appConfig.bundleID)
458+
end)
459+
else
460+
if space.blacklist then
461+
return fn.every(space.blacklist, function(tag)
462+
return not fn.contains(appConfig.tags, tag)
458463
end)
459-
else
460-
if space.blacklist then
461-
return fn.every(space.blacklist, function(tag)
462-
return not fn.contains(appConfig.tags, tag)
463-
end)
464-
end
465464
end
466465
end
467466
end

0 commit comments

Comments
 (0)