153 lines
6.8 KiB
Lua
153 lines
6.8 KiB
Lua
function ToggleFloatingWindow()
|
|
local monitor = hl.get_active_monitor()
|
|
local width = math.floor(monitor.width * 0.8)
|
|
local height = math.floor(monitor.height * 0.8)
|
|
|
|
hl.dispatch(hl.dsp.window.float({ action = "toggle" }))
|
|
hl.dispatch(hl.dsp.window.resize({ x = width, y = height, window = "active", }))
|
|
end
|
|
|
|
--------------
|
|
---- 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,
|
|
},
|
|
},
|
|
})
|
|
|
|
-- Gestures
|
|
hl.gesture({
|
|
fingers = 3,
|
|
direction = "horizontal",
|
|
action = "workspace",
|
|
})
|
|
|
|
hl.gesture({
|
|
fingers = 3,
|
|
direction = "vertical",
|
|
action = ToggleFloatingWindow,
|
|
})
|
|
|
|
--------------------
|
|
---- KEYBINDINGS ---
|
|
--------------------
|
|
|
|
MainMod = "SUPER" -- Sets META ("Windows") key as main modifier
|
|
|
|
-- 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
|
|
-- Toggle floating
|
|
hl.bind(MainMod .. " + T", ToggleFloatingWindow )
|
|
hl.bind(MainMod .. " + " .. "Y", hl.dsp.window.pseudo()) -- Toggle pseudo-tiling
|
|
|
|
-- Switch workspaces with mainMod + [0-9]
|
|
-- Move active window to a workspace with mainMod + SHIFT + [0-9]
|
|
for i = 0, 10 do
|
|
local key = i % 10
|
|
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" }))
|
|
|
|
-- TODO
|
|
-- Minimize function (uses scratchpad)
|
|
|
|
-- 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 })
|