---------------------
---- KEYBINDINGS ----
---------------------
-- Version 2
-- Last change:     Sun 2026-06-14 using Hyprland v0.55.3-1
-- Git repo:        https://git.fennek.xyz/fennek182/dotfiles
-- Latest version:  https://git.fennek.xyz/fennek182/dotfiles/src/branch/main/.config/hypr/modules/binds.lua

-- See https://wiki.hypr.land/Configuring/Basics/Binds/ for more
-- Example bind:
-- hl.bind("SUPER + Q", hl.dsp.exec_cmd("kitty"), { description = "Open my favourite terminal" })

---- App variables
local terminal      = "~/.local/bin/alacritty"
local fileManager   = "nautilus"
local browser       = "~/.local/bin/firefox"
local editor_gui    = "~/.local/bin/zed"
local editor_cli    = "env -u VIMINIT nvim"
local vpn           = "/opt/ivpn/ui/bin/ivpn-ui"
local mediaPlayer   = "/opt/ivpn/ui/bin/ivpn-ui"

--- Modifiers
local mainMod       = "SUPER" -- Sets "Windows" key as main modifier


-- ========== Misc ==========
-- For ALT + TAB between workspaces
hl.config({
    binds = {
        workspace_back_and_forth = true,
        allow_workspace_cycles = true,
    },
})


-- ========== Apps ==========
hl.bind(mainMod .. " + Return", hl.dsp.exec_cmd(terminal))
hl.bind(mainMod .. " + N", hl.dsp.exec_cmd(editor_gui))
hl.bind(mainMod .. " + ALT + N", hl.dsp.exec_cmd(editor_gui .. " /mnt/ssd/dox/todo.txt"))
hl.bind(mainMod .. " + E", hl.dsp.exec_cmd(fileManager .. " --new-window"))
hl.bind(mainMod .. " + F", hl.dsp.exec_cmd(browser))
hl.bind(mainMod .. " + SHIFT + F", hl.dsp.exec_cmd(browser .. " --private-window"))
hl.bind("CTRL + ALT + N", hl.dsp.exec_cmd(mediaPlayer .. " --player-operation-mode=pseudo-gui"))

-- ========== Apps > global Keybinds ==========
hl.bind("ALT + 0", hl.dsp.pass({ window = "class:^(com\\.obsproject\\.Studio)$" }))
hl.bind("ALT + P", hl.dsp.pass({ window = "class:^(com\\.obsproject\\.Studio)$" }))


-- ========== Scripts ==========
hl.bind(mainMod .. " + ALT + P", hl.dsp.exec_cmd("~/.local/bin/firefox2tv &"))
hl.bind(mainMod .. " + ALT + P", hl.dsp.exec_cmd("~/.local/bin/firefox2mpv --current &"))
hl.bind(mainMod .. " + ALT + P", hl.dsp.exec_cmd("~/.local/bin/firefox2mpv --select &"))


-- ========== Hyprland ==========
hl.bind(mainMod .. " + SHIFT + R", hl.dsp.exec_cmd("hyprctl reload"))

--- Restart waybar
hl.bind(mainMod .. " + ALT + R", hl.dsp.exec_cmd("pkill waybar; hyprctl dispatch 'hl.dsp.exec_cmd(\"waybar\")' "))

--- Layouts
--- TODO: per workspace layouts with + SHIFT
hl.bind(mainMod .. " + A", function() hl.config({ general = { layout = "master" } }) end)       -- master
hl.bind(mainMod .. " + D", function() hl.config({ general = { layout = "dwindle" } }) end)      -- dwindle
hl.bind(mainMod .. " + S", function() hl.config({ general = { layout = "scrolling" } }) end)    -- scrolling

--- Windows
local closeWindowBind = hl.bind(mainMod .. " + Q", hl.dsp.window.close())
-- closeWindowBind:set_enabled(false)
hl.bind(mainMod .. " + SHIFT + Q", hl.dsp.exec_cmd("hyprctl kill"))
hl.bind("ALT + TAB", hl.dsp.focus({ workspace = "previous" }))
hl.bind(mainMod .. " + ALT + I", hl.dsp.exec_cmd("notify-send \"$(hyprctl activewindow -j | jq -r .title)\""))

