refactor(hammerspoon): improve URL handling setup, enabling host-specific setup

This commit is contained in:
2023-10-28 17:04:23 +01:00
parent 407e02895d
commit 047d11653b
4 changed files with 197 additions and 88 deletions

View File

@@ -1,8 +1,12 @@
local obj = {}
function obj.init()
local apptoggle = require('app_toggle')
--------------------------------------------------------------------------------
-- Global Hotkeys
--------------------------------------------------------------------------------
local apptoggle = require('app_toggle')
local function init_hotkeys()
apptoggle:bind({ 'cmd', 'alt', 'ctrl' }, 'A', { 'Activity Monitor' })
apptoggle:bind({ 'cmd', 'ctrl' }, '2', { 'ChatGPT' })
apptoggle:bind({ 'cmd', 'ctrl' }, '4', { 'FastGPT' })
@@ -24,4 +28,53 @@ function obj.init()
)
end
--------------------------------------------------------------------------------
-- URL Handling
--------------------------------------------------------------------------------
local uh = require('url_handler')
local function init_url_handler()
local chromeProfiles = {
default = uh.chromeProfile("Default"),
work = uh.chromeProfile("Profile 1"),
}
uh.default_handler = uh.browsers.safari
uh.url_patterns = {
{
{ "%://github.com/krystal/", "%://%.github.com/krystal/" },
uh.browsers.edge, nil, { "Slack" }
},
{
{ "%://meet.google.com/" },
chromeProfiles.work, nil, { "Slack", "Calendar" }
}
}
-- uh.url_redir_decoders = {
-- {
-- "MS Teams links",
-- function(_, _, params, fullUrl)
-- if params.url then
-- return params.url
-- else
-- return fullUrl
-- end
-- end,
-- nil, true, "Microsoft Teams"
-- },
-- }
uh:init()
end
--------------------------------------------------------------------------------
-- Initialization
--------------------------------------------------------------------------------
function obj.init()
init_hotkeys()
init_url_handler()
end
return obj