From fdab40dff305058e94c4d46ec045567ac75a3e5e Mon Sep 17 00:00:00 2001 From: venus Date: Thu, 6 Aug 2026 23:21:22 -0500 Subject: [PATCH] feat(submaps): add basic submaps module --- basic/submaps.lua | 147 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 147 insertions(+) create mode 100644 basic/submaps.lua diff --git a/basic/submaps.lua b/basic/submaps.lua new file mode 100644 index 0000000..9d86b8a --- /dev/null +++ b/basic/submaps.lua @@ -0,0 +1,147 @@ +local mainMod = "SUPER" -- Sets "Windows" key as main modifier +local ipc = "qs -c noctalia-shell ipc call " +local custom = require("custom-functions") + +local function vim_motions_rebind_keys() -- Pressing H, J, K, L sends Left, Down, Up, Right to the active window + hl.bind("H", hl.dsp.send_shortcut({ mods = "", key = "Left"})) + hl.bind("J", hl.dsp.send_shortcut({ mods = "", key = "Down"})) + hl.bind("K", hl.dsp.send_shortcut({ mods = "", key = "Up"})) + hl.bind("L", hl.dsp.send_shortcut({ mods = "", key = "Right"})) +end + +local function clipper_submap_keys() -- A submap for quick access to certain clipboard and screen tools. Pressing H, J, K, L sends Left, Down, Up, Right to the active window. + hl.bind("C" ,hl.dsp.exec_cmd(ipc .. "plugin:clipper openPanel")) + vim_motions_rebind_keys() + local function exit() hl.dispatch(hl.dsp.submap("reset")) hl.dispatch(hl.dsp.exec_cmd(ipc .. "plugin:clipper closePanel")) end + hl.bind("escape" ,exit ) + hl.bind("MOD3" .. " + Hyper_L" ,exit ) +end + +hl.define_submap("hyper-submap", function() + clipper_submap_keys() + hl.bind("S" ,hl.dsp.exec_cmd(ipc .. "plugin:screen-toolkit toggle")) + hl.bind("T" ,hl.dsp.exec_cmd(ipc .. "plugin:timer toggle")) + hl.bind("M" ,hl.dsp.exec_cmd(ipc .. "controlCenter toggle")) +end) + +hl.define_submap("screen-toolkit", "reset", function() -- Access the screen toolkit options + hl.bind("S" ,hl.dsp.exec_cmd(ipc .. " plugin:screen-toolkit toggle")) + hl.bind("C" ,hl.dsp.exec_cmd(ipc .. " plugin:screen-toolkit color")) + hl.bind("P" ,hl.dsp.exec_cmd(ipc .. " plugin:screen-toolkit pallete")) + hl.bind("O" ,hl.dsp.exec_cmd(ipc .. " plugin:screen-toolkit ocr")) + hl.bind("L" ,hl.dsp.exec_cmd(ipc .. " plugin:screen-toolkit lens")) + hl.bind("A" ,hl.dsp.exec_cmd(ipc .. " plugin:screen-toolkit annotate")) + hl.bind("SHIFT + A" ,hl.dsp.exec_cmd(ipc .. " plugin:screen-toolkit annotateWindow")) + hl.bind("R" ,hl.dsp.exec_cmd(ipc .. " plugin:screen-toolkit recordMp4")) + hl.bind("SHIFT + R" ,hl.dsp.exec_cmd(ipc .. " plugin:screen-toolkit recordFullscreenMp4")) + hl.bind("catchall" ,function () + hl.dispatch(hl.dsp.submap("reset")) + hl.dispatch(hl.dsp.exec_cmd(ipc .. "plugin:screen-toolkit toggle ")) + end) +end) + +hl.define_submap("timer", function () -- Open and create timers, pause, reset, and start timers. + hl.bind("T" ,hl.dsp.exec_cmd(ipc .. "plugin:timer toggle")) + hl.bind("P" ,hl.dsp.exec_cmd(ipc .. "plugin:timer pause")) + hl.bind("R" ,hl.dsp.exec_cmd(ipc .. "plugin:timer reset")) + hl.bind("S" ,hl.dsp.exec_cmd(ipc .. "plugin:timer start 10")) + hl.bind("A" ,hl.dsp.exec_cmd(ipc .. "plugin:timer start 240")) + -- include the double escape or no? + hl.bind("catchall" ,function () + hl.dispatch(hl.dsp.submap("reset")) + hl.dispatch(hl.dsp.exec_cmd(ipc .. "plugin:timer toggle ")) + end) +end) + +hl.define_submap("quick-settings", function () -- An Interface for quickly accessing settings and toggling certain features. + hl.bind("V" ,hl.dsp.exec_cmd("protonvpn-app & hyprctl dispatch submap vpn")) + hl.bind("S" ,hl.dsp.exec_cmd(ipc .. "settings toggle")) + hl.bind("C" ,hl.dsp.exec_cmd(ipc .. "plugin:clipper togglePanel ")) + hl.bind("P" ,hl.dsp.exec_cmd(ipc .. "sessionMenu toggle")) + hl.bind("R" ,hl.dsp.exec_cmd(ipc .. "systemMonitor toggle")) + hl.bind("T" ,hl.dsp.exec_cmd(ipc .. "plugin:timer toggle")) + hl.bind("M" ,hl.dsp.exec_cmd(ipc .. "controlCenter toggle")) + hl.bind("D" ,hl.dsp.exec_cmd(ipc .. "notifications toggleDND")) + hl.bind("A" ,hl.dsp.exec_cmd(ipc .. "notifications dismissAll")) + hl.bind("SHIFT + B" ,hl.dsp.exec_cmd(ipc .. "bar toggle")) + hl.bind("SHIFT + W" ,hl.dsp.exec_cmd(ipc .. "wifi toggle -- toggle wifi")) + hl.bind("I" ,hl.dsp.exec_cmd(ipc .. "wallpaper toggle")) + hl.bind(" L " ,hl.dsp.exec_cmd(ipc .. "sessionMenu toggle")) + hl.bind("B " ,hl.dsp.exec_cmd(ipc .. "battery togglePanel -- toggle battery panel")) + hl.bind("SHIFT + C " ,hl.dsp.exec_cmd(ipc .. "calendar toggle")) + hl.bind("F" ,hl.dsp.exec_cmd(ipc .. "calendar toggle")) + -- Bind Submaps + hl.bind("L" ,hl.dsp.submap("layouts")) + hl.bind("N" ,function () + hl.dispatch(hl.dsp.submap("notifications-sub")) + hl.dispatch(hl.dsp.exec_cmd(ipc .. "notifications toggleHistory")) + end) + hl.bind("B" ,function() + hl.dispatch(hl.dsp.submap("bt-sub")) + hl.dispatch(hl.dsp.exec_cmd(ipc .. "bluetooth togglePanel")) + end) + hl.bind("W" ,function () + hl.dispatch(hl.dsp.submap("wifi-sub")) + hl.dispatch(hl.dsp.exec_cmd(ipc .. "network togglePanel")) + end) + -- TODO Implement layout switching + -- hl.bind(, L, hl.dsp.exec_cmd( notify-send "layout switching" & hyprctl dispatch submap layouts) + hl.bind("catchall" ,function () + hl.dispatch(hl.dsp.submap("reset")) + hl.dispatch(hl.dsp.exec_cmd(ipc .. "controlCenter toggle ")) + end) +end) + +hl.define_submap("notifications-sub", function() -- Notifications submap for quick access to notification settings and actions. + hl.bind("D" ,hl.dsp.exec_cmd(ipc .. "notifications toggleDND")) + hl.bind("S" ,hl.dsp.exec_cmd(ipc .. "notifications toggleDND")) + hl.bind("Q" ,hl.dsp.exec_cmd(ipc .. "notifications toggleDND")) + hl.bind("A" ,hl.dsp.exec_cmd(ipc .. "notifications dismissAll")) + hl.bind("C" ,hl.dsp.exec_cmd(ipc .. "notifications clear")) + hl.bind("CTRL + D" ,hl.dsp.exec_cmd(ipc .. "notifications dismissAll")) + hl.bind("SHIFT + D" ,hl.dsp.exec_cmd(ipc .. "notifications dismissAll")) + hl.bind(mainMod .. " + D " ,hl.dsp.exec_cmd(ipc .. "notifications dismissAll")) + hl.bind("escape" ,function () + hl.dispatch(hl.dsp.exec_cmd(ipc .. "notifications toggleHistory")) + hl.dispatch(hl.dsp.submap("reset")) + end) +end) + +hl.define_submap("wifi-sub", "reset", function() -- Wifi submap for quick access to wifi settings and actions. + hl.bind("T" ,hl.dsp.exec_cmd(ipc .. "wifi toggle")) + hl.bind("S" ,hl.dsp.exec_cmd(ipc .. "wifi togglePanel")) + hl.bind("D" ,hl.dsp.exec_cmd(ipc .. "wifi disable")) + hl.bind("E" ,hl.dsp.exec_cmd(ipc .. "wifi enable")) + hl.bind("R" ,hl.dsp.exec_cmd("sudo systemctl restart iwd")) + hl.bind("escape" ,hl.dsp.exec_cmd(ipc .. "network togglePanel")) +end) + +hl.define_submap("bt-sub", function() -- Bluetooth submap for quick access to bluetooth settings and actions. + hl.bind("T" ,hl.dsp.exec_cmd(ipc .. "bluetooth toggle")) + hl.bind("S" ,hl.dsp.exec_cmd(ipc .. "bluetooth togglePanel")) + hl.bind("D" ,hl.dsp.exec_cmd(ipc .. "bluetooth disable")) + hl.bind("E" ,hl.dsp.exec_cmd(ipc .. "bluetooth enable")) + hl.bind("H" ,hl.dsp.exec_cmd('bluetoothctl connect 88:92:CC:53:88:7E && notify-send "connected to headphones"')) + hl.bind("B" ,hl.dsp.exec_cmd('bluetoothctl connect FC:91:5D:6A:2A:C5 && notify-send "connected to earbuds"')) + hl.bind("P" ,hl.dsp.exec_cmd('bluetoothctl connect 64:9D:38:E0:4D:02 && notify-send "Connected to phone"')) + hl.bind("SHIFT + B" ,hl.dsp.exec_cmd('bluetoothctl disconnect FC:91:5D:6A:2A:C5 && notify-send "disconnected from earbuds"')) + hl.bind("J" ,hl.dsp.exec_cmd('bluetoothctl disconnect 88:92:CC:53:88:7E && notify-send "disconnected from headphones"')) + hl.bind("SHIFT + H" ,hl.dsp.exec_cmd('bluetoothctl disconnect 88:92:CC:53:88:7E && notify-send "disconnected from headphones"')) + hl.bind("M" ,hl.dsp.exec_cmd('bluetoothctl disconnect 64:9D:38:E0:4D:02 && notify-send "Disconnected from phone"')) + hl.bind("escape" ,function () + hl.dispatch(hl.dsp.exec_cmd(ipc .. "bluetooth togglePanel")) + hl.dispatch(hl.dsp.submap("reset")) + end) + end) + +hl.define_submap("open-apps", "reset", function() -- Submap for quickly opening commonly used applications. + hl.bind("S" ,hl.dsp.exec_cmd("signal-desktop")) + hl.bind("D" ,hl.dsp.exec_cmd("vesktop")) + hl.bind("F" ,hl.dsp.exec_cmd("firefox")) + hl.bind("M" ,hl.dsp.exec_cmd("feishin")) + hl.bind("R" ,hl.dsp.exec_cmd("calibre")) + hl.bind("E" ,hl.dsp.exec_cmd("darktable")) + hl.bind("catchall" ,hl.dsp.submap("reset")) +end) + +-- TODO Implement a VPN summap that allows quick connection to different VPN servers and toggling the VPN on/off.