Skip to content

Commit

Permalink
hammerspon: Fast switch between accounts
Browse files Browse the repository at this point in the history
  • Loading branch information
oschrenk committed Sep 3, 2015
1 parent a4d052f commit 3ee467b
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions .hammerspoon/init.lua
Expand Up @@ -130,6 +130,25 @@ hs.hotkey.bind(hyper, "t", function()
os.execute("/bin/rm -rf ~/.Trash/*")
end)


------------------------
-- Fast user switching
------------------------
hs.hotkey.bind(hyper, "u", function()
local file = assert(io.popen('/usr/bin/whoami', 'r'))
local output = file:read('*all')
file:close()
is_personal_account = output:gsub("%s+", "") == "oliver"

if (is_personal_account) then
hs.alert.show("Switch to work")
os.execute('/System/Library/CoreServices/Menu\\ Extras/User.menu/Contents/Resources/CGSession -switchToUserID 503')
else
hs.alert.show("Switch to fun")
os.execute('/System/Library/CoreServices/Menu\\ Extras/User.menu/Contents/Resources/CGSession -switchToUserID 502')
end
end)

------------------------
-- Bluetooth
------------------------
Expand Down

0 comments on commit 3ee467b

Please sign in to comment.