aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--gdrive_mouseover_item.lua79
-rw-r--r--init.lua1
2 files changed, 80 insertions, 0 deletions
diff --git a/gdrive_mouseover_item.lua b/gdrive_mouseover_item.lua
new file mode 100644
index 0000000..80473ed
--- /dev/null
+++ b/gdrive_mouseover_item.lua
@@ -0,0 +1,79 @@
+-- Copyright (c) 2019 Teddy Wing
+--
+-- This program is free software: you can redistribute it and/or modify
+-- it under the terms of the GNU General Public License as published by
+-- the Free Software Foundation, either version 3 of the License, or
+-- (at your option) any later version.
+--
+-- This program is distributed in the hope that it will be useful,
+-- but WITHOUT ANY WARRANTY; without even the implied warranty of
+-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+-- GNU General Public License for more details.
+--
+-- You should have received a copy of the GNU General Public License
+-- along with this program. If not, see <https://www.gnu.org/licenses/>.
+
+
+gdrive_mouseover_item_mode = hs.hotkey.modal.new(
+ {'ctrl', 'option'},
+ 'o',
+ 'GDrive Mouseover Item'
+)
+gdrive_mouseover_item_mode:bind(
+ {'ctrl', 'option'},
+ 'o',
+ 'GDrive Mouseover Item Off',
+ function() gdrive_mouseover_item_mode:exit() end
+)
+
+function gdrive_mouseover_item_select(id)
+ local x_delta = 250
+ local y_delta = 250
+
+ y_delta = y_delta + (id * 48)
+
+ local zoom_position = hs.window.frontmostWindow():zoomButtonRect()
+ zoom_position.x = zoom_position.x + x_delta
+ zoom_position.y = zoom_position.y + y_delta
+
+ hs.mouse.setRelativePosition(zoom_position)
+ hs.eventtap.leftClick(zoom_position)
+end
+
+function gdrive_mouseover_item_run_and_exit(f)
+ return function()
+ f()
+
+ gdrive_mouseover_item_mode:exit()
+ end
+end
+
+for i = 0, 8 do
+ local key = tostring(i + 1)
+
+ gdrive_mouseover_item_mode:bind(
+ {},
+ key,
+ gdrive_mouseover_item_run_and_exit(function()
+ gdrive_mouseover_item_select(i)
+ end)
+ )
+end
+
+gdrive_mouseover_item_mode:bind(
+ {},
+ '0',
+ gdrive_mouseover_item_run_and_exit(function()
+ gdrive_mouseover_item_select(9)
+ end)
+)
+
+for i, key in pairs({'q', 'w', 'e', 'r', 't', 'y', 'u', 'i', 'o', 'p'}) do
+ gdrive_mouseover_item_mode:bind(
+ {},
+ key,
+ gdrive_mouseover_item_run_and_exit(function()
+ gdrive_mouseover_item_select(i + 9)
+ end)
+ )
+end
diff --git a/init.lua b/init.lua
index e4008c9..9ae8dce 100644
--- a/init.lua
+++ b/init.lua
@@ -18,6 +18,7 @@
require("hs.ipc")
require('application_switch')
+require('gdrive_mouseover_item')
require('mouse')
require('terminal_tab_hotkeys')