dustack — which subdirectories grew since the snapshot
dustack is a LightGUI (Python/XFrame) port of the dustack utility from util_box: show which subdirectories grew most since the last snapshot — a growth tracker, not just du. Take a snapshot of a directory's sizes, come back later, and it ranks the subdirectories by growth in bytes and percent, so you see what actually grew instead of what is merely big. It is one of the 285 apps in util_boxgui, the project recreating util_box utilities as LightGUI apps, each with a screenshot and a walkthrough on the matching LightGUI doc site. The full source is apps/python/dustack/dustack.py in that repo.
The comparison is already run when the app starts, so a plain launch + screenshot shows a real growth table. The default directory is a demo tree, /tmp/dustack-demo: on first launch the tree is created (a/ 300 B, b/ 500 B, c/ 50 B), a snapshot is taken, the tree is grown (a/ +900 B, b/ −50 B — mirroring the CLI self-test), and the comparison is shown. The screenshot below is the default state, not a staged one.
The GUI layout

The window is 800×560 and holds six widgets, created with create() + set_prop() and drawn on a single Gtk.DrawingArea:
- Directory: a
GtkLabeland aGtkEntryholding the directory to track, pre-filled with/tmp/dustack-demo. Click the entry to focus it (a blue outline appears), then type — BackSpace deletes, Escape drops focus. - Snapshot: a
GtkButtonthat saves a snapshot of every immediate subdirectory's size + file count as<dir>/.dustack.json. - Compare: a
GtkButtonthat ranks subdirectories by growth (bytes and %) since the snapshot, with a table of directory, growth, percent, current size, and file-count change. Enter re-runs the comparison, too. - Hint line: a
GtkLabelexplaining that Snapshot saves sizes and Compare ranks growth since the snapshot. - Result area: a
GtkTextViewfilling the rest of the window, showing the growth table. It is read-only — clicking it just drops the entry's focus.
Two honest limitations, both inherited from how LightGUI draws its widgets with Cairo on one drawing area: there is no native GTK focus, so this app wires focus and typing itself; and the result area does not really scroll — the text-view scroll bars are drawn, not functional, so a directory with more subdirs than fit the window clips at the bottom (the top 10 are shown). Type any other directory to use it instead; there the app behaves exactly like the CLI.
One row deserves a word of its own: the . row, 296 B, marked "new". That is not a subdirectory — it is the snapshot file itself. The snapshot (.dustack.json, 296 B) is written into the directory after the snapshot is taken, so on the compare run it shows up as a brand-new file in the root. It is the CLI's behaviour too, and a reminder that the tracker watches everything in the directory, including its own bookkeeping:
growth since 2026-12-06 07:00 (0.0 days ago), root /tmp/dustack-demo
DIR GROWTH % NOW FILES +/-
a +900 B +300.0% 1.2 KiB +1
. +296 B new 296 B +1
b -50 B -10.0% 450 B -1
c 0 B +0.0% 50 B +0A real bug was found and fixed while testing: the demo tree was not created when the directory did not exist yet, because the is_dir check ran before ensure_demo. The check now creates the demo tree first — the kind of thing the CLI-equivalence check is for, since a mismatch means a bug in one of them.
The source, in sections
dustack.py is about 426 lines. It is modelled on the LightGUI Python examples gtkentry.py, gtkbutton.py and gtktextview.py (and the datecalc app in this repo): widgets are created with create() + set_prop(), drawn on a Gtk.DrawingArea by widget.draw(cr), hit-tested on click, and dispatched through a _HANDLERS table. The snapshot and comparison half is vendored verbatim from the CLI, so the GUI can never drift from it.
The snapshot and the table. snapshot_tree(), dir_size(), human() and compare_text() are copied byte-for-byte from the CLI script into dustack.py. A snapshot records each immediate subdirectory's size + file count (files directly in the root go under .) as JSON, with the root path and the time. The comparison re-snapshots, diffs each directory against the old snapshot, and sorts by absolute growth, descending — so the biggest mover is on top whether it grew or shrank. A brand-new directory shows "new" instead of a percent, and a directory that vanished shows as "(gone)" with −100%:
def compare_text(root, top=10):
"""The growth table for *root*, exactly as the CLI prints it."""
root = Path(root)
snapfile = root / ".dustack.json"
if not snapfile.exists():
return None
now = snapshot_tree(root)
old = load(snapfile)
age = time.time() - old.get("time", now["time"])
lines = [f"growth since {time.strftime('%Y-%m-%d %H:%M', time.localtime(old.get('time', 0)))} ({age/86400:.1f} days ago), root {old.get('root')}"]
rows = []
for name, cur in now["dirs"].items():
o = old.get("dirs", {}).get(name, {"bytes": 0, "files": 0})
d = cur["bytes"] - o["bytes"]
pct = (d / o["bytes"] * 100) if o["bytes"] else (float("inf") if d > 0 else 0.0)
rows.append((name, d, pct, cur["bytes"], cur["files"] - o["files"]))
for name in old.get("dirs", {}):
if name not in now["dirs"]:
rows.append((name + " (gone)", -old["dirs"][name]["bytes"], -100.0, 0, -old["dirs"][name]["files"]))
rows.sort(key=lambda r: -abs(r[1]))
lines.append(f"{'DIR':<20} {'GROWTH':>12} {'%':>8} {'NOW':>12} {'FILES +/-':>10}")
for name, d, pct, cur, df in rows[:top]:
ps = f"{pct:+.1f}%" if pct != float("inf") else "new"
lines.append(f"{name:<20} {human(d) if d>=0 else '-'+human(-d):>12} {ps:>8} {human(cur):>12} {df:+d}")
return "\n".join(lines)compute_text() is the GUI's own half: it takes the directory and the action ("snapshot" is the CLI's --snapshot step, "compare" is the default step). On the demo tree at first launch it builds the tree, snapshots it, grows it, then compares — the CLI's two steps back to back. On any other directory with no snapshot it saves one and says to run again later; with a snapshot it shows the table. A directory that does not exist shows an error line instead of the CLI's exit code 2.
The widgets. _build_widgets() creates the six widgets with their design-time geometry, and an _ANCHORS table records each widget's anchor flags so _apply_anchors() can reposition them when the window is resized — recomputed from the design geometry every time, so a resize is idempotent and never drifts. The output area is created already holding the comparison, so the window opens populated.
Events. LightGUI draws the widgets with Cairo, so there is no native GTK focus to rely on — the app wires it itself. Clicking the entry focuses it; typing goes to the focused entry through a window-level key-press handler, which appends printable characters, handles BackSpace and Delete, and re-runs the comparison on every keystroke (and on Return). Clicking Snapshot takes a snapshot and drops focus; clicking Compare shows the growth table and drops focus. Clicking the output area just drops focus. The dispatch is a small hit-test: the topmost visible widget containing the click gets the event through the _HANDLERS table, and a button release always goes to the widget that got the press. main() is the standard LightGUI Python harness: a Gtk.Window titled dustack - util_boxgui holding a Gtk.DrawingArea, with the draw, button-press, button-release and resize signals connected, and Gtk.main() running the loop.
Building and running it
There is nothing to build — it is pure Python. Run it with the LightGUI Python package on PYTHONPATH, under a real X server or under Xvfb (display :97 is the one used for this app). It needs python3-gi / gir1.2-gtk-3.0 and the LightGUI Python checkout:
cd apps/python/dustack
PYTHONPATH=/root/graphfix-wt/lightgui_python python3 dustack.py
# Under Xvfb:
Xvfb :97 -screen 0 1024x768x24 &
DISPLAY=:97 PYTHONPATH=/root/graphfix-wt/lightgui_python python3 dustack.pyThe PYTHONPATH above points at the clean graphfix-wt checkout on the build machine — the usual /root/lg-review/lightgui_python checkout is mid-merge as of this writing, so batch 5 was built against the clean one. On your own machine, point it at wherever you cloned LightGUI Python. The window title is dustack - util_boxgui. The CLI equivalent is dustack --snapshot DIR followed later by dustack DIR.
What the CLI version does differently
Same snapshot, same table, same sort order — and the differences are all about the medium. The CLI is dustack [dir] [--snapshot [file]] [--compare [file]] [--top N] [--selftest] and prints to stdout; the GUI shows the table in the result area. The GUI has no --compare file option (it always uses <dir>/.dustack.json) and no --top option (top 10, the CLI default). The CLI prints once and exits; the GUI stays open and re-compares on every keystroke. Verified on the same input: the demo tree's growth table (a +900 B +300.0%, b −50 B −10.0%, c 0, . 296 B new) matches the CLI exactly.
See also
- util_boxgui — the project this app belongs to: all 285 apps, with screenshots
- dustack.py — the full source
- dustack — the util_box CLI this ports
- XFrame widgets
- All 562 Python widgets