mirror of
https://github.com/jimeh/dotfiles.git
synced 2026-02-19 13:46:41 +00:00
Extract host specific hammerspoon config to separate files
This commit is contained in:
@@ -2,16 +2,13 @@ local obj = {
|
|||||||
hostname = nil
|
hostname = nil
|
||||||
}
|
}
|
||||||
|
|
||||||
function obj:init()
|
function obj.getHostname()
|
||||||
self.hostname = self.getHostname()
|
local f = io.popen ("hostname -s")
|
||||||
end
|
|
||||||
|
|
||||||
function obj:getHostname()
|
|
||||||
local f = io.popen ("hostname")
|
|
||||||
local hostname = f:read("*a") or ""
|
local hostname = f:read("*a") or ""
|
||||||
f:close()
|
f:close()
|
||||||
hostname = string.gsub(hostname, "\n$", "")
|
hostname = string.gsub(hostname, "\n$", "")
|
||||||
return hostname
|
return hostname
|
||||||
end
|
end
|
||||||
|
|
||||||
|
obj.hostname = obj.getHostname()
|
||||||
return obj
|
return obj
|
||||||
|
|||||||
20
hammerspoon/host_config.lua
Normal file
20
hammerspoon/host_config.lua
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
local obj = {}
|
||||||
|
|
||||||
|
function obj:init()
|
||||||
|
local env = require('env')
|
||||||
|
local conf_file = "hosts/" .. env.hostname .. ".lua"
|
||||||
|
local conf_req = "hosts." .. env.hostname
|
||||||
|
|
||||||
|
if self.file_exists(conf_file) then
|
||||||
|
print("loading host config: " .. conf_file)
|
||||||
|
local conf_module = require(conf_req)
|
||||||
|
conf_module:init()
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function obj.file_exists(name)
|
||||||
|
local f=io.open(name,"r")
|
||||||
|
if f~=nil then io.close(f) return true else return false end
|
||||||
|
end
|
||||||
|
|
||||||
|
return obj
|
||||||
17
hammerspoon/hosts/UAC00024.lua
Normal file
17
hammerspoon/hosts/UAC00024.lua
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
local obj = {}
|
||||||
|
|
||||||
|
function obj.init()
|
||||||
|
local apptoggle = require('app_toggle')
|
||||||
|
|
||||||
|
apptoggle:bind({'alt', 'ctrl'}, 'A', 'Activity Monitor')
|
||||||
|
apptoggle:bind({'cmd', 'ctrl'}, 'B', 'Sequel Pro')
|
||||||
|
apptoggle:bind({'cmd', 'ctrl'}, 'C', 'Paw')
|
||||||
|
apptoggle:bind({'cmd', 'ctrl'}, 'D', 'Mail')
|
||||||
|
apptoggle:bind({'cmd', 'ctrl'}, 'E', 'Emacs', '/Applications/Emacs.app')
|
||||||
|
apptoggle:bind({'cmd', 'ctrl'}, 'G', 'Slack')
|
||||||
|
apptoggle:bind({'cmd', 'ctrl'}, 'S', 'Skype for Business')
|
||||||
|
apptoggle:bind({'cmd', 'ctrl'}, 'X', 'Calendar')
|
||||||
|
apptoggle:bind({'cmd', 'ctrl'}, 'Z', 'Stride')
|
||||||
|
end
|
||||||
|
|
||||||
|
return obj
|
||||||
22
hammerspoon/hosts/noct.lua
Normal file
22
hammerspoon/hosts/noct.lua
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
local obj = {}
|
||||||
|
|
||||||
|
function obj.init()
|
||||||
|
local apptoggle = require('app_toggle')
|
||||||
|
|
||||||
|
apptoggle:bind({'cmd', 'alt', 'ctrl'}, 'A', 'Activity Monitor')
|
||||||
|
apptoggle:bind({'cmd', 'ctrl'}, '4', 'Skitch')
|
||||||
|
apptoggle:bind({'cmd', 'ctrl'}, 'A', 'YakYak')
|
||||||
|
apptoggle:bind({'cmd', 'ctrl'}, 'B', 'Portico')
|
||||||
|
apptoggle:bind({'cmd', 'ctrl'}, 'C', 'Medis')
|
||||||
|
apptoggle:bind({'cmd', 'ctrl'}, 'D', 'Wavebox')
|
||||||
|
apptoggle:bind({'cmd', 'ctrl'}, 'E', 'Emacs', '/Applications/Emacs.app')
|
||||||
|
apptoggle:bind({'cmd', 'ctrl'}, 'F', 'Messenger')
|
||||||
|
apptoggle:bind({'cmd', 'ctrl'}, 'G', 'Stride')
|
||||||
|
apptoggle:bind({'cmd', 'ctrl'}, 'S', 'Skype')
|
||||||
|
apptoggle:bind({'cmd', 'ctrl'}, 'T', 'IRCCloud')
|
||||||
|
apptoggle:bind({'cmd', 'ctrl'}, 'W', 'WhatsApp')
|
||||||
|
apptoggle:bind({'cmd', 'ctrl'}, 'X', 'Calendar')
|
||||||
|
apptoggle:bind({'cmd', 'ctrl'}, 'Z', 'Slack')
|
||||||
|
end
|
||||||
|
|
||||||
|
return obj
|
||||||
@@ -4,13 +4,6 @@
|
|||||||
hs.hotkey.bind({'cmd', 'alt', 'ctrl'}, 'R', hs.reload)
|
hs.hotkey.bind({'cmd', 'alt', 'ctrl'}, 'R', hs.reload)
|
||||||
hs.hotkey.bind({'cmd', 'alt', 'ctrl'}, 'C', hs.toggleConsole)
|
hs.hotkey.bind({'cmd', 'alt', 'ctrl'}, 'C', hs.toggleConsole)
|
||||||
|
|
||||||
--------------------------------------------------------------------------------
|
|
||||||
-- Environment
|
|
||||||
--------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
local env = require('env')
|
|
||||||
env:init()
|
|
||||||
|
|
||||||
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
-- Set Hammerspoon options
|
-- Set Hammerspoon options
|
||||||
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
@@ -36,36 +29,11 @@ spoon.HeadphoneAutoPause.autoResume = false
|
|||||||
spoon.HeadphoneAutoPause:start()
|
spoon.HeadphoneAutoPause:start()
|
||||||
|
|
||||||
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
-- Application toggles
|
-- Host specific configuration
|
||||||
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
|
|
||||||
local apptoggle = require('app_toggle')
|
local hostconfig = require('host_config')
|
||||||
|
hostconfig:init()
|
||||||
apptoggle:bind({'cmd', 'ctrl'}, 'E', 'Emacs', '/Applications/Emacs.app')
|
|
||||||
apptoggle:bind({'cmd', 'ctrl'}, 'X', 'Calendar')
|
|
||||||
|
|
||||||
if env.hostname == "UAC00024" then
|
|
||||||
apptoggle:bind({'alt', 'ctrl'}, 'A', 'Activity Monitor')
|
|
||||||
apptoggle:bind({'cmd', 'ctrl'}, 'B', 'Sequel Pro')
|
|
||||||
apptoggle:bind({'cmd', 'ctrl'}, 'C', 'Paw')
|
|
||||||
apptoggle:bind({'cmd', 'ctrl'}, 'D', 'Mail')
|
|
||||||
apptoggle:bind({'cmd', 'ctrl'}, 'G', 'Slack')
|
|
||||||
apptoggle:bind({'cmd', 'ctrl'}, 'S', 'Skype for Business')
|
|
||||||
apptoggle:bind({'cmd', 'ctrl'}, 'Z', 'Stride')
|
|
||||||
else
|
|
||||||
apptoggle:bind({'cmd', 'alt', 'ctrl'}, 'A', 'Activity Monitor')
|
|
||||||
apptoggle:bind({'cmd', 'ctrl'}, '4', 'Skitch')
|
|
||||||
apptoggle:bind({'cmd', 'ctrl'}, 'A', 'YakYak')
|
|
||||||
apptoggle:bind({'cmd', 'ctrl'}, 'B', 'Portico')
|
|
||||||
apptoggle:bind({'cmd', 'ctrl'}, 'C', 'Medis')
|
|
||||||
apptoggle:bind({'cmd', 'ctrl'}, 'D', 'Wavebox')
|
|
||||||
apptoggle:bind({'cmd', 'ctrl'}, 'F', 'Messenger')
|
|
||||||
apptoggle:bind({'cmd', 'ctrl'}, 'G', 'Stride')
|
|
||||||
apptoggle:bind({'cmd', 'ctrl'}, 'S', 'Skype')
|
|
||||||
apptoggle:bind({'cmd', 'ctrl'}, 'T', 'IRCCloud')
|
|
||||||
apptoggle:bind({'cmd', 'ctrl'}, 'W', 'WhatsApp')
|
|
||||||
apptoggle:bind({'cmd', 'ctrl'}, 'Z', 'Slack')
|
|
||||||
end
|
|
||||||
|
|
||||||
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
-- Window management
|
-- Window management
|
||||||
|
|||||||
Reference in New Issue
Block a user