--- Windows > floating - toggle foating, set window size to 80% and center
hl.bind(mainMod .. "+ Y", function ()
    -- Only toggle floating if window is already floating
    local active_window = hl.get_active_window()
    if not active_window then return end
    if active_window.floating == true then
        hl.dispatch(hl.dsp.window.float({action = "toggle"}))
        return
    end

    -- Toggle floating, set window size to 80% and center
    hl.dispatch(hl.dsp.window.float({action = "toggle"}))
    local monitor = hl.get_active_monitor()
    if not monitor then return end
    local height = monitor.height * 0.8
    local width = monitor.width * 0.8
    hl.dispatch(hl.dsp.window.resize({x = width, y = height}))
    hl.dispatch(hl.dsp.window.center())
end)

--- Windows > pin - pin a window so it displays above all workspaces (picture in picture)
hl.bind(mainMod .. "+ SHIFT + Y", function ()
    hl.dispatch(hl.dsp.window.float({action = "toggle"}))
    hl.dispatch(hl.dsp.window.pin({action = "toggle"}))
end)

--- Windows > all float - set all windows to floating -
---  I have no idea how this works in lua now, I gave up after wasting too much time reading the wiki
---  the wiki sucks SERIOUSLY, old stuff just gets removed, stuff like workspaceopt gets NO MENTION AT ALL
---  idk... I never used this function anyway... sooo:
--- TODO: remove this on next commit:
-- hl.bind(mainMod .. " + SHIFT + V", hl.dsp.exec_cmd("hyprctl dispatch workspaceopt allfloat"))

--- Windows > split (dwindle layout only)
hl.bind(mainMod .. " + SHIFT + J", hl.dsp.layout("togglesplit")) -- dwindle only

--- Windows > fullscreen / maximize / fake fullscreen
hl.bind(mainMod .. " + SHIFT + P", hl.dsp.window.pseudo())       -- dwindle only
hl.bind(mainMod .. " + M", hl.dsp.window.fullscreen({ action = "toggle" }))
hl.bind(mainMod .. " + SHIFT + M", hl.dsp.window.fullscreen_state({ internal = 0, client = 2 }))
--     ^-- keeps the window non-fullscreen, but the client goes into fullscreen mode within the window

--- Move focus with mainMod + arrow keys
hl.bind(mainMod .. " + left",  hl.dsp.focus({ direction = "left" }))
hl.bind(mainMod .. " + right", hl.dsp.focus({ direction = "right" }))
hl.bind(mainMod .. " + up",    hl.dsp.focus({ direction = "up" }))
hl.bind(mainMod .. " + down",  hl.dsp.focus({ direction = "down" }))

--- Workspaces
-- switch workspaces with mainMod + [0-9]
-- move active window to a workspace with mainMod + SHIFT + [0-9]:
-- for i = 1, 10 do
--     local key = i % 10 -- 10 maps to key 0
--     hl.bind(mainMod .. " + " .. key,             hl.dsp.focus({ workspace = i}))
--     hl.bind(mainMod .. " + SHIFT + " .. key,     hl.dsp.window.move({ workspace = i }))
-- end

--- Workspaces > Switch workspaces with mainMod + [0-9]
hl.bind(mainMod .. " + " .. 1, hl.dsp.focus({ workspace = 5 }))
hl.bind(mainMod .. " + " .. 2, hl.dsp.focus({ workspace = 6 }))
hl.bind(mainMod .. " + " .. 3, hl.dsp.focus({ workspace = 7 }))
hl.bind(mainMod .. " + " .. 4, hl.dsp.focus({ workspace = 8 }))
hl.bind(mainMod .. " + " .. 5, hl.dsp.focus({ workspace = 1 }))
hl.bind(mainMod .. " + " .. 6, hl.dsp.focus({ workspace = 2 }))
hl.bind(mainMod .. " + " .. 7, hl.dsp.focus({ workspace = 3 }))
hl.bind(mainMod .. " + " .. 8, hl.dsp.focus({ workspace = 4 }))
hl.bind(mainMod .. " + " .. 9, hl.dsp.focus({ workspace = 9 }))
hl.bind(mainMod .. " + " .. 0, hl.dsp.focus({ workspace = 10 }))
hl.bind(mainMod .. " + " .. "ssharp", hl.dsp.focus({ workspace = 11 }))
hl.bind(mainMod .. " + " .. "dead_acute", hl.dsp.focus({ workspace = 12 }))

