Skip to content

Commit e4cccc5

Browse files
committed
Propagate desktop config updates
1 parent 2d69c14 commit e4cccc5

6 files changed

Lines changed: 106 additions & 20 deletions

File tree

dotfiles/config/hypr/hyprland.lua

Lines changed: 98 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ local window_picker_candidates = {}
3737
local stack_update_timer = nil
3838
local monocle_notice = nil
3939
local scratchpad_pending = {}
40+
local monitor_reserved_cache_path = (os.getenv("XDG_RUNTIME_DIR") or "/tmp") .. "/hyprland-monitor-reserved.tsv"
41+
local scratchpad_fallback_reserved_top = 60
4042

4143
hl.monitor({
4244
output = "eDP-1",
@@ -228,6 +230,7 @@ local function apply_hyprwinview_config()
228230
hover_border_col = "rgba(66ccffee)",
229231
border_size = 3,
230232
window_order = "application",
233+
keys_filter_toggle = "/",
231234
show_app_icon = 1,
232235
app_icon_size = 48,
233236
app_icon_theme_source = "auto",
@@ -240,6 +243,13 @@ local function apply_hyprwinview_config()
240243
app_icon_offset_y = 0,
241244
app_icon_backplate_col = "rgba(00000066)",
242245
app_icon_backplate_padding = 6,
246+
show_window_text = 1,
247+
window_text_font = "Sans",
248+
window_text_size = 14,
249+
window_text_color = "rgba(ffffffff)",
250+
window_text_backplate_col = "rgba(00000099)",
251+
window_text_padding = 6,
252+
filter_animation_ms = 140,
243253
animation = "workspace_zoom",
244254
animation_in_ms = 280,
245255
animation_out_ms = 220,
@@ -262,6 +272,7 @@ local function apply_hyprwinview_config()
262272
bring = { "b", "shift+return", "shift+space" },
263273
bring_replace = { "shift + b" },
264274
close = { "escape", "q" },
275+
filter_toggle = { "/" },
265276
},
266277
})
267278
end
@@ -1199,10 +1210,70 @@ local function logical_monitor_dimension(value, scale)
11991210
return math.floor((value / scale) + 0.5)
12001211
end
12011212

