mirror of
https://github.com/nmasur/dotfiles
synced 2024-11-10 00:32:55 +00:00
draw switcher indicator on screen
This commit is contained in:
parent
244c431c75
commit
ba3aa9cd93
@ -8,70 +8,87 @@ obj.name = "Launcher"
|
|||||||
obj.version = "0.1"
|
obj.version = "0.1"
|
||||||
obj.license = "MIT - https://opensource.org/licenses/MIT"
|
obj.license = "MIT - https://opensource.org/licenses/MIT"
|
||||||
|
|
||||||
|
function drawSwitcher()
|
||||||
|
-- Drawing
|
||||||
|
canv = hs.canvas.new({ x = 850, y = 1, h = 3, w = 120 })
|
||||||
|
canv[#canv + 1] = {
|
||||||
|
action = "build",
|
||||||
|
type = "rectangle",
|
||||||
|
}
|
||||||
|
canv[#canv + 1] = {
|
||||||
|
type = "rectangle",
|
||||||
|
fillColor = { alpha = 1, red = 0.8, green = 0.6, blue = 0.3 },
|
||||||
|
action = "fill",
|
||||||
|
}
|
||||||
|
return canv:show()
|
||||||
|
end
|
||||||
|
|
||||||
function obj:init()
|
function obj:init()
|
||||||
-- Begin launcher mode
|
-- Begin launcher mode
|
||||||
self.launcher = hs.hotkey.modal.new("ctrl", "space")
|
self.launcher = hs.hotkey.modal.new("ctrl", "space")
|
||||||
|
|
||||||
-- Behaviors on enter
|
-- Behaviors on enter
|
||||||
function self.launcher:entered()
|
function self.launcher:entered()
|
||||||
-- hs.alert'Entered mode'
|
-- hs.alert("Entered mode")
|
||||||
end
|
self.canv = drawSwitcher()
|
||||||
-- Behaviors on exit
|
end
|
||||||
function self.launcher:exited()
|
-- Behaviors on exit
|
||||||
-- hs.alert'Exited mode'
|
function self.launcher:exited()
|
||||||
end
|
-- hs.alert("Exited mode")
|
||||||
|
self.canv:hide()
|
||||||
|
end
|
||||||
|
|
||||||
-- Use escape to exit launcher mode
|
-- Use escape to exit launcher mode
|
||||||
self.launcher:bind("", "escape", function()
|
self.launcher:bind("", "escape", function()
|
||||||
self.launcher:exit()
|
self.launcher:exit()
|
||||||
end)
|
end)
|
||||||
|
|
||||||
-- Launcher shortcuts
|
-- Launcher shortcuts
|
||||||
self.launcher:bind("", "space", function()
|
self.launcher:bind("", "space", function()
|
||||||
hs.hints.windowHints()
|
hs.hints.windowHints()
|
||||||
self.launcher:exit()
|
self.launcher:exit()
|
||||||
end)
|
end)
|
||||||
self.launcher:bind("", "return", function()
|
self.launcher:bind("", "return", function()
|
||||||
self:switch("Alacritty.app")
|
self:switch("Alacritty.app")
|
||||||
end)
|
end)
|
||||||
self.launcher:bind("", "C", function()
|
self.launcher:bind("", "C", function()
|
||||||
self:switch("Calendar.app")
|
self:switch("Calendar.app")
|
||||||
end)
|
end)
|
||||||
self.launcher:bind("", "D", function()
|
self.launcher:bind("", "D", function()
|
||||||
self:switch("Discord.app")
|
self:switch("Discord.app")
|
||||||
end)
|
end)
|
||||||
self.launcher:bind("", "E", function()
|
self.launcher:bind("", "E", function()
|
||||||
self:switch("Mail.app")
|
self:switch("Mail.app")
|
||||||
end)
|
end)
|
||||||
self.launcher:bind("", "F", function()
|
self.launcher:bind("", "F", function()
|
||||||
self:switch("Firefox.app")
|
self:switch("Firefox.app")
|
||||||
end)
|
end)
|
||||||
self.launcher:bind("", "G", function()
|
self.launcher:bind("", "G", function()
|
||||||
self:switch("Mimestream.app")
|
self:switch("Mimestream.app")
|
||||||
end)
|
end)
|
||||||
self.launcher:bind("", "M", function()
|
self.launcher:bind("", "M", function()
|
||||||
self:switch("Messages.app")
|
self:switch("Messages.app")
|
||||||
end)
|
end)
|
||||||
self.launcher:bind("", "O", function()
|
self.launcher:bind("", "O", function()
|
||||||
self:switch("Obsidian.app")
|
self:switch("Obsidian.app")
|
||||||
end)
|
end)
|
||||||
self.launcher:bind("", "P", function()
|
self.launcher:bind("", "P", function()
|
||||||
self:switch("System Preferences.app")
|
self:switch("System Preferences.app")
|
||||||
end)
|
end)
|
||||||
self.launcher:bind("", "R", function()
|
self.launcher:bind("", "R", function()
|
||||||
hs.reload()
|
hs.reload()
|
||||||
end)
|
end)
|
||||||
self.launcher:bind("", "S", function()
|
self.launcher:bind("", "S", function()
|
||||||
self:switch("Slack.app")
|
self:switch("Slack.app")
|
||||||
end)
|
end)
|
||||||
self.launcher:bind("", "Z", function()
|
self.launcher:bind("", "Z", function()
|
||||||
self:switch("zoom.us.app")
|
self:switch("zoom.us.app")
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
|
|
||||||
function obj:switch(app)
|
function obj:switch(app)
|
||||||
hs.application.launchOrFocus(app)
|
hs.application.launchOrFocus(app)
|
||||||
self.launcher:exit()
|
self.launcher:exit()
|
||||||
end
|
end
|
||||||
|
|
||||||
return obj
|
return obj
|
||||||
|
Loading…
Reference in New Issue
Block a user