Window Manager Central
EN ES FR

Hyprland

Hyprland is the most popular compositor out there and it really shows why, it has 4 built-in layouts, animations, special workspaces and more.

Disable window focus fallback when reaching the end of a monitor: §

lua
hl.config{(
	general = {
		no_focus_fallback = true
	}
)}

Click Passthrough in Special Workspaces §

lua
hl.config({
	input = {
		special_fallthrough = true,
	}
})

Hide special workspaces when focusing a normal workspace: §

lua
hl.config({
	binds = {
		hide_special_on_workspace_change = true,
	}
})

Remove default wallpaper and nags: §

lua
hl.config({
	misc = {
		disable_hyprland_logo = true,
	},

	ecosystem = {
		no_update_news = true,
		no_donation_nag = true,
	}
})

Focus Window on Activation Request: §

lua
hl.config({
	misc = {
		focus_on_activate = true,
	}
})

Color Code Window State: §

lua
hl.window_rule({
	name  = "pinned",
	match = { pin = true },
	border_color = yellow .. " " ..  yellow_dim,
})

hl.window_rule({
	name  = "maximized",
	match = { fullscreen_state_internal = 1},
	border_color = cyan .. " " ..  cyan_dim,
})

hl.window_rule({
	name  = "highlight_special",
	match = { workspace = "s[1]" },
	border_color = blue .. " " ..  blue_dim,
})

In this case we give pinned windows a yellow color, maximized windows cyan, and blue for windows in special workspaces as well as their respetive dimmed color for when they are unfocused.

Cycle Windows When in Fullscreen State §

lua
hl.config({
	binds = {
		movefocus_cycles_fullscreen = true,
	}
})

Define settings and toggle them: §

lua
local closeWindowBind = hl.bind(
	mm .. " + c",
	hl.dsp.window.close()
)

closeWindowBind:set_enabled(false)

Set keybinds for workspace management in one go: §

lua
for i = 1, 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, follow = true })
	)

	hl.bind(
		mainMod .. " + CTRL + " .. key,
		hl.dsp.window.move({ workspace = i, follow = false })
	)
end

Float stubborn windows(dynamic rules): §

Extensions like password managers and others very often need to span a new browser window, with Firefox one can’t simply use a normal rule to make these float because Firefox renames the title of the window after it spawns. For this reason we make the following event function.

lua
hl.on("window.title", function(w)
	if string.find(w.title, "Extension: (AliasVault)", nil, true ) then
		local monitor = hl.get_active_monitor()
		if monitor == nil then
			return
		end

		local win_size = {
			width = 500,
			height = 800
		}
		local win_pos = {
			x = monitor.width * 0.5 - win_size.width * 0.5,
			y = monitor.height * 0.5 - win_size.height * 0.5,
		}

		hl.dispatch(
			hl.dsp.window.float({
				action = "enable",
				window = w
			})
		)
		hl.dispatch(
			hl.dsp.window.resize({
				x = win_size.width,
				y = win_size.height,
				relative = false,
				window = w
			})
		)
		hl.dispatch(
			hl.dsp.window.move({
				x = win_pos.x,
				y = win_pos.y,
				relative = false,
				window = w
			})
		)
	end
end)

Avoid repetition on setting special workspace keybinds: §

lua
local function specialWorkspaceKeybind(name, key)
	hl.bind(
		M .. "+" .. key,
		hl.dsp.workspace.toggle_special(name)
	)
	hl.bind(
		M .. "+SHIFT+" .. key,
		hl.dsp.window.move({ workspace = "special:" .. name })
	)
	hl.bind(
		M .. "+CTRL+" .. key,
		hl.dsp.window.move({ workspace = "special:" .. name, follow = false })
	)
end

specialWorkspaceKeybind("quickterm", "i")
specialWorkspaceKeybind("calc", "h")
specialWorkspaceKeybind("matrix", "u")

Close all windows: §

lua
local function closeAllWindows()
	local windows = hl.get_windows()

	for _,w in pairs(windows) do
		hl.dispatch(hl.dsp.window.close({ window = w }))
	end
end

-- Probably add another mod key for safety reasons.
hl.bind(M .. "+Delete", closeAllWindows )

Close all windows in current workspace: §

lua
local function closeAllWindowCurrentWorkspace()
	local cws = hl.get_active_workspace()
	local windows = hl.get_windows({ workspace = cws })

	for _,w in pairs(windows) do
		hl.dispatch(hl.dsp.window.close({ window = w }))
	end
end

hl.bind(M .. "+BackSpace", closeAllWindowCurrentWorkspace )

Fix MPV Content Type §

When toggling fullscreen on a mpv window the screen goes black for some seconds, to fix this use the following rule:

lua
hl.window_rule({
	name  = "mpv_content_type",
	match = { class = "mpv" },
	content = "none"
})