fix(i3): window startup

This commit is contained in:
AquaAI 2026-07-26
2026-07-26 17:15:20 -04:00
parent 1960e0ed57
commit fe212c0a92
5 changed files with 65 additions and 24 deletions
+29
View File
@@ -0,0 +1,29 @@
#!/bin/bash
# Restore Brave and place its windows after they finish opening.
preferences="$HOME/.config/BraveSoftware/Brave-Browser/Default/Preferences"
function enable_session_restore {
if [ ! -f "$preferences" ] || ! command -v jq &> /dev/null; then
return
fi
temp_file="$(mktemp "${preferences}.XXXXXX")"
if jq '.session.restore_on_startup = 1 | .profile.exit_type = "Normal"' \
"$preferences" > "$temp_file"; then
mv "$temp_file" "$preferences"
else
rm -f "$temp_file"
fi
}
enable_session_restore
i3-msg 'workspace 9; append_layout ~/.config/i3/brave-workspace-9.json; workspace 5'
brave-browser --restore-last-session &
# Brave creates restored windows asynchronously and after startup focus has moved.
for _ in {1..20}; do
sleep 0.5
i3-msg '[class="^Brave-browser$" workspace="^(?!9$).*"] move to workspace 5' \
> /dev/null
done