mirror of
https://github.com/jimeh/dotfiles.git
synced 2026-02-19 11:06:41 +00:00
Extract host specific hammerspoon config to separate files
This commit is contained in:
@@ -2,16 +2,13 @@ local obj = {
|
||||
hostname = nil
|
||||
}
|
||||
|
||||
function obj:init()
|
||||
self.hostname = self.getHostname()
|
||||
end
|
||||
|
||||
function obj:getHostname()
|
||||
local f = io.popen ("hostname")
|
||||
function obj.getHostname()
|
||||
local f = io.popen ("hostname -s")
|
||||
local hostname = f:read("*a") or ""
|
||||
f:close()
|
||||
hostname = string.gsub(hostname, "\n$", "")
|
||||
return hostname
|
||||
end
|
||||
|
||||
obj.hostname = obj.getHostname()
|
||||
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'}, 'C', hs.toggleConsole)
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
-- Environment
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
local env = require('env')
|
||||
env:init()
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
-- Set Hammerspoon options
|
||||
--------------------------------------------------------------------------------
|
||||
@@ -36,36 +29,11 @@ spoon.HeadphoneAutoPause.autoResume = false
|
||||
spoon.HeadphoneAutoPause:start()
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
-- Application toggles
|
||||
-- Host specific configuration
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
local apptoggle = require('app_toggle')
|
||||
|
||||
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
|
||||
local hostconfig = require('host_config')
|
||||
hostconfig:init()
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
-- Window management
|
||||
|
||||
Reference in New Issue
Block a user