--- Workspaces > Switch workspaces with mainMod + pageUp/pageDown
hl.bind(mainMod .. " + " .. "Next", hl.dsp.focus({ workspace = -1 }))
hl.bind(mainMod .. " + " .. "Prior", hl.dsp.focus({ workspace = "+1" }))

--- Workspaces > Scroll through existing workspaces with mainMod + scroll
hl.bind(mainMod .. " + mouse_down", hl.dsp.focus({ workspace = "e+1" }))
hl.bind(mainMod .. " + mouse_up",   hl.dsp.focus({ workspace = "e-1" }))

--- Workspaces > Move active window to a workspace with mainMod + SHIFT + [0-9]
hl.bind(mainMod .. " + " .. "SHIFT + " .. 1, hl.dsp.window.move({ workspace = 5 }))
hl.bind(mainMod .. " + " .. "SHIFT + " .. 2, hl.dsp.window.move({ workspace = 6 }))
hl.bind(mainMod .. " + " .. "SHIFT + " .. 3, hl.dsp.window.move({ workspace = 7 }))
hl.bind(mainMod .. " + " .. "SHIFT + " .. 4, hl.dsp.window.move({ workspace = 8 }))
hl.bind(mainMod .. " + " .. "SHIFT + " .. 5, hl.dsp.window.move({ workspace = 1 }))
hl.bind(mainMod .. " + " .. "SHIFT + " .. 6, hl.dsp.window.move({ workspace = 2 }))
hl.bind(mainMod .. " + " .. "SHIFT + " .. 7, hl.dsp.window.move({ workspace = 3 }))
hl.bind(mainMod .. " + " .. "SHIFT + " .. 8, hl.dsp.window.move({ workspace = 4 }))
hl.bind(mainMod .. " + " .. "SHIFT + " .. 9, hl.dsp.window.move({ workspace = 9 }))
hl.bind(mainMod .. " + " .. "SHIFT + " .. 0, hl.dsp.window.move({ workspace = 10 }))
hl.bind(mainMod .. " + " .. "SHIFT + " .. "ssharp", hl.dsp.window.move({ workspace = 11 }))
hl.bind(mainMod .. " + " .. "SHIFT + " .. "dead_acute", hl.dsp.window.move({ workspace = 12 }))

--- Workspaces > Move active window to a workspace with mainMod + SHIFT + pageUp/pageDown
hl.bind(mainMod .. " + SHIFT + Next", hl.dsp.window.move({ workspace = -1 }))
hl.bind(mainMod .. " + SHIFT + Prior", hl.dsp.window.move({ workspace = "+1" }))

--- Workspaces > Move workspaces between dual screen setup
hl.bind(mainMod .. " + ALT + left", hl.dsp.exec_cmd("hyprctl dispatch movecurrentworkspacetomonitor DP-1"))
hl.bind(mainMod .. " + ALT + right", hl.dsp.exec_cmd("hyprctl dispatch movecurrentworkspacetomonitor DP-4"))


--- TODO: add device specific binds
-- thinkpad:
-- gpd:


