Add init --sync and --prune for incremental monitor setup

`init` planned every file on every run and refused if any of them
existed, so attaching a new monitor could not be configured without
--force — which reallocated global workspace numbers by i3's current
output order and renumbered the monitors already in use.

- allocate_global_starts() keeps the block each known output already
  holds and gives new outputs the lowest free block; blocks of inactive
  outputs stay reserved.
- read_allocations()/parse_allocation() read those blocks back out of
  the generated files (inverse of render_workspaces_for_output).
- --sync writes only the missing files, --prune drops configs for
  outputs that are gone and frees their numbers.
- Files without the auto-generated header are never written or
  deleted, --force included.

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Asger Weirsøe
2026-08-11 12:58:05 +02:00
co-authored by Claude
parent 8bbf7b8fbe
commit fa1de7fe16
4 changed files with 535 additions and 18 deletions
+1 -1
View File
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
[project]
name = "pi3-smart-workspace"
version = "0.2.0"
version = "0.3.0"
description = "Switch i3 workspaces based on which output your mouse cursor is on."
readme = "README.md"
requires-python = ">=3.14"