1213+
local function shell_quote(value)
1214+
return "'" .. tostring(value):gsub("'", "'\\''") .. "'"
1215+
end
1216+
1217+
local function split_tsv(line)
1218+
local fields = {}
1219+
for field in (line .. "\t"):gmatch("([^\t]*)\t") do
1220+
fields[#fields + 1] = field
1221+
end
1222+
return fields
1223+
end
1224+
1225+
local function monitor_from_reserved_cache(monitor)
1226+
if verify_config or not monitor or not monitor.name then
1227+
return nil
1228+
end
1229+
1230+
local file = io.open(monitor_reserved_cache_path, "r")
1231+
if not file then
1232+
return nil
1233+
end
1234+
1235+
local cached = nil
1236+
for line in file:lines() do
1237+
local fields = split_tsv(line)
1238+
if fields[1] == monitor.name and #fields >= 10 then
1239+
cached = {
1240+
name = monitor.name,
1241+
x = tonumber(fields[2]),
1242+
y = tonumber(fields[3]),
1243+
width = tonumber(fields[4]),
1244+
height = tonumber(fields[5]),
1245+
scale = tonumber(fields[6]),
1246+
reserved = {
1247+
tonumber(fields[7]),
1248+
tonumber(fields[8]),
1249+
tonumber(fields[9]),
1250+
tonumber(fields[10]),
1251+
},
1252+
}
1253+
break
1254+
end
1255+
end
1256+
file:close()
1257+
return cached
1258+
end
1259+
1260+
local function refresh_monitor_reserved_cache(delay)
1261+
if verify_config then
1262+
return
1263+
end
1264+
1265+
local command = string.format(
1266+
[=[sleep %.2f; cache="${XDG_RUNTIME_DIR:-/tmp}/hyprland-monitor-reserved.tsv"; tmp="$cache.tmp"; /run/current-system/sw/bin/hyprctl -j monitors 2>/dev/null | /run/current-system/sw/bin/jq -r '.[] | [.name, .x, .y, .width, .height, .scale, .reserved[0], .reserved[1], .reserved[2], .reserved[3]] | @tsv' > "$tmp" && mv "$tmp" "$cache"]=],
1267+
as_number(delay, 0)
1268+
)
1269+
hl.exec_cmd("sh -lc " .. shell_quote(command))
1270+
end
1271+
12021272
local function monitor_workarea(monitor)
1273+
monitor = monitor_from_reserved_cache(monitor) or monitor
12031274
local width = logical_monitor_dimension(monitor.width, monitor.scale)
12041275
local height = logical_monitor_dimension(monitor.height, monitor.scale)
1205-
local reserved = monitor.reserved or {}
1276+
local reserved = monitor.reserved or { 0, scratchpad_fallback_reserved_top, 0, 0 }
12061277
local left = math.floor(as_number(reserved[1], 0))
12071278
local top = math.floor(as_number(reserved[2], 0))
12081279
local right = math.floor(as_number(reserved[3], 0))
@@ -1331,6 +1402,22 @@ local function hide_active_scratchpads(except_name)
13311402
end
13321403
end
13331404

1405+
local function refresh_active_scratchpad_geometries()
1406+
local monitor = hl.get_active_monitor()
1407+
for _, active in ipairs(active_scratchpad_windows()) do
1408+
schedule_scratchpad_geometry(active.name, active.window, monitor)
1409+
end
1410+
end
1411+
1412+
local function refresh_active_scratchpad_geometries_later(timeout)
1413+
hl.timer(refresh_active_scratchpad_geometries, { timeout = timeout or 300, type = "oneshot" })
1414+
end
1415+
1416+
local function refresh_shell_workarea_and_scratchpads()
1417+
refresh_monitor_reserved_cache(0.15)
1418+
refresh_active_scratchpad_geometries_later(400)
1419+
end
1420+
13341421
local function adopt_matching_scratchpad_window(window)
13351422
if not window then
13361423
return
@@ -1884,6 +1971,7 @@ bind(main_mod .. " + E", exec("emacsclient --eval '(emacs-everywhere)'"))
18841971
bind(main_mod .. " + V", exec("wl-paste | xdotool type --file -"))
18851972
bind(main_mod .. " + Tab", hyprwinview("toggle"))
18861973
bind(main_mod .. " + SHIFT + Tab", hyprwinview("toggle other-workspaces"))
1974+
bind(main_mod .. " + SHIFT + slash", hyprwinview("toggle filter"))
18871975
bind("ALT + Tab", hyprexpo("toggle"))
18881976
bind("ALT + SHIFT + Tab", hyprexpo("bring"))
18891977
bind(main_mod .. " + G", exec(shell_ui_command .. " window go"))
@@ -2036,9 +2124,6 @@ end)
20362124
bind(mod_alt .. " + grave", function()
20372125
toggle_scratchpad("dropdown")
20382126
end)
2039-
bind(mod_alt .. " + C", function()
2040-
raise_or_spawn("google-chrome", "google-chrome-stable")
2041-
end)
20422127
bind(mod_alt .. " + Space", minimize_other_classes)
20432128
bind(mod_alt .. " + SHIFT + Space", restore_focused_class)
20442129
bind(mod_alt .. " + Return", restore_all_minimized)
@@ -2088,12 +2173,16 @@ bind("XF86MonBrightnessDown", exec("brightness.sh down"), { repeating = true })
20882173
bind(hyper .. " + V", exec([[cliphist list | rofi -dmenu -p "Clipboard" | cliphist decode | wl-copy]]))
20892174
bind(hyper .. " + P", exec("rofi-pass"))
20902175
bind(hyper .. " + H", exec([[grim -g "$(slurp)" - | swappy -f -]]))
2091-
bind(hyper .. " + C", exec("shell_command.sh"))
2176+
bind(hyper .. " + C", exec("rofi_tmcodex.sh"))
20922177
bind(hyper .. " + SHIFT + L", exec("hyprlock"))
20932178
bind(hyper .. " + K", exec("rofi_kill_process.sh"))
20942179
bind(hyper .. " + SHIFT + K", exec("rofi_kill_all.sh"))
20952180
bind(hyper .. " + R", exec("rofi-systemd"))
2096-
bind(hyper .. " + slash", exec("toggle_taffybar"))
2181+
bind(hyper .. " + slash", function()
2182+
hl.exec_cmd("toggle_taffybar")
2183+
refresh_monitor_reserved_cache(0.25)
2184+
refresh_active_scratchpad_geometries_later(600)
2185+
end)
20972186
bind(hyper .. " + I", exec("rofi_select_input.hs"))
20982187
bind(hyper .. " + backslash", exec("/home/imalison/dotfiles/dotfiles/lib/functions/mpg341cx_input toggle"))
20992188
bind(hyper .. " + SHIFT + backslash", workspacehistory("debug"))
@@ -2117,12 +2206,15 @@ hl.on("hyprland.start", function()
21172206
hl.exec_cmd("wl-paste --type image --watch cliphist store")
21182207
write_layout_state()
21192208
schedule_nstack_count_update()
2209+
refresh_monitor_reserved_cache(0.25)
2210+
refresh_monitor_reserved_cache(1.25)
21202211
end)
21212212

