Add Hyprland inactive opacity toggle

This commit is contained in:
2026-05-17 14:53:07 -07:00
parent 0a118d0673
commit 1642626d2a
5 changed files with 36 additions and 0 deletions

View File

@@ -332,6 +332,7 @@ Required behavior:
follows it. This is the target replacement for the older `Super+Shift+h`
binding.
- `Hyper+e` focuses the next empty workspace.
- `Hyper+1` toggles inactive-window opacity reduction for the focused window.
- `Hyper+5` swaps the current workspace with a selected workspace.
- `Hyper+g` gathers windows of the focused class onto the current workspace.

View File

@@ -243,6 +243,7 @@ function M.setup(ctx)
move_to_next_empty_workspace(false)
end, desc("Move window to next empty workspace"))
bind(main_mod .. " + apostrophe", focus_next_class, desc("Focus next window class"))
bind(hyper .. " + 1", toggle_inactive_opacity_for_active_window, desc("Toggle inactive opacity reduction for active window"))
bind(mod_alt .. " + W", show_active_window_info, desc("Show active window info"))
end

View File

@@ -403,6 +403,10 @@ function M.setup(ctx)
border_size = 2,
border_color = "rgba(edb443ff) rgba(ff4d5dcc)",
})
hl.window_rule({
match = { tag = inactive_opacity_override_tag },
opacity = "1.0 override 1.0 override 1.0 override",
})
end
ctx.apply_rules = apply_rules

View File

@@ -42,6 +42,7 @@ return {
[monocle_layout] = "Monocle",
},
minimized_workspace = "special:minimized",
inactive_opacity_override_tag = "no-inactive-opacity",
tabbed_group_restore_workspace_prefix = "special:tabbed-monocle-restore-",
current_layout = columns_layout,
enable_nstack = true,

View File

@@ -355,6 +355,34 @@ function M.setup(ctx)
})
end
local function window_has_tag(window, tag)
for _, value in ipairs((window and window.tags) or {}) do
if tostring(value):gsub("%*$", "") == tag then
return true
end
end
return false
end
local function toggle_inactive_opacity_for_active_window()
local window = hl.get_active_window()
local selector = window_selector(window)
if not selector then
return
end
local disabling_reduction = not window_has_tag(window, inactive_opacity_override_tag)
dispatch(hl.dsp.window.tag({ tag = inactive_opacity_override_tag, window = selector }))
hl.notification.create({
text = "Inactive opacity reduction: " .. (disabling_reduction and "off for window" or "on for window"),
duration = 1600,
icon = notification_icons.info,
color = "rgba(edb443ff)",
font_size = 13,
})
end
local function raise_or_spawn(class_fragment, command)
local fragment = string.lower(class_fragment)
for _, window in ipairs(hl.get_windows()) do
@@ -462,6 +490,7 @@ function M.setup(ctx)
ctx.gather_focused_class = gather_focused_class
ctx.focus_next_class = focus_next_class
ctx.show_active_window_info = show_active_window_info
ctx.toggle_inactive_opacity_for_active_window = toggle_inactive_opacity_for_active_window
ctx.raise_or_spawn = raise_or_spawn
ctx.minimize_active_window = minimize_active_window
ctx.restore_last_minimized = restore_last_minimized