quickshell-dots
quickshell-dots copied to clipboard
feat: persist Control panel state across restarts
Currently the bar resets all Control panel settings on every restart (splits, animation mode, bar color). This adds automatic persistence to ~/.cache/quickshell_splits so the state survives restarts with no extra dependencies.
What's saved
- All 4 splits (Status / Left / Right / Network)
- Bar animation mode (Stream / Surge / Bolt)
- Bar color source (Red / Accent)
How it works
- On startup: reads the cache file and restores state before marking
_splitsLoaded = true(prevents saving during load) - On any toggle: an
onXChangedhandler writes the new state immediately via a one-shot bashecho - File format:
splitArch splitMon splitMprisL splitNet barAnim useThemeAccent(space-separated, e.g.1 0 1 0 2 0) - If the file doesn't exist (first run), defaults apply as usual
Changes
Theme.qml only — adds ~35 lines (2 Process blocks + change handlers + save function).
// ── Split persistence ──
readonly property string splitsCachePath: Quickshell.env("HOME") + "/.cache/quickshell_splits"
property bool _splitsLoaded: false
onSplitArchChanged: if (_splitsLoaded) saveSplits()
onSplitMonChanged: if (_splitsLoaded) saveSplits()
onSplitNetChanged: if (_splitsLoaded) saveSplits()
onSplitMprisLChanged: if (_splitsLoaded) saveSplits()
onBarAnimChanged: if (_splitsLoaded) saveSplits()
onUseThemeAccentChanged: if (_splitsLoaded) saveSplits()
function saveSplits() {
splitSaveProc.running = false
splitSaveProc.running = true
}
Process {
id: splitLoadProc
command: ["cat", theme.splitsCachePath]
running: true
stdout: StdioCollector {
onStreamFinished: {
var parts = this.text.trim().split(" ")
if (parts.length >= 5) {
theme.splitArch = parts[0] === "1"
theme.splitMon = parts[1] === "1"
theme.splitMprisL = parts[2] === "1"
theme.splitNet = parts[3] === "1"
theme.barAnim = parseInt(parts[4]) || 0
theme.useThemeAccent = parts.length >= 6 && parts[5] === "1"
}
theme._splitsLoaded = true
}
}
}
Process {
id: splitSaveProc
command: ["bash", "-c",
"echo '" +
(theme.splitArch ? "1" : "0") + " " +
(theme.splitMon ? "1" : "0") + " " +
(theme.splitMprisL ? "1" : "0") + " " +
(theme.splitNet ? "1" : "0") + " " +
theme.barAnim + " " +
(theme.useThemeAccent ? "1" : "0") +
"' > '" + theme.splitsCachePath + "'"]
}
Implemented — thanks for the well-scoped proposal. Shipped in 3940011 (+ hardening in 213bc54).
Notes on the implementation:
- Kept it on the
Process+cat/echoapproach (dependency-free, matches the rest of the codebase) rather thanFileView. - One change vs. the proposal was necessary: the save command must be built imperatively inside
saveSplits(), not as a boundcommand:property. With a binding, theProcesscould run before the binding re-evaluated and persist the pre-toggle state (e.g. setting a split saved0 0 0 0 0 0). Building the string at call time reads the already-committed values. - Hardening:
mkdir -pthe cache dir (so a missing~/.cachedoes not silently drop persistence) and clampbarAnimto 0–3 on load. Verified the file is overwrite-only (never grows, ~12 B), and that empty/corrupt/partial content falls back to defaults without crashing.
Closing as done.