X-Git-Url: http://47.100.26.94:8080/?a=blobdiff_plain;f=hammerspoon%2Finit.lua;h=0d0eb8303d584d852aed308703833aae9294b92b;hb=6515e998b7be0db4b699d119ceaad4bfa11d405e;hp=2228bdcc6978c0da2873cff5fe9bd6814005af1a;hpb=be4017091a741b544d0a7761429fdd9f6635b128;p=dotfiles.git diff --git a/hammerspoon/init.lua b/hammerspoon/init.lua index 2228bdc..0d0eb83 100644 --- a/hammerspoon/init.lua +++ b/hammerspoon/init.lua @@ -10,6 +10,21 @@ 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) + +-- Up +hs.hotkey.bind({"cmd,", "ctrl"}, "p", function() + hs.eventtap.keyStroke({}, 'up') +end) + -- Reacting to application events -- Move all Finder in front function applicationWatcher(appName, eventType, appObject) @@ -24,42 +39,6 @@ appWatcher = hs.application.watcher.new(applicationWatcher) appWatcher:start() - ----- Sample - Drawing on the screen - http://www.hammerspoon.org/go/#simplereload ---mouseCircle = nil ---mouseCircleTimer = nil ---function mouseHighlight() --- -- Delete an existing highlight if it exists --- if mouseCircle then --- mouseCircle:delete() --- if mouseCircleTimer then --- mouseCircleTimer:stop() --- 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) --- --- ----- 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. @@ -117,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")) @@ -160,6 +139,7 @@ INSTALL:andUse("TextClipboardHistory", { config = { show_in_menubar = false, + hist_size = 500, }, hotkeys = { toggle_clipboard = { { "cmd", "shift" }, "v"} @@ -211,3 +191,26 @@ INSTALL:andUse("Seal", start = true, } ) +-------------------------------------------------------------------------------- +-- Focus the last used window. +local function focusLastFocused() + local wf = hs.window.filter + local lastFocused = wf.defaultCurrentSpace:getWindows(wf.sortByFocusedLast) + if #lastFocused > 0 then lastFocused[1]:focus() end +end + +-- Create the chooser. +-- On selection, copy the emoji and type it into the focused application. +local chooser = hs.chooser.new(function(choice) + if not choice then focusLastFocused(); return end + hs.pasteboard.setContents(choice["chars"]) + focusLastFocused() + hs.eventtap.keyStrokes(hs.pasteboard.getContents()) +end) + +chooser:searchSubText(true) +chooser:choices(choices) + +chooser:rows(5) +chooser:bgDark(true) +hs.hotkey.bind({"cmd", "alt"}, "E", function() chooser:show() end)