21222213
hl.on("config.reloaded", apply_nstack_config)
21232214
hl.on("config.reloaded", apply_hyprexpo_config)
21242215
hl.on("config.reloaded", apply_hyprwinview_config)
21252216
hl.on("config.reloaded", apply_rules)
2217+
hl.on("config.reloaded", refresh_shell_workarea_and_scratchpads)
21262218

21272219
hl.on("window.open", schedule_nstack_count_update)
21282220
hl.on("window.destroy", schedule_nstack_count_update)

dotfiles/config/taffybar/flake.lock

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dotfiles/config/xmonad/xmonad.hs

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,6 @@ virtualClasses =
250250

251251
-- Commands
252252

253-
chromeCommand = "google-chrome-stable"
254253
elementCommand = "element-desktop"
255254
emacsCommand = "emacsclient -c"
256255
htopCommand = "ghostty --title=htop -e htop"
@@ -1004,11 +1003,6 @@ addKeys conf@XConfig { modMask = modm } =
10041003
buildDirectionalBindings
10051004
(hyper .|. shiftMask) (followingWindow . (`screenSwap` True)) ++
10061005

1007-
-- Specific program spawning
1008-
bindBringAndRaiseMany
1009-
[ (modalt, xK_c, spawn chromeCommand, chromeSelector)
1010-
] ++
1011-
10121006
-- ScratchPads
10131007
[ ((modalt, xK_e), doScratchpad "element")
10141008
, ((modalt, xK_h), doScratchpad "htop")
@@ -1072,7 +1066,7 @@ addKeys conf@XConfig { modMask = modm } =
10721066
, ((hyper, xK_v), spawn "rofi -modi 'clipboard:greenclip print' -show clipboard")
10731067
, ((hyper, xK_p), spawn "rofi-pass")
10741068
, ((hyper, xK_h), spawn "rofi_shutter")
1075-
, ((hyper, xK_c), spawn "shell_command.sh")
1069+
, ((hyper, xK_c), spawn "rofi_tmcodex.sh")
10761070
, ((hyper .|. shiftMask, xK_l), spawn "dm-tool lock")
10771071
, ((hyper, xK_l), selectLayout)
10781072
, ((hyper, xK_k), spawn "rofi_kill_process.sh")

nixos/flake.lock

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

nixos/flake.nix

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -532,7 +532,7 @@
532532
} ''
533533
cp ${../dotfiles/config/hypr/hyprland.lua} hyprland.lua
534534
luac -p hyprland.lua
535-
if grep -n 'hyprctl' hyprland.lua | grep -v 'hyprctl reload' | grep -v 'hyprctl dispatch hyprwinview:overview'; then
535+
if grep -n 'hyprctl' hyprland.lua | grep -v 'hyprctl reload' | grep -v 'hyprctl dispatch hyprwinview:overview' | grep -v 'hyprctl -j monitors'; then
536536
echo "hyprland.lua should not shell out to hyprctl for window/workspace manipulation" >&2
537537
exit 1
538538
fi

0 commit comments

Comments
 (0)