Files
scripts/hypr/base.lua
T
adamfandClaude Opus 5.5 cc5f0348dc Add cursor_follow: PiP windows follow the mouse cursor in Hyprland
New hypr/cursor_follow.lua module, loaded from base.lua. A repeating
timer keeps the followed window floating and pinned beside the cursor.
It flips sides at the screen edges so the window never covers the cursor.

- Picture-in-Picture windows follow automatically. This replaces the old
  rule that tiled them.
- $mod+p makes the focused window follow, or pauses/resumes following.
  $mod+Shift+p stops.
- Following stops when the window closes or is tiled again.
- The followed window is tagged so following picks back up after a
  config reload.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-16 16:29:32 +00:00

330 lines
10 KiB
Lua

-- Hyprland Lua config - converted from i3 config by Adam French
-- https://wiki.hypr.land/Configuring/
-- Built from colors.lua + base.lua by build.sh (edit base.lua, not hyprland.lua)
------------------
---- MONITORS ----
------------------
hl.monitor({ output = "", mode = "preferred", position = "auto", scale = 1 })
-- Per-machine layout generated by nwg-displays
pcall(require, "monitors")
---------------------
---- MY PROGRAMS ----
---------------------
local terminal = "kitty"
local fileManager = "kitty -e ranger"
local menu = "wofi --show drun"
----------------
---- CURSOR ----
----------------
hl.env("XCURSOR_THEME", "Miku Cursor")
hl.env("XCURSOR_SIZE", "48")
hl.env("HYPRCURSOR_SIZE", "48")
-------------------
---- AUTOSTART ----
-------------------
hl.on("hyprland.start", function()
hl.exec_cmd("dex -a")
hl.exec_cmd("/usr/lib/polkit-gnome/polkit-gnome-authentication-agent-1")
hl.exec_cmd("wl-paste --watch cliphist store")
hl.exec_cmd("dunst")
hl.exec_cmd("hypridle")
hl.exec_cmd("hyprpaper")
hl.exec_cmd("gammastep -m wayland -l 51.5074:-0.1278 -t 6500:3500")
hl.exec_cmd("waterfox")
hl.exec_cmd("waybar")
end)
-------------------------------
---- ENVIRONMENT VARIABLES ----
-------------------------------
hl.env("XDG_SESSION_TYPE", "wayland")
-- NVIDIA-specific env vars — uncomment if running on nvidia:
-- hl.env("LIBVA_DRIVER_NAME", "nvidia")
-- hl.env("GBM_BACKEND", "nvidia-drm")
-- hl.env("__GLX_VENDOR_LIBRARY_NAME", "nvidia")
-- hl.env("WLR_NO_HARDWARE_CURSORS", "1")
-----------------------
---- LOOK AND FEEL ----
-----------------------
hl.config({
general = {
gaps_in = 5, -- inner gaps (i3: gaps inner 10 → split between two sides)
gaps_out = 0, -- outer gaps (i3: gaps outer 0)
border_size = 1,
col = {
active_border = color_primary,
inactive_border = color_gray,
},
resize_on_border = true,
allow_tearing = false,
layout = "dwindle",
},
xwayland = {
force_zero_scaling = true,
},
decoration = {
rounding = 0,
active_opacity = 1.0,
inactive_opacity = 1.0,
shadow = {
enabled = false,
},
blur = {
enabled = true,
size = 3,
passes = 1,
},
},
animations = {
enabled = true,
},
dwindle = {
preserve_split = true, -- required for togglesplit
},
master = {
new_status = "slave",
},
misc = {
force_default_wallpaper = 0,
disable_hyprland_logo = true,
focus_on_activate = true, -- replaces i3's "for_window [urgent=latest] focus"
},
input = {
kb_layout = "",
kb_options = "caps:swapescape,grp:alt_shift_toggle",
follow_mouse = 1,
sensitivity = 0,
},
})
hl.curve("myBezier", { type = "bezier", points = { { 0.645, 0.045 }, { 0.355, 1.000 } } })
hl.animation({ leaf = "windows", enabled = true, speed = 7, bezier = "myBezier" })
hl.animation({ leaf = "windowsOut", enabled = true, speed = 7, bezier = "myBezier" })
hl.animation({ leaf = "border", enabled = true, speed = 10, bezier = "myBezier" })
hl.animation({ leaf = "borderangle", enabled = true, speed = 8, bezier = "myBezier" })
hl.animation({ leaf = "fade", enabled = true, speed = 7, bezier = "myBezier" })
hl.animation({ leaf = "workspaces", enabled = true, speed = 6, bezier = "myBezier" })
---------------------
---- KEYBINDINGS ----
---------------------
local mod = "SUPER"
-- Terminal
hl.bind(mod .. " + Return", hl.dsp.exec_cmd(terminal))
-- Kill focused window
hl.bind(mod .. " + SHIFT + Q", hl.dsp.window.close())
-- Launcher (wofi replaces dmenu)
hl.bind(mod .. " + D", hl.dsp.exec_cmd(menu))
-- Pavucontrol
hl.bind(mod .. " + CTRL + M", hl.dsp.exec_cmd("hyprpwcenter"))
-- Applications
hl.bind(mod .. " + F2", hl.dsp.exec_cmd("waterfox"))
hl.bind(mod .. " + F3", hl.dsp.exec_cmd(fileManager))
hl.bind(mod .. " + SHIFT + F3", hl.dsp.exec_cmd("pcmanfm"))
hl.bind(mod .. " + F5", hl.dsp.exec_cmd("kitty -e mocp"))
-- Toggle window layout between master and dwindle
local layoutIsMaster = false
hl.bind(mod .. " + T", function()
layoutIsMaster = not layoutIsMaster
hl.config({ general = { layout = layoutIsMaster and "master" or "dwindle" } })
end)
-- Restart dunst
hl.bind(mod .. " + SHIFT + D", hl.dsp.exec_cmd("killall dunst && notify-send 'restart dunst'"))
-- Screenshots (flameshot on Wayland needs -g flag or use grim/slurp instead)
hl.bind("Print", hl.dsp.exec_cmd("flameshot gui"))
hl.bind(mod .. " + Print", hl.dsp.exec_cmd('grim -g "$(slurp)" - | wl-copy'))
hl.bind(mod .. " + SHIFT + Print", hl.dsp.exec_cmd('grim -g "$(slurp)" ~/screenshot.png'))
-- Xkill equivalent
hl.bind(mod .. " + CTRL + X", hl.dsp.exec_cmd("hyprctl kill"))
-- Toggle nerd-dictation
hl.bind(
mod .. " + C",
hl.dsp.exec_cmd(
'pgrep -f "nerd-dictation begin" >/dev/null && nerd-dictation end || nerd-dictation begin --simulate-input-tool=YDOTOOL'
)
)
-- Lock screen
hl.bind(mod .. " + 9", hl.dsp.exec_cmd("hyprlock")) -- replaces blurlock; configure hyprlock separately
-- Toggle bar visibility (waybar)
hl.bind(mod .. " + M", hl.dsp.exec_cmd("pkill -SIGUSR1 waybar"))
-- Reload Hyprland config
hl.bind(mod .. " + SHIFT + C", hl.dsp.exec_cmd("hyprctl reload"))
-- Exit Hyprland
hl.bind(mod .. " + SHIFT + E", hl.dsp.exec_cmd("hyprshutdown"))
-- System mode (replaces i3's $mode_system)
hl.bind(mod .. " + 0", function()
hl.dispatch(
hl.dsp.exec_cmd(
'notify-send -t 5000 "System Mode" "(l)ock (s)uspend (h)ibernate\\n(r)eboot (Shift+s) shutdown (e)xit\\n\\nReturn/Escape to cancel"'
)
)
hl.dispatch(hl.dsp.submap("system"))
end)
-- second arg "reset" returns to the global submap after any bind fires
hl.define_submap("system", "reset", function()
hl.bind("L", hl.dsp.exec_cmd("hyprlock"))
hl.bind("S", hl.dsp.exec_cmd("systemctl suspend"))
hl.bind("H", hl.dsp.exec_cmd("systemctl hibernate"))
hl.bind("R", hl.dsp.exec_cmd("systemctl reboot"))
hl.bind("SHIFT + S", hl.dsp.exec_cmd("systemctl poweroff"))
hl.bind("E", hl.dsp.exec_cmd("hyprshutdown"))
hl.bind("Return", hl.dsp.exec_cmd("dunstctl close"))
hl.bind("Escape", hl.dsp.exec_cmd("dunstctl close"))
end)
-- --- FOCUS ---
local dirs = { H = "left", J = "down", K = "up", L = "right", left = "left", down = "down", up = "up", right = "right" }
for key, dir in pairs(dirs) do
hl.bind(mod .. " + " .. key, hl.dsp.focus({ direction = dir }))
hl.bind(mod .. " + SHIFT + " .. key, hl.dsp.window.move({ direction = dir }))
end
-- --- FLOATING ---
hl.bind(mod .. " + SHIFT + space", hl.dsp.window.float())
hl.bind(mod .. " + space", hl.dsp.focus({ urgent_or_last = true })) -- approximate focus mode_toggle
-- --- FULLSCREEN ---
hl.bind(mod .. " + F", hl.dsp.window.fullscreen())
-- --- SPLIT / LAYOUT ---
-- orientation* messages only apply to the master layout
hl.bind(mod .. " + G", hl.dsp.layout("orientationleft")) -- tile horizontally
hl.bind(mod .. " + V", hl.dsp.layout("orientationbottom")) -- tile vertically
hl.bind(mod .. " + E", hl.dsp.layout("togglesplit"))
hl.bind(mod .. " + W", hl.dsp.group.toggle())
-- --- STICKY (pin floating window) ---
hl.bind(mod .. " + SHIFT + S", hl.dsp.window.pin())
-- --- SCRATCHPAD ---
hl.bind(mod .. " + SHIFT + minus", hl.dsp.window.move({ workspace = "special:scratchpad", follow = false }))
hl.bind(mod .. " + minus", hl.dsp.workspace.toggle_special("scratchpad"))
-- --- WORKSPACE NAVIGATION ---
hl.bind(mod .. " + CTRL + right", hl.dsp.focus({ workspace = "r+1" }))
hl.bind(mod .. " + CTRL + left", hl.dsp.focus({ workspace = "r-1" }))
hl.bind(mod .. " + B", hl.dsp.focus({ workspace = "previous" })) -- back_and_forth
for i = 1, 8 do
-- Switch to workspace
hl.bind(mod .. " + " .. i, hl.dsp.focus({ workspace = i }))
-- Move container to workspace (silent = don't follow)
hl.bind(mod .. " + CTRL + " .. i, hl.dsp.window.move({ workspace = i, follow = false }))
-- Move to workspace AND follow (replaces $mod+Shift+N in i3)
hl.bind(mod .. " + SHIFT + " .. i, hl.dsp.window.move({ workspace = i, follow = true }))
end
-- --- RESIZE SUBMAP ---
hl.bind(mod .. " + R", hl.dsp.submap("resize"))
hl.define_submap("resize", function()
local rep = { repeating = true }
hl.bind("H", hl.dsp.window.resize({ x = -20, y = 0, relative = true }), rep)
hl.bind("J", hl.dsp.window.resize({ x = 0, y = 20, relative = true }), rep)
hl.bind("K", hl.dsp.window.resize({ x = 0, y = -20, relative = true }), rep)
hl.bind("L", hl.dsp.window.resize({ x = 20, y = 0, relative = true }), rep)
hl.bind("left", hl.dsp.window.resize({ x = -30, y = 0, relative = true }), rep)
hl.bind("down", hl.dsp.window.resize({ x = 0, y = 30, relative = true }), rep)
hl.bind("up", hl.dsp.window.resize({ x = 0, y = -30, relative = true }), rep)
hl.bind("right", hl.dsp.window.resize({ x = 30, y = 0, relative = true }), rep)
hl.bind("Return", hl.dsp.submap("reset"))
hl.bind("Escape", hl.dsp.submap("reset"))
end)
-- --- MOUSE BINDS ---
hl.bind(mod .. " + mouse:272", hl.dsp.window.drag(), { mouse = true }) -- mod+LMB drag to move floating
hl.bind(mod .. " + mouse:273", hl.dsp.window.resize(), { mouse = true }) -- mod+RMB drag to resize
-- --- AUDIO ---
hl.bind(
"XF86AudioRaiseVolume",
hl.dsp.exec_cmd("pactl set-sink-volume @DEFAULT_SINK@ +10%"),
{ locked = true, repeating = true }
)
hl.bind(
"XF86AudioLowerVolume",
hl.dsp.exec_cmd("pactl set-sink-volume @DEFAULT_SINK@ -10%"),
{ locked = true, repeating = true }
)
hl.bind("XF86AudioMute", hl.dsp.exec_cmd("pactl set-sink-mute @DEFAULT_SINK@ toggle"), { locked = true })
hl.bind("XF86AudioMicMute", hl.dsp.exec_cmd("pactl set-source-mute @DEFAULT_SOURCE@ toggle"), { locked = true })
-- --- BRIGHTNESS ---
hl.bind("XF86MonBrightnessUp", hl.dsp.exec_cmd("brightnessctl set +5%"), { locked = true, repeating = true })
hl.bind("XF86MonBrightnessDown", hl.dsp.exec_cmd("brightnessctl set 5%-"), { locked = true, repeating = true })
----------------------
---- WINDOW RULES ----
----------------------
hl.window_rule({
name = "Surfshark",
match = { class = "^(Surfshark)$" },
workspace = "8 silent",
tile = true,
})
hl.window_rule({
name = "hyprpwcenter",
match = { class = "^(hyprpwcenter)$" },
float = true,
})
hl.window_rule({
name = "Lxappearance",
match = { class = "^(Lxappearance)$" },
float = true,
})
-- Picture-in-Picture windows float and follow the cursor (SUPER+P / SUPER+SHIFT+P), see cursor_follow.lua
require("cursor_follow")
-------------------------------
---- WORKSPACE NAMES / ICONS --
-------------------------------
-- Hyprland workspace names (replaces i3 set $ws variables)
-- These are used by waybar's workspaces module — configure names there.
-- ws1=ツ ws2=ಠ‿ಠ ws3=◕‿◕ ws4=ʘ‿ʘ
-- ws5=˘◡˘ ws6=◠‿◠ ws7=ᵔᴥᵔ ws8=æ