-- ========== Rofi ==========
-- TODO: formatting/string cleanup
hl.bind("CTRL + ALT+ B", hl.dsp.exec_cmd("~/.local/bin/poweroptions_rofi"))
hl.bind(mainMod .. " + B", hl.dsp.exec_cmd("notify-send CPU-Profil gewechselt Performance && sudo /usr/bin/cpupower frequency-set -g performance"))
hl.bind(mainMod .. " + SHIFT" .. " + " .. "B", hl.dsp.exec_cmd("notify-send CPU-Profil gewechselt Powersave && sudo /usr/bin/cpupower frequency-set -g powersave"))
hl.bind(mainMod .. " + C", hl.dsp.exec_cmd("~/.local/bin/rofi_calc"))
hl.bind(mainMod .. " + SHIFT" .. " + " .. "C", hl.dsp.exec_cmd("~/.local/bin/rofi_calc --normal-window"))
hl.bind("CTRL + ALT + P", hl.dsp.exec_cmd("~/.config/rofi/bin/menu_powermenu"))
hl.bind(mainMod .. " + U", hl.dsp.exec_cmd("~/.local/bin/bemoji"))
-- bind = $mainMod, U, exec, rofi -show emoji -modi emoji:/usr/bin/rofimoji --single

hl.bind(mainMod .. " + space", hl.dsp.exec_cmd("~/.local/bin/rofi_drun"))
hl.bind("SUPER" .. " + SUPER_L", hl.dsp.exec_cmd("~/.local/bin/rofi_drun"), { repeating = true })
hl.bind("CTRL + ALT + minus", hl.dsp.exec_cmd("~/.local/bin/mount_rofi"))

-- TODO: fix bind:
hl.bind("ALT + space", hl.dsp.exec_cmd("zsh -c rofi -show run"))

-- ========== System control ==========
-- TODO: formatting/string cleanup
hl.bind("CTRL + ALT" .. " + " .. "A", hl.dsp.exec_cmd("alacritty -e alsamixer"))
hl.bind("CTRL + ALT + SHIFT" .. " + " .. "B", hl.dsp.exec_cmd("sh ~/.local/bin/blue_light_filter"))
hl.bind("CTRL + ALT" .. " + " .. "S", hl.dsp.exec_cmd("pavucontrol"))
hl.bind(mainMod .. " + " .. "V", hl.dsp.exec_cmd("dunstctl history-pop"))
hl.bind("CTRL + ALT" .. " + " .. "V", hl.dsp.exec_cmd("dunstctl history-pop"))
hl.bind("CTRL + ALT + SHIFT" .. " + " .. "V", hl.dsp.exec_cmd("dunstctl set-paused toggle && pkill -RTMIN+2 waybar"))
hl.bind(mainMod .. " + " .. "CTRL + ALT" .. " + " .. "V", hl.dsp.exec_cmd("dunstctl close && pkill -RTMIN+2 waybar"))
hl.bind(mainMod .. " + " .. "ALT" .. " + " .. "V", hl.dsp.exec_cmd("dunstctl close && pkill -RTMIN+2 waybar"))
hl.bind("CTRL + ALT + SHIFT" .. " + " .. "W", hl.dsp.exec_cmd("python ~/.local/src/setbg-gui/azote/azote/v10_abhier.py"))
hl.bind("CTRL + SHIFT" .. " + " .. "W", hl.dsp.exec_cmd("python ~/.local/src/setbg-gui/azote/azote/v10_abhier.py"))
hl.bind("CTRL + ALT" .. " + " .. "W", hl.dsp.exec_cmd("sh ~/.local/bin/setbg --random"))
hl.bind("CTRL + SHIFT" .. " + " .. "Escape", hl.dsp.exec_cmd("~/.local/bin/alacritty --class floating -e btop"))
-- bind = CTRL ALT, O, exec, switch_output


-- ========== Volume control ==========
-- TODO: formatting/string cleanup
hl.bind("XF86AudioLowerVolume", hl.dsp.exec_cmd("pactl set-sink-volume @DEFAULT_SINK@ -1%"))
hl.bind("CTRL + ALT" .. " + " .. "numbersign", hl.dsp.exec_cmd("pactl set-sink-volume @DEFAULT_SINK@ -1%"))
hl.bind("CTRL + SHIFT" .. " + " .. "numbersign", hl.dsp.exec_cmd("pactl set-sink-volume @DEFAULT_SINK@ -3%"))

hl.bind("XF86AudioRaiseVolume", hl.dsp.exec_cmd("pactl set-sink-volume @DEFAULT_SINK@ +1%"))
hl.bind("CTRL + ALT" .. " + " .. "plus", hl.dsp.exec_cmd("pactl set-sink-volume @DEFAULT_SINK@ +1%"))
hl.bind("CTRL + SHIFT" .. " + " .. "plus", hl.dsp.exec_cmd("pactl set-sink-volume @DEFAULT_SINK@ +3%"))

