2021-08-30 21:36:04 +00:00
|
|
|
--- === Launcher ===
|
|
|
|
|
2021-12-28 05:31:30 +00:00
|
|
|
local obj = {}
|
2021-08-30 21:36:04 +00:00
|
|
|
obj.__index = obj
|
|
|
|
|
|
|
|
-- Metadata
|
2021-12-28 05:31:30 +00:00
|
|
|
obj.name = "Launcher"
|
|
|
|
obj.version = "0.1"
|
|
|
|
obj.license = "MIT - https://opensource.org/licenses/MIT"
|
2021-08-30 21:36:04 +00:00
|
|
|
|
|
|
|
function obj:init()
|
2021-12-28 05:31:30 +00:00
|
|
|
-- Begin launcher mode
|
|
|
|
self.launcher = hs.hotkey.modal.new("ctrl", "space")
|
2021-08-30 21:36:04 +00:00
|
|
|
|
2021-12-28 05:31:30 +00:00
|
|
|
-- Behaviors on enter
|
|
|
|
function self.launcher:entered()
|
|
|
|
-- hs.alert'Entered mode'
|
|
|
|
end
|
|
|
|
-- Behaviors on exit
|
|
|
|
function self.launcher:exited()
|
|
|
|
-- hs.alert'Exited mode'
|
|
|
|
end
|
2021-08-30 21:36:04 +00:00
|
|
|
|
2021-12-28 05:31:30 +00:00
|
|
|
-- Use escape to exit launcher mode
|
|
|
|
self.launcher:bind("", "escape", function()
|
|
|
|
self.launcher:exit()
|
|
|
|
end)
|
|
|
|
|
|
|
|
-- Launcher shortcuts
|
|
|
|
self.launcher:bind("", "space", function()
|
|
|
|
hs.hints.windowHints()
|
|
|
|
self.launcher:exit()
|
|
|
|
end)
|
|
|
|
self.launcher:bind("", "return", function()
|
|
|
|
self:switch("Alacritty.app")
|
|
|
|
end)
|
|
|
|
self.launcher:bind("", "C", function()
|
|
|
|
self:switch("Calendar.app")
|
|
|
|
end)
|
|
|
|
self.launcher:bind("", "D", function()
|
|
|
|
self:switch("Discord.app")
|
|
|
|
end)
|
|
|
|
self.launcher:bind("", "E", function()
|
|
|
|
self:switch("Mail.app")
|
|
|
|
end)
|
|
|
|
self.launcher:bind("", "F", function()
|
|
|
|
self:switch("Firefox.app")
|
|
|
|
end)
|
|
|
|
self.launcher:bind("", "G", function()
|
|
|
|
self:switch("Mimestream.app")
|
|
|
|
end)
|
|
|
|
self.launcher:bind("", "M", function()
|
|
|
|
self:switch("Messages.app")
|
|
|
|
end)
|
|
|
|
self.launcher:bind("", "O", function()
|
|
|
|
self:switch("Obsidian.app")
|
|
|
|
end)
|
|
|
|
self.launcher:bind("", "P", function()
|
|
|
|
self:switch("System Preferences.app")
|
|
|
|
end)
|
|
|
|
self.launcher:bind("", "R", function()
|
|
|
|
hs.reload()
|
|
|
|
end)
|
|
|
|
self.launcher:bind("", "S", function()
|
|
|
|
self:switch("Slack.app")
|
|
|
|
end)
|
|
|
|
self.launcher:bind("", "Z", function()
|
|
|
|
self:switch("zoom.us.app")
|
|
|
|
end)
|
2021-08-30 21:36:04 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
function obj:switch(app)
|
2021-12-28 05:31:30 +00:00
|
|
|
hs.application.launchOrFocus(app)
|
|
|
|
self.launcher:exit()
|
2021-08-30 21:36:04 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
return obj
|