X-Git-Url: http://47.100.26.94:8080/?a=blobdiff_plain;f=hammerspoon%2Finit.lua;h=f30a5b63368c3db2cb2775f64d406277c5914a5c;hb=67b5f4d9b5c4dbc854ac55b627296ba7aa992d51;hp=5beeeda2c10a28e7f2f87221f835d0e018409e99;hpb=da1444b79dabf62580ab6acc7383ac0ee08857cd;p=dotfiles.git diff --git a/hammerspoon/init.lua b/hammerspoon/init.lua index 5beeeda..f30a5b6 100644 --- a/hammerspoon/init.lua +++ b/hammerspoon/init.lua @@ -10,43 +10,35 @@ hs.hotkey.bind({"cmd", "alt", "ctrl"}, "R", function() end) hs.alert.show("Config loaded") +---- Right click +--hs.hotkey.bind({"cmd,", "alt", "ctrl"}, "l", function() +-- hs.eventtap.rightClick(hs.mouse.getAbsolutePosition()) +--end) + +-- Donw : For firefox vimperator +hs.hotkey.bind({"cmd,", "ctrl"}, "n", function() + hs.eventtap.keyStroke({}, 'down') +end) --- Sample - Drawing on the screen - http://www.hammerspoon.org/go/#simplereload -mouseCircle = nil -mouseCircleTimer = nil +-- Up +hs.hotkey.bind({"cmd,", "ctrl"}, "p", function() + hs.eventtap.keyStroke({}, 'up') +end) -function mouseHighlight() - -- Delete an existing highlight if it exists - if mouseCircle then - mouseCircle:delete() - if mouseCircleTimer then - mouseCircleTimer:stop() +-- Reacting to application events +-- Move all Finder in front +function applicationWatcher(appName, eventType, appObject) + if (eventType == hs.application.watcher.activated) then + if (appName == "Finder") then + -- Bring all Finder windows forward when one gets activated + appObject:selectMenuItem({"Window", "Bring All to Front"}) end end - -- Get the current co-ordinates of the mouse pointer - mousepoint = hs.mouse.getAbsolutePosition() - -- Prepare a big red circle around the mouse pointer - mouseCircle = hs.drawing.circle(hs.geometry.rect(mousepoint.x-40, mousepoint.y-40, 80, 80)) - mouseCircle:setStrokeColor({["red"]=1,["blue"]=0,["green"]=0,["alpha"]=1}) - mouseCircle:setFill(false) - mouseCircle:setStrokeWidth(5) - mouseCircle:show() - - -- Set a timer to delete the circle after 3 seconds - mouseCircleTimer = hs.timer.doAfter(3, function() mouseCircle:delete() end) end -hs.hotkey.bind({"cmd","alt","shift"}, "D", mouseHighlight) +appWatcher = hs.application.watcher.new(applicationWatcher) +appWatcher:start() --- window movement -hs.hotkey.bind({"cmd", "alt", "ctrl"}, "H", function() - local win = hs.window.focusedWindow() - local f = win:frame() - - f.x = f.x - 10 - win:setFrame(f) -end) - -- Window Movement -- https://andrich.blog/2016/11/20/hammerspoon-an-awesome-tool-to-automate-your-mac/ -- CTRL + ALT + Left - Move current window to the left half of the screen. @@ -104,7 +96,7 @@ function move_window(direction) end end -local hyper = {"ctrl", "alt"} +local hyper = {"ctrl", "cmd"} hs.hotkey.bind(hyper, "h", move_window("left")) hs.hotkey.bind(hyper, "l", move_window("right")) hs.hotkey.bind(hyper, "k", move_window("up")) @@ -147,6 +139,7 @@ INSTALL:andUse("TextClipboardHistory", { config = { show_in_menubar = false, + hist_size = 500, }, hotkeys = { toggle_clipboard = { { "cmd", "shift" }, "v"}