From b4fa650685ff42cff7616a6676d94d4e783ab256 Mon Sep 17 00:00:00 2001 From: Jeena Date: Mon, 24 Aug 2026 09:38:23 +0900 Subject: [PATCH] feat: convert hypr config to Lua and add Chester host - Add Lua equivalents for hyprland, autostart, keybindings, programs, windowrule - Add per-host Lua configs (Chester, Rutherford, example) with hostname detection - Rename old host 'William' to 'Chester'; fix 2x scaling on the 2880x1800 panel - Update .gitignore to track *.lua host files instead of example-host.conf --- .gitignore | 2 +- hypr/autostart.lua | 16 +++ hypr/hosts/Chester.lua | 13 ++ hypr/hosts/Rutherford.lua | 9 ++ hypr/hosts/example.lua | 7 + hypr/hyprland.lua | 284 ++++++++++++++++++++++++++++++++++++++ hypr/keybindings.lua | 38 +++++ hypr/programs.lua | 14 ++ hypr/windowrule.lua | 34 +++++ 9 files changed, 416 insertions(+), 1 deletion(-) create mode 100644 hypr/autostart.lua create mode 100644 hypr/hosts/Chester.lua create mode 100644 hypr/hosts/Rutherford.lua create mode 100644 hypr/hosts/example.lua create mode 100644 hypr/hyprland.lua create mode 100644 hypr/keybindings.lua create mode 100644 hypr/programs.lua create mode 100644 hypr/windowrule.lua diff --git a/.gitignore b/.gitignore index ca7c79b..b586c5c 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,3 @@ hypr/menu-*.list hypr/hosts/* -!hpyr/hosts/example-host.conf +!hypr/hosts/*.lua diff --git a/hypr/autostart.lua b/hypr/autostart.lua new file mode 100644 index 0000000..bf37e92 --- /dev/null +++ b/hypr/autostart.lua @@ -0,0 +1,16 @@ +-- Autostart (converted from autostart.conf) +local P = require("programs") + +-- Qt apps don't work with workspace on exec-once +-- Added windowrule for them + +hl.on("hyprland.start", function() + hl.exec_cmd("fcitx5") + hl.exec_cmd("~/.config/hypr/scripts/wob-daemon.sh") + hl.exec_cmd("[workspace 1 silent] " .. P.browser) + hl.exec_cmd("[workspace 2 silent] thunderbird") + hl.exec_cmd("[workspace 2 silent] element-desktop") + hl.exec_cmd("[workspace special:magic silent] " .. P.terminal) + hl.exec_cmd("keepassxc") + hl.exec_cmd('chromium --profile-directory="Default"') +end) diff --git a/hypr/hosts/Chester.lua b/hypr/hosts/Chester.lua new file mode 100644 index 0000000..4d5976c --- /dev/null +++ b/hypr/hosts/Chester.lua @@ -0,0 +1,13 @@ +-- Host-specific overrides: Chester (laptop, 2880x1800 internal display) +-- Converted from hosts/William.conf (which the .conf path used via the +-- host.conf symlink) — keeps the internal panel at 2x scaling. + +-- Laptop internal display — explicit & stable +hl.monitor({ + output = "eDP-1", + mode = "2880x1800@60", + position = "0x0", + scale = 2, +}) + +return {} diff --git a/hypr/hosts/Rutherford.lua b/hypr/hosts/Rutherford.lua new file mode 100644 index 0000000..b101afe --- /dev/null +++ b/hypr/hosts/Rutherford.lua @@ -0,0 +1,9 @@ +-- Host-specific overrides: Rutherford (desktop PC) +-- Converted from hosts/Rutherford.conf + +hl.monitor({ + output = "DP-1", + mode = "2560x1440@74.97", + position = "0x0", + scale = 1, +}) diff --git a/hypr/hosts/example.lua b/hypr/hosts/example.lua new file mode 100644 index 0000000..a5c4503 --- /dev/null +++ b/hypr/hosts/example.lua @@ -0,0 +1,7 @@ +-- example.lua - no-op host fallback (mirrors example.conf) +-- +-- Used by hyprland.lua when the machine's hostname does not match any +-- hosts/.lua file. Keep this file empty (or add shared defaults). +-- Create a file named after your host, e.g. hosts/MyHost.lua, to override +-- host-specific settings. +return {} diff --git a/hypr/hyprland.lua b/hypr/hyprland.lua new file mode 100644 index 0000000..20a50d6 --- /dev/null +++ b/hypr/hyprland.lua @@ -0,0 +1,284 @@ +-- Hyprland Lua config (converted from hyprland.conf) +-- Refer to the wiki for more information: https://wiki.hypr.land/Configuring/Start/ + +---------------- +--## ENVIRONMENT ### +---------------- + +hl.env("XCURSOR_SIZE", "24") +hl.env("HYPRCURSOR_SIZE", "24") +hl.env("QT_QPA_PLATFORMTHEME", "qt5ct") +hl.env("HYPRSHOT_DIR", "Screenshots") + +----------------- +--## MONITORS ### +----------------- + +-- Safe default for any machine +hl.monitor({ + output = "", + mode = "preferred", + position = "auto", + scale = 1, +}) + +------------------- +--## MY PROGRAMS ### +------------------- + +-- Shared program variables (was programs.conf). Other modules require() this. +local P = require("programs") + +--################ +--## AUTOSTART ### +--################ + +-- Hyprland-start executables (from hyprland.conf) +hl.on("hyprland.start", function() + hl.exec_cmd("hypridle") + hl.exec_cmd("waybar") + hl.exec_cmd("swaybg -i ~/.config/hypr/wallpapers/Purple.jpg -m fill") + hl.exec_cmd("~/.config/hypr/scripts/dynamic-borders.sh") + hl.exec_cmd("~/.config/hypr/scripts/xdg-desktop-portal-hyprland.sh") +end) + +require("autostart") + +------------------- +--## PERMISSIONS ### +------------------- +-- Note: permission changes require a Hyprland restart. +-- ecosystem { enforce_permissions = 1 } (commented out in original) + +--#################### +--## LOOK AND FEEL ### +--#################### + +-- General +hl.config({ + general = { + gaps_in = 5, + gaps_out = { 1, 0, 0, 0 }, + border_size = 3, + col = { + active_border = { colors = { "rgba(D55D7Cee)", "rgba(480023ee)" }, angle = 45 }, + inactive_border = "rgba(595959aa)", + }, + resize_on_border = true, + allow_tearing = false, + layout = "dwindle", + }, +}) + +-- Decoration +hl.config({ + decoration = { + rounding = 10, + rounding_power = 2, + active_opacity = 1.0, + inactive_opacity = 0.8, + shadow = { + enabled = true, + range = 4, + render_power = 3, + color = "rgba(1a1a1aee)", + }, + blur = { + enabled = true, + size = 3, + passes = 1, + vibrancy = 0.1696, + }, + }, +}) + +-- Animations +hl.config({ + animations = { + enabled = true, + }, +}) + +-- Bezier curves +hl.curve("easeOutQuint", { type = "bezier", points = { {0.23, 1}, {0.32, 1} } }) +hl.curve("easeInOutCubic", { type = "bezier", points = { {0.65, 0.05}, {0.36, 1} } }) +hl.curve("linear", { type = "bezier", points = { {0, 0}, {1, 1} } }) +hl.curve("almostLinear", { type = "bezier", points = { {0.5, 0.5}, {0.75, 1.0} } }) +hl.curve("quick", { type = "bezier", points = { {0.15, 0}, {0.1, 1} } }) + +-- Animations (default curves) +hl.animation({ leaf = "global", enabled = true, speed = 10, bezier = "default" }) +hl.animation({ leaf = "border", enabled = true, speed = 5.39, bezier = "easeOutQuint" }) +hl.animation({ leaf = "windows", enabled = true, speed = 4.79, bezier = "easeOutQuint" }) +hl.animation({ leaf = "windowsIn", enabled = true, speed = 4.1, bezier = "easeOutQuint", style = "popin 87%" }) +hl.animation({ leaf = "windowsOut", enabled = true, speed = 1.49, bezier = "linear", style = "popin 87%" }) +hl.animation({ leaf = "fadeIn", enabled = true, speed = 1.73, bezier = "almostLinear" }) +hl.animation({ leaf = "fadeOut", enabled = true, speed = 1.46, bezier = "almostLinear" }) +hl.animation({ leaf = "fade", enabled = true, speed = 3.03, bezier = "quick" }) +hl.animation({ leaf = "layers", enabled = true, speed = 3.81, bezier = "easeOutQuint" }) +hl.animation({ leaf = "layersIn", enabled = true, speed = 4, bezier = "easeOutQuint", style = "fade" }) +hl.animation({ leaf = "layersOut", enabled = true, speed = 1.5, bezier = "linear", style = "fade" }) +hl.animation({ leaf = "fadeLayersIn", enabled = true, speed = 1.79, bezier = "almostLinear" }) +hl.animation({ leaf = "fadeLayersOut", enabled = true, speed = 1.39, bezier = "almostLinear" }) +hl.animation({ leaf = "workspaces", enabled = true, speed = 1.94, bezier = "easeOutQuint", style = "slidefade" }) +hl.animation({ leaf = "workspacesIn", enabled = true, speed = 1.21, bezier = "easeOutQuint", style = "slidefade" }) +hl.animation({ leaf = "workspacesOut", enabled = true, speed = 1.94, bezier = "easeOutQuint", style = "slidefade" }) +hl.animation({ leaf = "specialWorkspace", enabled = true, speed = 1.21, bezier = "quick", style = "slidefadevert" }) + +-- Dwindle +hl.config({ + dwindle = { + preserve_split = true, -- You probably want this + force_split = 2, + }, +}) + +-- Master +hl.config({ + master = { + new_status = "master", + }, +}) + +-- Misc +hl.config({ + misc = { + force_default_wallpaper = 0, -- Set to 0 or 1 to disable the anime mascot wallpapers + disable_hyprland_logo = true, -- If true disables the random hyprland logo / anime girl background. + enable_swallow = true, + font_family = "FontAwesome", + -- Fix black screen on wake: let the compositor itself re-enable DPMS on input, + -- as a fallback when hypridle's after_sleep dpms-on runs too early / gets ignored. + key_press_enables_dpms = true, + mouse_move_enables_dpms = true, + }, +}) + +--------------- +--## INPUT ### +--------------- + +hl.config({ + input = { + kb_layout = "us,se,kr", + kb_variant = "dvorak,dvorak", + kb_options = "grp:win_space_toggle,grp:alt_r_toggle", + follow_mouse = 0, + float_switch_override_focus = 0, + sensitivity = 0.33, -- -1.0 - 1.0, 0 means no modification. + natural_scroll = true, + accel_profile = "adaptive", + touchpad = { + natural_scroll = true, + tap_to_click = true, + disable_while_typing = true, + }, + }, +}) + +-- Gestures +hl.gesture({ fingers = 3, direction = "horizontal", action = "workspace" }) +hl.gesture({ fingers = 3, direction = "vertical", action = function() + hl.dispatch(hl.dsp.workspace.toggle_special()) +end }) + +-- Example per-device config +hl.device({ + name = "epic-mouse-v1", + sensitivity = -0.5, +}) + +------------------- +--## KEYBINDINGS ### +------------------- + +-- Main focus/workspace binds (from hyprland.conf) +local mainMod = "SUPER" + +-- 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" })) + +-- Switch workspaces with mainMod + [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 })) +end + +-- Move active window to a workspace with mainMod + SHIFT + [0-9] +for i = 1, 10 do + local key = i % 10 + 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" })) + +-- 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" })) + +hl.bind("CTRL + ALT + right", hl.dsp.focus({ workspace = "e+1" })) +hl.bind("CTRL + ALT + left", 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 }) + +-- Swap active window with the one next to it with SUPER + SHIFT + arrow keys +hl.bind("SUPER + SHIFT + left", hl.dsp.window.swap({ direction = "left" }), { description = "Swap window to the left" }) +hl.bind("SUPER + SHIFT + right", hl.dsp.window.swap({ direction = "right" }), { description = "Swap window to the right" }) +hl.bind("SUPER + SHIFT + up", hl.dsp.window.swap({ direction = "up" }), { description = "Swap window up" }) +hl.bind("SUPER + SHIFT + down", hl.dsp.window.swap({ direction = "down" }), { description = "Swap window down" }) + +-- Laptop multimedia keys for volume and LCD brightness (bindel = locked + repeating) +hl.bind("XF86AudioRaiseVolume", hl.dsp.exec_cmd("~/.config/hypr/scripts/wob-volume.sh up"), { locked = true, repeating = true }) +hl.bind("XF86AudioLowerVolume", hl.dsp.exec_cmd("~/.config/hypr/scripts/wob-volume.sh down"), { 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("~/.config/hypr/scripts/wob-brightness.sh up"), { locked = true, repeating = true }) +hl.bind("XF86MonBrightnessDown", hl.dsp.exec_cmd("~/.config/hypr/scripts/wob-brightness.sh down"), { locked = true, repeating = true }) + +-- Requires playerctl (bindl = locked, no repeat) +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 }) + +require("keybindings") + +--------------------------- +--## WINDOWS AND WORKSPACES ### +--------------------------- + +hl.window_rule({ + name = "suppress-maximize", + match = { class = ".*" }, + suppress_event = "maximize", +}) + +hl.window_rule({ + name = "xwayland-nofocus-fix", + match = { + class = "^$", + title = "^$", + xwayland = 1, + float = 1, + fullscreen = 0, + pin = 0, + }, + no_focus = true, +}) + +require("windowrule") + +-- Host overrides (detect machine by hostname and load matching hosts/.lua) +local hostname = (io.popen("hostname") or {}):read("*l") or "" +hostname = hostname:gsub("%..*$", "") -- strip domain suffix +local ok, err = pcall(require, "hosts." .. hostname) +if not ok then + require("hosts.example") +end diff --git a/hypr/keybindings.lua b/hypr/keybindings.lua new file mode 100644 index 0000000..b45c0bc --- /dev/null +++ b/hypr/keybindings.lua @@ -0,0 +1,38 @@ +-- Keybindings (converted from keybindings.conf) +local P = require("programs") + +hl.bind(P.mainMod .. " + T", hl.dsp.exec_cmd(P.terminal)) +hl.bind(P.mainMod .. " + B", hl.dsp.exec_cmd(P.browser)) +hl.bind(P.mainMod .. " + W", hl.dsp.window.close()) +hl.bind(P.mainMod .. " + SHIFT + M", hl.dsp.exit()) +hl.bind(P.mainMod .. " + E", hl.dsp.exec_cmd(P.fileManager)) +hl.bind(P.mainMod .. " + V", hl.dsp.window.float()) +-- App menu (original was bindr = $mainMod, SUPER_L, exec, $app_menu) +hl.bind(P.mainMod .. " + SUPER_L", hl.dsp.exec_cmd(P.app_menu), { release = true }) +hl.bind("SHIFT + SUPER_L", hl.dsp.exec_cmd(P.menu)) +-- dwindle +hl.bind(P.mainMod .. " + P", hl.dsp.window.pseudo()) +-- dwindle +hl.bind(P.mainMod .. " + J", hl.dsp.layout("togglesplit")) + +hl.bind(P.mainMod .. " + F", hl.dsp.window.fullscreen()) + +-- Screenshot +hl.bind("CTRL + PRINT", hl.dsp.exec_cmd("hyprshot -m active -m output")) +hl.bind("PRINT", hl.dsp.exec_cmd("hyprshot -m window")) +hl.bind("SHIFT + PRINT", hl.dsp.exec_cmd("hyprshot -m region")) + +-- Color picker +hl.bind(P.mainMod .. " + C", hl.dsp.exec_cmd("hyprpicker --autocopy")) + +-- Lock +hl.bind(P.mainMod .. " + L", hl.dsp.exec_cmd("~/.config/hypr/scripts/lock.sh")) +hl.bind(P.mainMod .. " + SHIFT + L", hl.dsp.exec_cmd("wlogout --protocol layer-shell")) + +-- Cheatsheet +hl.bind(P.mainMod .. " + F1", hl.dsp.exec_cmd("~/.config/hypr/scripts/cheatsheet.py ~/.config/hypr/shortcuts.txt")) + +-- OBS +hl.bind(P.mainMod .. " + ALT + TAB", hl.dsp.pass({ window = "class:^(com.obsproject.Studio)$" })) +hl.bind("F1", hl.dsp.pass({ window = "class:^(com.obsproject.Studio)$" })) +hl.bind("F2", hl.dsp.pass({ window = "class:^(com.obsproject.Studio)$" })) diff --git a/hypr/programs.lua b/hypr/programs.lua new file mode 100644 index 0000000..c87fae9 --- /dev/null +++ b/hypr/programs.lua @@ -0,0 +1,14 @@ +-- Shared program variables (converted from programs.conf) +-- Returned as a table so other modules can require() it. +-- NOTE: inner quotes in `terminal` are significant (preserved from the original). + +local P = { + mainMod = "SUPER", + terminal = 'kitty -e zsh -c "fastfetch; exec zsh"', + fileManager = "nautilus", + app_menu = "~/.config/hypr/scripts/launch-tofi.sh", + menu = "~/.config/hypr/scripts/launch-menu.sh", + browser = "librewolf", +} + +return P diff --git a/hypr/windowrule.lua b/hypr/windowrule.lua new file mode 100644 index 0000000..c0123a6 --- /dev/null +++ b/hypr/windowrule.lua @@ -0,0 +1,34 @@ +-- Window rules (converted from windowrule.conf) +local P = require("programs") + +-- LibreWolf Picture-in-Picture +hl.window_rule({ + name = "librewolf-pip", + match = { + class = "(" .. P.browser .. ")", + title = "(Picture-in-Picture)", + }, + float = true, + pin = true, + opacity = "1.0 override 1.0 override", +}) + +-- Cheatsheet +hl.window_rule({ + name = "cheatsheet-window", + match = { class = "net.jeena.Cheatsheet" }, + float = true, + center = true, +}) + +hl.window_rule({ + name = "chromium-ws3", + match = { class = "chromium" }, + workspace = "3 silent", +}) + +hl.window_rule({ + name = "keepassxc-special", + match = { class = "org.keepassxc.KeePassXC" }, + workspace = "special silent", +})