hl.bind("XF86AudioMute", hl.dsp.exec_cmd("pactl set-sink-mute @DEFAULT_SINK@ toggle"))
hl.bind("XF86AudioMicMute", hl.dsp.exec_cmd("pactl set-source-mute @DEFAULT_SOURCE@ toggle"))
hl.bind("CTRL + ALT" .. " + " .. "M", hl.dsp.exec_cmd("pactl set-sink-mute @DEFAULT_SINK@ toggle"))
hl.bind("CTRL + ALT + SHIFT" .. " + " .. "M", hl.dsp.exec_cmd("pactl set-source-mute @DEFAULT_SOURCE@ toggle"))


-- ========== Media control ==========
-- TODO: formatting/string cleanup
hl.bind(mainMod .. " + ALT + comma", hl.dsp.exec_cmd("playerctl previous"))
hl.bind(mainMod .. " + ALT + left", hl.dsp.exec_cmd("playerctl previous"))
hl.bind(mainMod .. " + F7", hl.dsp.exec_cmd("playerctl previous"))

hl.bind(mainMod .. " + ALT + minus", hl.dsp.exec_cmd("playerctl pause"))
-- bind = $mainMod ALT, up, exec, playerctl pause
-- bind = $mainMod ALT, down, exec, playerctl pause
hl.bind(mainMod .. " + F8", hl.dsp.exec_cmd("playerctl pause"))

hl.bind(mainMod .. " + ALT + period", hl.dsp.exec_cmd("playerctl next"))
-- bind = $mainMod ALT, right, exec, playerctl next
hl.bind(mainMod .. " + F9", hl.dsp.exec_cmd("playerctl next"))

-- ========== Brightness control ==========
-- TODO: formatting/string cleanup
-- TODO: fix brightness:
hl.bind("XF86MonBrightnessDown", hl.dsp.exec_cmd("brightnessctl set 3%-"))
hl.bind("XF86MonBrightnessUp", hl.dsp.exec_cmd("brightnessctl set 3%+"))
hl.bind(mainMod .. " + " .. "XF86AudioLowerVolume", hl.dsp.exec_cmd("~/.local/bin/monitor --dimmer"))
hl.bind(mainMod .. " + " .. "XF86AudioRaiseVolume", hl.dsp.exec_cmd("~/.local/bin/monitor --brighter"))
hl.bind(mainMod .. " + " .. "SHIFT" .. " + " .. "XF86AudioLowerVolume", hl.dsp.exec_cmd("~/.local/bin/monitor --one_dimmer"))
hl.bind(mainMod .. " + " .. "SHIFT" .. " + " .. "XF86AudioRaiseVolume", hl.dsp.exec_cmd("~/.local/bin/monitor --one_brighter"))
hl.bind("CTRL + ALT" .. " + " .. "Prior", hl.dsp.exec_cmd("~/.local/bin/monitor --brighter"))
hl.bind("CTRL + ALT + SHIFT" .. " + " .. "Prior", hl.dsp.exec_cmd("~/.local/bin/monitor --one_brighter"))
hl.bind("CTRL + ALT" .. " + " .. "Next", hl.dsp.exec_cmd("~/.local/bin/monitor --dimmer"))
hl.bind("CTRL + ALT + SHIFT" .. " + " .. "Next", hl.dsp.exec_cmd("~/.local/bin/monitor --one_dimmer"))

-- ========== Screenshots ==========
-- TODO: formatting/string cleanup
-- ---- Full ----
hl.bind("Print", hl.dsp.exec_cmd("~/.local/bin/screenshot --full"))

-- Screenshot of all monitors
hl.bind("CTRL" .. " + " .. "Print", hl.dsp.exec_cmd("~/.local/bin/screenshot --full_clipboard"))

