103 lines
6.7 KiB
Lua

-- Dispatchers https://wiki.hyprland.org/Configuring/Dispatchers/
local constants = require("hyprland/constants")
-- Applications
hl.bind(constants.mainMod .. " + RETURN", hl.dsp.exec_cmd("uwsm app -- " .. constants.terminal))
hl.bind(constants.mainMod .. " + code:51", hl.dsp.exec_cmd("uwsm app -- " .. constants.browser))
hl.bind(constants.mainMod .. " + code:48", hl.dsp.exec_cmd("uwsm app -- " .. constants.fileManager))
hl.bind(constants.mainMod .. " + V", hl.dsp.exec_cmd("copyq show"))
hl.bind(constants.mainMod .. " + SUPER_L", hl.dsp.exec_cmd("if pgrep -x " .. constants.menu .. "; then kill $(pgrep -x " .. constants.menu .. "); else uwsm app -- " .. constants.menu .. " -show drun; fi"), { release = true })
hl.bind("code:107", hl.dsp.exec_cmd("grim -g \"$(slurp)\" - | swappy -f -"))
hl.bind(constants.mainMod .. " + code:107", hl.dsp.exec_cmd("grim -o $(hyprctl activeworkspace -j | jq \".monitor\" | tr -d \"\\\"\") - | swappy -f -"))
hl.bind(constants.subMod .. " + code:107", hl.dsp.exec_cmd(constants.kill_on_unfocus .. " normcap"))
hl.bind(constants.focusMod .. " + code:107", hl.dsp.exec_cmd("dunstify -a System -r 1000 -t 5000 -i \"" .. os.getenv("HOME") .. "/.config/assets/arch-maron.png\" \"Hyprpicker\" \"Color: $(hyprpicker -a -r)\""))
hl.bind(constants.mainMod .. " + O", hl.dsp.exec_cmd(os.getenv("HOME") .. "/.local/share/until-scripts/open_uri.sh"))
-- Media Buttons
hl.bind("XF86AudioLowerVolume", hl.dsp.exec_cmd("wpctl set-volume @DEFAULT_SINK@ 1%-"))
hl.bind("XF86AudioLowerVolume", hl.dsp.exec_cmd("dunstify -a System -r 1000 -t 2000 -i " .. os.getenv("HOME") .. "/.config/assets/volume-down.png -h int:value:$(echo \"100 * $(wpctl get-volume @DEFAULT_SINK@ | tr -d \"Volume: \")\" | bc) Volume"))
hl.bind("XF86AudioRaiseVolume", hl.dsp.exec_cmd("wpctl set-volume @DEFAULT_SINK@ 1%+"))
hl.bind("XF86AudioRaiseVolume", hl.dsp.exec_cmd("dunstify -a System -r 1000 -t 2000 -i " .. os.getenv("HOME") .. "/.config/assets/volume-up.png -h int:value:$(echo \"100 * $(wpctl get-volume @DEFAULT_SINK@ | tr -d \"Volume: \")\" | bc) Volume"))
hl.bind("XF86AudioPlay", hl.dsp.exec_cmd("playerctl play-pause"), { locked = true })
hl.bind("XF86AudioPlay", hl.dsp.exec_cmd("sleep 0.1; if [ \"$(playerctl status)\" = \"Playing\" ]; then dunstify -a System -r 1000 -t 2000 -i \"" .. os.getenv("HOME") .. "/.config/assets/play.png\" \"Player\" \"resumed playback\"; else dunstify -a System -r 1000 -t 2000 -i \"" .. os.getenv("HOME") .. "/.config/assets/pause.png\" \"Player\" \"paused playback\"; fi"), { locked = true })
hl.bind("XF86AudioNext", hl.dsp.exec_cmd("playerctl next"), { locked = true })
hl.bind("XF86AudioPrev", hl.dsp.exec_cmd("playerctl previous"), { locked = true })
-- System ctl
hl.bind("XF86PowerOff", hl.dsp.exec_cmd("bash ~/.local/share/until-scripts/sleep.sh hibernate"))
-- Window management
hl.bind(constants.mainMod .. " + Q", hl.dsp.window.close())
hl.bind(constants.mainMod .. " + W", hl.dsp.window.fullscreen({ mode = "fullscreen", action = "toggle" }))
hl.bind(constants.mainMod .. " + T", hl.dsp.window.fullscreen({ mode = "fullscreen", action = "toggle" }))
-- FIXME: dispatcher 'forcerendererreload' not found in Hyprland 0.55 hl.dsp API. Original bind: $mainMod, M, forcerendererreload,
hl.bind(constants.mainMod .. " + F", hl.dsp.window.float({ action = "toggle" }))
hl.bind(constants.mainMod .. " + R", hl.dsp.workspace.toggle_special("scratchpad"))
hl.bind(constants.mainMod .. " + X", hl.dsp.workspace.toggle_special("scratchpad2"))
hl.bind(constants.mainMod .. " + code:21", hl.dsp.workspace.toggle_special("dump"))
-- FIXME: dispatcher 'layoutmsg' not found in Hyprland 0.55 hl.dsp API. Original bind: $resizeMod, e, layoutmsg, orientationnext
-- FIXME: dispatcher 'layoutmsg' not found in Hyprland 0.55 hl.dsp API. Original bind: $resizeMod, q, layoutmsg, orientationprev
-- Change Focus
hl.bind(constants.focusMod .. " + A", hl.dsp.focus({ direction = "l" }))
hl.bind(constants.focusMod .. " + D", hl.dsp.focus({ direction = "r" }))
hl.bind(constants.focusMod .. " + W", hl.dsp.focus({ direction = "u" }))
hl.bind(constants.focusMod .. " + S", hl.dsp.focus({ direction = "d" }))
-- Resize Window
hl.bind(constants.resizeMod .. " + A", hl.dsp.window.resize({ x = -30, y = 0, relative = true }), { repeating = true })
hl.bind(constants.resizeMod .. " + D", hl.dsp.window.resize({ x = 30, y = 0, relative = true }), { repeating = true })
hl.bind(constants.resizeMod .. " + S", hl.dsp.window.resize({ x = 0, y = 30, relative = true }), { repeating = true })
hl.bind(constants.resizeMod .. " + W", hl.dsp.window.resize({ x = 0, y = -30, relative = true }), { repeating = true })
-- Move Window
hl.bind(constants.moveMod .. " + A", hl.dsp.window.move({ direction = "l" }))
hl.bind(constants.moveMod .. " + D", hl.dsp.window.move({ direction = "r" }))
hl.bind(constants.moveMod .. " + S", hl.dsp.window.move({ direction = "d" }))
hl.bind(constants.moveMod .. " + W", hl.dsp.window.move({ direction = "u" }))
hl.bind(constants.mainMod .. " + code:112", hl.dsp.window.move({ monitor = "DP-2" }))
hl.bind(constants.mainMod .. " + code:117", hl.dsp.window.move({ monitor = "DP-3" }))
hl.bind(constants.mainMod .. " + E", hl.dsp.exec_cmd(constants.special_workspace_movment .. " scratchpad"))
hl.bind(constants.mainMod .. " + Y", hl.dsp.exec_cmd(constants.special_workspace_movment .. " scratchpad2"))
hl.bind(constants.mainMod .. " + code:20", hl.dsp.exec_cmd(constants.special_workspace_movment .. " dump"))
-- Overview
--hl.bind(constants.mainMod .. " + code:65", function()
-- constants.hyprspace.toggle()
-- end
--)
-- Switch workspaces with mainMod
hl.bind(constants.mainMod .. " + code:113", function() constants.smw.workspace("-1") end)
hl.bind(constants.mainMod .. " + code:114", function() constants.smw.workspace("+1") end)
hl.bind(constants.subMod .. " + code:113", function() constants.smw.move_to_workspace("-1") end)
hl.bind(constants.subMod .. " + code:114", function() constants.smw.move_to_workspace("+1") end)
-- Workspace management
-- Mousebinds
hl.bind(constants.mainMod .. " + mouse:272", hl.dsp.window.drag(), { mouse = true })
hl.bind(constants.mainMod .. " + mouse:273", hl.dsp.window.resize(), { mouse = true })
-- Submaps
hl.bind(constants.mainMod .. " + G", hl.dsp.submap("gaming"))
hl.define_submap("gaming", function()
hl.bind(constants.mainMod .. " + T", hl.dsp.window.fullscreen({ mode = "fullscreen", action = "toggle" }))
hl.bind(constants.mainMod .. " + R", hl.dsp.workspace.toggle_special("scratchpad"))
hl.bind(constants.mainMod .. " + G", hl.dsp.submap("reset"), {long_press = true})
hl.bind(constants.mainMod .. " + mouse:272", hl.dsp.window.drag(), { mouse = true })
hl.bind(constants.mainMod .. " + mouse:273", hl.dsp.window.drag(), { mouse = true })
hl.bind(constants.mainMod .. " + code:51", hl.dsp.exec_cmd(constants.browser))
end)