hyprland: migrate to Lua config, add pc/laptop profiles
hyprlang has been deprecated since Hyprland 0.55 and is dropped after 1-2 releases; this box runs 0.56.2. Migrate Hyprland's own config to Lua and split the machine-specific parts into profiles. Config: - hyprland.lua entry point; the .conf tree is left in place as a rollback path (Hyprland prefers hyprland.lua and only decides at startup). - Each require() is its own Lua scope, so hyprlang's global "$VAR" no longer crosses files: vars.lua / apps.lua / theme/colors.lua return tables. - hypridle, hyprlock, plugins/* and pyprland.toml stay hyprlang -- the other hypr* tools keep it. Profiles (configs/profiles/): - pc -> DP-1 / HDMI-A-1 / DP-2, all 1920x1080 - laptop -> eDP-1 3072x1920@120 scale 2.0, DP-1, HDMI-A-1 mirroring eDP-1 - Each owns its monitors and workspace-to-monitor mapping; common.lua generates the 30 workspace rules from the three outputs. - Selected by $HYPR_PROFILE, else hostname (mainPC -> pc), else laptop. Fixes: - pyprland.toml called swww, which is not installed; the wallpaper backend here is awww. The rotation timer failed silently and both outputs stayed at color: 000000. - XF86InputRaiseVolume / XF86InputLowerVolume are not real keysyms (no XF86Input* family in xkbcommon). They were dead in .conf too; hyprlang ignored them silently, hl.bind rejects them. Commented out. - SUPER+SHIFT+R was bound twice (notification reload + bar reload). hyprlang ran both; in Lua the second would shadow the first, so they are merged. - The waybar layer rule set no effects and was a no-op; dropped. - Polkit autostart now picks hyprpolkitagent or polkit-gnome by what is installed, so one file works on both machines. Verified with `Hyprland --verify-config` on both profiles (config ok). Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01StGBghPW9Dm7z7uj2VNWHr
This commit is contained in:
31
hypr/configs/profiles/common.lua
Normal file
31
hypr/configs/profiles/common.lua
Normal file
@@ -0,0 +1,31 @@
|
||||
-- Shared profile logic: given three outputs, lay out the 30 workspaces.
|
||||
--
|
||||
-- 1-10 -> MONITOR1, 11-20 -> MONITOR2, 21-30 -> MONITOR3.
|
||||
-- The first workspace of each block is that monitor's default.
|
||||
-- Was: configs/workspaces.conf (byte-identical on both machines, because it
|
||||
-- only ever referred to $MONITOR1/2/3).
|
||||
|
||||
local M = {}
|
||||
|
||||
function M.workspaces(monitors)
|
||||
local blocks = {
|
||||
{ first = 1, last = 10, monitor = monitors[1] },
|
||||
{ first = 11, last = 20, monitor = monitors[2] },
|
||||
{ first = 21, last = 30, monitor = monitors[3] },
|
||||
}
|
||||
|
||||
for _, block in ipairs(blocks) do
|
||||
for ws = block.first, block.last do
|
||||
hl.workspace_rule({
|
||||
workspace = tostring(ws),
|
||||
monitor = block.monitor,
|
||||
default = (ws == block.first),
|
||||
})
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- Gaming workspaces (10 / 20 / 30) had these commented out in workspaces.conf:
|
||||
-- no_rounding = true, decorate = false, gaps_in = -1, gaps_out = 0, no_border = true
|
||||
|
||||
return M
|
||||
35
hypr/configs/profiles/init.lua
Normal file
35
hypr/configs/profiles/init.lua
Normal file
@@ -0,0 +1,35 @@
|
||||
-- Machine profile selection.
|
||||
--
|
||||
-- Each profile owns the two things that genuinely differ between machines:
|
||||
-- the monitor layout and the workspace-to-monitor assignment.
|
||||
--
|
||||
-- Selection order:
|
||||
-- 1. $HYPR_PROFILE, if set (e.g. `HYPR_PROFILE=laptop Hyprland`)
|
||||
-- 2. hostname match
|
||||
-- 3. fallback: "laptop"
|
||||
--
|
||||
-- To add a machine: create configs/profiles/<name>.lua and add it to `byHost`.
|
||||
|
||||
local byHost = {
|
||||
mainPC = "pc",
|
||||
}
|
||||
|
||||
local fallback = "laptop"
|
||||
|
||||
local function hostname()
|
||||
-- Cheap file read at config-load time (not in a bind callback, so it is
|
||||
-- safe to block on). os.getenv("HOSTNAME") is not reliably exported.
|
||||
local f = io.open("/etc/hostname")
|
||||
if not f then return nil end
|
||||
local h = f:read("l")
|
||||
f:close()
|
||||
-- strip stray whitespace
|
||||
return h and h:match("^%s*(.-)%s*$") or nil
|
||||
end
|
||||
|
||||
local host = hostname()
|
||||
local profile = os.getenv("HYPR_PROFILE") or byHost[host] or fallback
|
||||
|
||||
require("configs.profiles." .. profile)
|
||||
|
||||
return { name = profile, host = host }
|
||||
22
hypr/configs/profiles/laptop.lua
Normal file
22
hypr/configs/profiles/laptop.lua
Normal file
@@ -0,0 +1,22 @@
|
||||
-- Profile: laptop
|
||||
-- Internal hidpi panel plus two external 1080p outputs.
|
||||
-- Was: the committed configs/monitors.conf in the dotfiles repo.
|
||||
|
||||
local common = require("configs.profiles.common")
|
||||
|
||||
local MONITOR1 = "eDP-1" -- internal panel
|
||||
local MONITOR2 = "DP-1" -- second
|
||||
local MONITOR3 = "HDMI-A-1" -- third
|
||||
|
||||
-- Main Monitor
|
||||
hl.monitor({ output = MONITOR1, mode = "3072x1920@120.00", position = "0x0", scale = 2.0, vrr = 1 })
|
||||
|
||||
-- Second Monitor
|
||||
hl.monitor({ output = MONITOR2, mode = "1920x1080@60.00", position = "0x1920", scale = 1.0 })
|
||||
-- FSIT: position = "-1920x-800"
|
||||
-- mirror = MONITOR1
|
||||
|
||||
-- Third Monitor
|
||||
hl.monitor({ output = MONITOR3, mode = "1920x1080@60.00", position = "0x1920", scale = 1.0, mirror = MONITOR1 })
|
||||
|
||||
common.workspaces({ MONITOR1, MONITOR2, MONITOR3 })
|
||||
24
hypr/configs/profiles/pc.lua
Normal file
24
hypr/configs/profiles/pc.lua
Normal file
@@ -0,0 +1,24 @@
|
||||
-- Profile: pc (hostname "mainPC")
|
||||
-- Three 1080p outputs, no internal panel.
|
||||
-- Was: the live ~/.config/hypr/configs/monitors.conf on this machine.
|
||||
|
||||
local common = require("configs.profiles.common")
|
||||
|
||||
local MONITOR1 = "DP-1" -- main
|
||||
local MONITOR2 = "HDMI-A-1" -- second
|
||||
local MONITOR3 = "DP-2" -- third
|
||||
|
||||
-- Main Monitor
|
||||
hl.monitor({ output = MONITOR1, mode = "1920x1080@120.00", position = "0x0", scale = 1.0 })
|
||||
-- add vrr = 1 to the above if wanted
|
||||
|
||||
-- Second Monitor
|
||||
hl.monitor({ output = MONITOR2, mode = "1920x1080@60.00", position = "-1920x280", scale = 1.0 })
|
||||
-- FSIT Arbeitsplatz: position = "-1920x-800"
|
||||
-- mirror = MONITOR3
|
||||
|
||||
-- Third Monitor
|
||||
hl.monitor({ output = MONITOR3, mode = "1920x1080@60.00", position = "0x1920", scale = 1.0 })
|
||||
-- mirror = MONITOR1
|
||||
|
||||
common.workspaces({ MONITOR1, MONITOR2, MONITOR3 })
|
||||
Reference in New Issue
Block a user