-- ---- Window ----
hl.bind("ALT" .. " + " .. "Print", hl.dsp.exec_cmd("~/.local/bin/screenshot --window"))
hl.bind("ALT" .. " + " .. "ssharp", hl.dsp.exec_cmd("~/.local/bin/screenshot --window"))
hl.bind("CTRL + ALT" .. " + " .. "Print", hl.dsp.exec_cmd("~/.local/bin/screenshot --window_clipboard"))
hl.bind("CTRL + ALT" .. " + " .. "ssharp", hl.dsp.exec_cmd("~/.local/bin/screenshot --window_clipboard"))

-- ---- Selection ----
hl.bind("SHIFT" .. " + " .. "Print", hl.dsp.exec_cmd("~/.local/bin/screenshot --selection"))
hl.bind("SHIFT" .. " + " .. "Print", hl.dsp.exec_cmd("~/.local/bin/screenshot --selection"))
hl.bind("CTRL + SHIFT" .. " + " .. "Print", hl.dsp.exec_cmd("~/.local/bin/screenshot --selection_clipboard"))
hl.bind("CTRL + SHIFT" .. " + " .. "ssharp", hl.dsp.exec_cmd("~/.local/bin/screenshot --selection_clipboard"))

-- ---- Monitor ----
hl.bind(mainMod .. " + " .. "print", hl.dsp.exec_cmd("~/.local/bin/screenshot --monitor"))
hl.bind(mainMod .. " + " .. "CTRL" .. " + " .. "print", hl.dsp.exec_cmd("~/.local/bin/screenshot --monitor_clipboard"))

-- ---- Open file / folder ----
hl.bind(mainMod .. " + " .. "SHIFT" .. " + " .. "Print", hl.dsp.exec_cmd("nautilus --new-window ~/pix/screenshots/nightfury/"))
hl.bind(mainMod .. " + " .. "CTRL + SHIFT" .. " + " .. "Print", hl.dsp.exec_cmd("imv-dir ~/pix/screenshots/nightfury/$(ls -Art ~/pix/screenshots| tail -n 1)"))

-- TODO:
-- dunstify actions to open file in imv or nautlus
-- SUPER + SHIFT + print                 open image in imv (or standard image viewer) - if already image in clipboard, save to tmp and open
-- super + ALT+ print                    open latest file in gimp, if already in clipboard, then open that
-- dismissed idea - copy latest file to clipboard, ignore if theres already a picture in the clipboard
-- use copy montor to clipboard instead - (just copy/paste or open folder)
-- CTRL + SUPER + PRINT  copy latest screenshot to clipboard


-- ========== Window management ==========
-- TODO: formatting/string cleanup
-- Move focus with mainMod + j i k l
hl.bind(mainMod .. " + " .. "j", hl.dsp.focus({ direction = "left" }))
hl.bind(mainMod .. " + " .. "k", hl.dsp.focus({ direction = "down" }))
hl.bind(mainMod .. " + " .. "i", hl.dsp.focus({ direction = "up" }))
hl.bind(mainMod .. " + " .. "l", hl.dsp.focus({ direction = "right" }))

-- Move focus with mainMod + vim keys
-- bind = $mainMod, h, movefocus, l
-- bind = $mainMod, j, movefocus, d
-- bind = $mainMod, k, movefocus, u
-- bind = $mainMod, l, movefocus, r

-- Move focus with mainMod + arrow keys
hl.bind(mainMod .. " + " .. "left", hl.dsp.focus({ direction = "left" }))
hl.bind(mainMod .. " + " .. "right", hl.dsp.focus({ direction = "right" }))
hl.bind(mainMod .. " + " .. "up", hl.dsp.focus({ direction = "up" }))
hl.bind(mainMod .. " + " .. "down", hl.dsp.focus({ direction = "down" }))

-- Scroll through existing workspaces with mainMod + scroll
hl.bind(mainMod .. " + mouse_down", hl.dsp.focus({ workspace = "e+1" }))
hl.bind(mainMod .. " + mouse_up",   hl.dsp.focus({ workspace = "e-1" }))

