dotfiles/.config/hypr/config/input.lua
2026-08-04 11:15:48 +02:00

188 lines
8.8 KiB
Lua

--------------
---- INPUT ---
--------------
-- https://wiki.hyprland.org/Configuring/Variables/#input
hl.config({
input = {
numlock_by_default = true,
follow_mouse = 1,
sensitivity = 0.1, -- -1.0 - 1.0, 0 means no modification.
touchpad = {
natural_scroll = true,
disable_while_typing = false,
},
},
})
-- https://wiki.hyprland.org/Configuring/Variables/#gestures
-- TODO port to lua
-- gesture = 3, "horizontal", "workspace"
-- Example per-device config
-- See https://wiki.hyprland.org/Configuring/Keywords/#per-device-input-configs for more
hl.device({
name = "epic-mouse-v1",
sensitivity = -0.5,
})
--------------------
---- KEYBINDINGS ---
--------------------
-- See https://wiki.hyprland.org/Configuring/Keywords/
mainMod = "SUPER" -- Sets "Windows" key as main modifier
-- Example binds, see https://wiki.hyprland.org/Configuring/Binds/ for more
-- TODO use the ones defined in envuronment.lua
local terminal = "foot"
local fileManager = "nautilus"
local menu = "rofi -show drun"
local notificationManager = "swaync-client -t"
-- Main desktop controls
hl.bind(mainMod .. " + Q" , hl.dsp.window.close())
hl.bind(mainMod .. " + R" , hl.dsp.exec_cmd(menu)) -- Omnibar
hl.bind(mainMod .. " + D" , hl.dsp.exec_cmd(menu)) -- Legacy menu shortcut
hl.bind(mainMod .. " + I" , hl.dsp.exec_cmd("hyprlock")) -- Lockscreen
hl.bind(mainMod .. " + B" , hl.dsp.exec_cmd("~/.config/hypr/scripts/toggle-waybar.sh")) -- Toggle sidebar
hl.bind(mainMod .. " + SHIFT + R", hl.dsp.exec_cmd("~/.config/hypr/scripts/reload.sh")) -- Reload desktop
hl.bind(mainMod .. " + F11" , hl.dsp.exec_cmd("~/.config/hypr/scripts/gamemode.sh")) -- Gamemode
hl.bind(mainMod .. " + F10" , hl.dsp.exec_cmd("~/.config/hypr/scripts/sharp_mode.sh")) -- Sharp mode
hl.bind(mainMod .. " + SHIFT + M", hl.dsp.exit()) -- Exit desktop session
-- Shortcuts
hl.bind(mainMod .. " + RETURN", hl.dsp.exec_cmd(terminal))
hl.bind(mainMod .. " + X" , hl.dsp.exec_cmd(terminal)) -- Absolutely not because I dislocated my arm
hl.bind(mainMod .. " + SPACE" , hl.dsp.exec_cmd(menu))
hl.bind(mainMod .. " + E" , hl.dsp.exec_cmd(fileManager))
hl.bind(mainMod .. " + A" , hl.dsp.exec_cmd(notificationManager))
-- TODO Replace by default editor
hl.bind("XF86Launch1" , hl.dsp.exec_cmd(terminal .. " hx ~/.config/hypr/config"))
-- 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" }))
-- Move focus with mainMod + hjkl (vim keybinds)
hl.bind(mainMod .. " + H", hl.dsp.focus({ direction = "left" }))
hl.bind(mainMod .. " + L", hl.dsp.focus({ direction = "right" }))
hl.bind(mainMod .. " + K", hl.dsp.focus({ direction = "up" }))
hl.bind(mainMod .. " + J", hl.dsp.focus({ direction = "down" }))
-- Move windows with mainMod + shift + arrow keys
hl.bind(mainMod .. " + SHIFT + left" , hl.dsp.window.move{ direction = "left" })
hl.bind(mainMod .. " + SHIFT + right", hl.dsp.window.move{ direction = "right" })
hl.bind(mainMod .. " + SHIFT + up" , hl.dsp.window.move{ direction = "up" })
hl.bind(mainMod .. " + SHIFT + down" , hl.dsp.window.move{ direction = "down" })
-- Layout
hl.bind(mainMod .. " + " .. "F", hl.dsp.window.fullscreen())
hl.bind(mainMod .. " + " .. "V", hl.dsp.layout("togglesplit"))
-- Horizontal/vertical split
hl.bind(mainMod .. " + " .. "T", hl.dsp.window.float())
hl.bind(mainMod .. " + " .. "Y", hl.dsp.window.pseudo()) -- Toggle pseudo-tiling
-- Switch workspaces with mainMod + [0-9]
hl.bind(mainMod .. " + 1", hl.dsp.focus({ workspace = 1 }))
hl.bind(mainMod .. " + 2", hl.dsp.focus({ workspace = 2 }))
hl.bind(mainMod .. " + 3", hl.dsp.focus({ workspace = 3 }))
hl.bind(mainMod .. " + 4", hl.dsp.focus({ workspace = 4 }))
hl.bind(mainMod .. " + 5", hl.dsp.focus({ workspace = 5 }))
hl.bind(mainMod .. " + 6", hl.dsp.focus({ workspace = 6 }))
hl.bind(mainMod .. " + 7", hl.dsp.focus({ workspace = 7 }))
hl.bind(mainMod .. " + 8", hl.dsp.focus({ workspace = 8 }))
hl.bind(mainMod .. " + 9", hl.dsp.focus({ workspace = 9 }))
hl.bind(mainMod .. " + 0", hl.dsp.focus({ workspace = 10 }))
-- Move active window to a workspace with mainMod + SHIFT + [0-9]
hl.bind(mainMod .. " + SHIFT + 1", hl.dsp.window.move({ workspace = 1 }))
hl.bind(mainMod .. " + SHIFT + 2", hl.dsp.window.move({ workspace = 2 }))
hl.bind(mainMod .. " + SHIFT + 3", hl.dsp.window.move({ workspace = 3 }))
hl.bind(mainMod .. " + SHIFT + 4", hl.dsp.window.move({ workspace = 4 }))
hl.bind(mainMod .. " + SHIFT + 5", hl.dsp.window.move({ workspace = 5 }))
hl.bind(mainMod .. " + SHIFT + 6", hl.dsp.window.move({ workspace = 6 }))
hl.bind(mainMod .. " + SHIFT + 7", hl.dsp.window.move({ workspace = 7 }))
hl.bind(mainMod .. " + SHIFT + 8", hl.dsp.window.move({ workspace = 8 }))
hl.bind(mainMod .. " + SHIFT + 9", hl.dsp.window.move({ workspace = 9 }))
hl.bind(mainMod .. " + SHIFT + 0", hl.dsp.window.move({ workspace = 10 }))
-- TODO more concise notation for workspaces
-- for i = 0, 10 do
-- hl.bind(mainMod .. " + " .. key, hl.dsp.focus({ workspace = i}))
-- hl.bind(mainMod .. " + SHIFT + " .. key, hl.dsp.window.move({ workspace = i }))
-- end
-- 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" }))
-- Minimize function (uses scratchpad)
-- For testing, may be removed in future releases
hl.bind(mainMod .. " + N", hl.dsp.workspace.toggle_special("magic"))
-- TODO fix
-- hl.bind(mainMod .. " + N", hl.dsp.window.move({ direction = "+0" }))
hl.bind(mainMod .. " + N", hl.dsp.workspace.toggle_special("magic"))
hl.bind(mainMod .. " + N", hl.dsp.window.move({ workspace = "special:magic" }))
hl.bind(mainMod .. " + N", hl.dsp.workspace.toggle_special("magic"))
-- 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" }))
-- 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 })
-- Function keys
--- Volume
hl.bind("XF86AudioRaiseVolume", hl.dsp.exec_cmd("wpctl set-volume -l 1 @DEFAULT_AUDIO_SINK@ 5%+"), { locked = true })
hl.bind("XF86AudioLowerVolume", hl.dsp.exec_cmd("wpctl set-volume @DEFAULT_AUDIO_SINK@ 5%-"), { locked = true })
hl.bind("XF86AudioMute", hl.dsp.exec_cmd("wpctl set-mute @DEFAULT_AUDIO_SINK@ toggle"), { locked = true })
hl.bind("XF86AudioMicMute", hl.dsp.exec_cmd("wpctl set-mute @DEFAULT_AUDIO_SOURCE@ toggle"), { locked = true })
--- Brightness
hl.bind("XF86MonBrightnessUp", hl.dsp.exec_cmd("brightnessctl s 5%+"), { locked = true })
hl.bind("XF86MonBrightnessDown", hl.dsp.exec_cmd("brightnessctl s 5%-"), { locked = true })
hl.bind("SHIFT" .. " + XF86MonBrightnessUp", hl.dsp.exec_cmd("brightnessctl s 1%+"), { locked = true })
hl.bind("SHIFT" .. " + XF86MonBrightnessDown", hl.dsp.exec_cmd("brightnessctl s 1%-"), { locked = true })
--- Player controls
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 })
--- Screenshot
hl.bind("Print", hl.dsp.exec_cmd("~/.config/hypr/scripts/screenshot.sh"))
hl.bind("SHIFT" .. " + " .. "Print", hl.dsp.exec_cmd("~/.config/hypr/scripts/screenshot.sh --fullscreen"))
-- Color picker
hl.bind(mainMod .. " + " .. "SHIFT" .. " + " .. "C", hl.dsp.exec_cmd("hyprpicker -a"))
--- Touchpad toggle
hl.bind("XF86TouchpadToggle", hl.dsp.exec_cmd("~/.config/hypr/scripts/toggle-touchpad.sh"), { locked = true })
---- On galaxy books, pressing the disable touchpad key also triggers SUPER and
---- CONTROL keys, this is why there are present here
hl.bind("SUPER + CONTROL" .. " + " .. "XF86TouchpadToggle", hl.dsp.exec_cmd("~/.config/hypr/scripts/toggle-touchpad.sh"))
--- Keyboard layout toggle
---- Only works between AZERTY and QWERTY because of differences in the numbers row
---- that prevent using the default way provided by hyprland
hl.bind(mainMod .. " + " .. "CONTROL" .. " + " .. "SPACE", hl.dsp.exec_cmd("~/.config/hypr/scripts/change-kb-layout.sh"))
-- Lock laptop on lid close
hl.bind("switch:off:Lid Switch", hl.dsp.exec_cmd("hyprlock --immediate"), { locked = true })
--- Testing
--bind = $mainMod, TAB, overview:toggle, toggle