-- Toggle split direction
hl.bind(mainMod .. " + " .. "SHIFT" .. " + " .. "minus", hl.dsp.layout("togglesplit"))
hl.bind(mainMod .. " + " .. "minus", hl.dsp.layout("togglesplit"))
hl.bind(mainMod .. " + " .. "x", hl.dsp.layout("togglesplit"))

-- Resize windows
local resizeUnit = 100
hl.bind(mainMod .. " + CTRL + left", hl.dsp.window.resize({ x = -resizeUnit, y = 0, relative=true }))
hl.bind(mainMod .. " + CTRL + right", hl.dsp.window.resize({ x = resizeUnit, y = 0, relative=true }))
hl.bind(mainMod .. " + CTRL + up", hl.dsp.window.resize({ x = 0, y = -resizeUnit, relative=true }))
hl.bind(mainMod .. " + CTRL + down", hl.dsp.window.resize({ x = 0, y = resizeUnit, relative=true }))

-- Move windows
hl.bind(mainMod .. " + SHIFT + left", hl.dsp.window.swap({ direction = "left" }))
hl.bind(mainMod .. " + SHIFT + right", hl.dsp.window.swap({ direction = "right" }))
hl.bind(mainMod .. " + SHIFT + up", hl.dsp.window.swap({ direction = "up" }))
hl.bind(mainMod .. " + SHIFT + down", hl.dsp.window.swap({ direction = "down" }))

-- Move/resize windows with mainMod + LMB/RMB and dragging
hl.bind(mainMod .. " + " .. "mouse:272", hl.dsp.window.drag(), { mouse = true })
hl.bind(mainMod .. " + " .. "mouse:273", hl.dsp.window.resize(), { mouse = true })

-- Groups
hl.bind("SUPER" .. " + " .. "g", hl.dsp.group.toggle())
hl.bind("SUPER" .. " + " .. "tab", hl.dsp.group.next({ forward = false }))


-- TODO: check example config
-- -- Example special workspace (scratchpad)
-- hl.bind(mainMod .. " + S",         hl.dsp.workspace.toggle_special("magic"))
-- hl.bind(mainMod .. " + SHIFT + S", hl.dsp.window.move({ workspace = "special:magic" }))

-- -- Laptop multimedia keys for volume and LCD brightness
-- hl.bind("XF86AudioRaiseVolume", hl.dsp.exec_cmd("wpctl set-volume -l 1 @DEFAULT_AUDIO_SINK@ 5%+"), { locked = true, repeating = true })
-- hl.bind("XF86AudioLowerVolume", hl.dsp.exec_cmd("wpctl set-volume @DEFAULT_AUDIO_SINK@ 5%-"),      { locked = true, repeating = true })
-- hl.bind("XF86AudioMute",        hl.dsp.exec_cmd("wpctl set-mute @DEFAULT_AUDIO_SINK@ toggle"),     { locked = true, repeating = true })
-- hl.bind("XF86AudioMicMute",     hl.dsp.exec_cmd("wpctl set-mute @DEFAULT_AUDIO_SOURCE@ toggle"),   { locked = true, repeating = true })
-- hl.bind("XF86MonBrightnessUp",  hl.dsp.exec_cmd("brightnessctl -e4 -n2 set 5%+"),                  { locked = true, repeating = true })
-- hl.bind("XF86MonBrightnessDown",hl.dsp.exec_cmd("brightnessctl -e4 -n2 set 5%-"),                  { locked = true, repeating = true })

-- -- Requires playerctl
-- hl.bind("XF86AudioNext",  hl.dsp.exec_cmd("playerctl next"),       { locked = true })
-- hl.bind("XF86AudioPause", hl.dsp.exec_cmd("playerctl play-pause"), { locked = true })
-- hl.bind("XF86AudioPlay",  hl.dsp.exec_cmd("playerctl play-pause"), { locked = true })
-- hl.bind("XF86AudioPrev",  hl.dsp.exec_cmd("playerctl previous"),   { locked = true })


-- TODO (from Hyprland dev Vaxry):
--  open a (small) flatpak app on a hidden workspace at startup and then close it,
--  so the flatpak stuff is preloaded and app startup is faster
--  bind = $mainMod SHIFT, Return, exec, [workspace 2 silent;float;noanim] alacritty
