Move config out of the plugin dir so edits don't reload the plugin

The shell watches every file under ~/.config/omarchy/plugins/ with
inotify (no extension filter) and reloads all plugin code on any change,
so config.json there made every edit tear down and rebuild the panel and
bar widget. Config now lives at ~/.config/omarchy/key-visualizer.json, which
is not watched: edits update the display live. The panel migrates the
old plugin-dir config (values carried over, file removed) on first load
after the update.
This commit is contained in:
felixzsh
2026-08-11 13:42:24 -05:00
parent c0d491db29
commit 5670aca888
3 changed files with 25 additions and 14 deletions
+20 -11
View File
@@ -42,11 +42,15 @@ Item {
property int margin: Style.space(67) property int margin: Style.space(67)
readonly property var modLabels: ["Super", "Ctrl", "Alt", "Shift", "Menu", "AltGr"] readonly property var modLabels: ["Super", "Ctrl", "Alt", "Shift", "Menu", "AltGr"]
property var manifest: ({}) // Options live at ~/.config/omarchy/key-visualizer.json rather than inside the
readonly property string configPath: { // plugin folder on purpose: the shell watches every file under
var dir = root.manifest && root.manifest.__sourceDir ? root.manifest.__sourceDir : "" // ~/.config/omarchy/plugins/ and reloads all plugin code on any change, so
return dir ? dir + "/config.json" : "" // a config edit there would tear down and rebuild the panel. Editing this
} // file updates the display live.
readonly property string configPath: Quickshell.env("HOME") + "/.config/omarchy/key-visualizer.json"
// Pre-1.3.1 config lived in the watched plugin dir; migrated once on first
// load after the move.
readonly property string legacyConfigPath: Quickshell.env("HOME") + "/.config/omarchy/plugins/felixzsh.key-visualizer/config.json"
readonly property string statePath: { readonly property string statePath: {
var runtime = Quickshell.env("XDG_RUNTIME_DIR") var runtime = Quickshell.env("XDG_RUNTIME_DIR")
@@ -184,15 +188,20 @@ Item {
if (isFinite(cfg.lingerMs) && cfg.lingerMs >= 0) root.lingerMs = Math.round(cfg.lingerMs) if (isFinite(cfg.lingerMs) && cfg.lingerMs >= 0) root.lingerMs = Math.round(cfg.lingerMs)
} }
function seedConfig() { function migrateConfig() {
// First load with the new location: carry over values from the old
// plugin-dir config (if any) and remove it, or seed the defaults.
var defaults = '{"mode": "all", "position": "bottom-center", "margin": 67, "lingerMs": 1000}' var defaults = '{"mode": "all", "position": "bottom-center", "margin": 67, "lingerMs": 1000}'
seedConfigProc.command = ["sh", "-c", migrateProc.command = ["sh", "-c",
"printf '%s\\n' '" + defaults + "' > " + Util.shellQuote(root.configPath)] "if [ -f " + Util.shellQuote(root.legacyConfigPath) + " ]; then "
seedConfigProc.running = true + "cp " + Util.shellQuote(root.legacyConfigPath) + " " + Util.shellQuote(root.configPath) + "; "
+ "rm -f " + Util.shellQuote(root.legacyConfigPath) + "; "
+ "else printf '%s\\n' '" + defaults + "' > " + Util.shellQuote(root.configPath) + "; fi"]
migrateProc.running = true
} }
Process { Process {
id: seedConfigProc id: migrateProc
} }
property bool configSeeded: false property bool configSeeded: false
@@ -209,7 +218,7 @@ Item {
// shell injects `manifest` after instantiation, which re-fires this. // shell injects `manifest` after instantiation, which re-fires this.
if (!root.configSeeded) { if (!root.configSeeded) {
root.configSeeded = true root.configSeeded = true
if (root.configPath !== "" && text() === "") root.seedConfig() if (root.configPath !== "" && text() === "") root.migrateConfig()
} }
} }
onFileChanged: reload() onFileChanged: reload()
+4 -2
View File
@@ -28,12 +28,14 @@ Panel {
property int margin: 67 property int margin: 67
property int lingerMs: 1000 property int lingerMs: 1000
readonly property string pluginDir: Quickshell.env("HOME") + "/.config/omarchy/plugins/felixzsh.key-visualizer" // Config lives outside the plugin folder (the shell reloads all plugin
// code on any file change under ~/.config/omarchy/plugins/), so editing it
// updates the display live instead of restarting the plugin.
readonly property string configPath: Quickshell.env("HOME") + "/.config/omarchy/key-visualizer.json"
readonly property string pausePath: { readonly property string pausePath: {
var runtime = Quickshell.env("XDG_RUNTIME_DIR") var runtime = Quickshell.env("XDG_RUNTIME_DIR")
return (runtime && runtime.length > 0 ? runtime : "/tmp") + "/omarchy-key-visualizer.paused" return (runtime && runtime.length > 0 ? runtime : "/tmp") + "/omarchy-key-visualizer.paused"
} }
readonly property string configPath: root.pluginDir + "/config.json"
// ------------------------------------------------------------- pause // ------------------------------------------------------------- pause
+1 -1
View File
@@ -2,7 +2,7 @@
"schemaVersion": 1, "schemaVersion": 1,
"id": "felixzsh.key-visualizer", "id": "felixzsh.key-visualizer",
"name": "Key Visualizer", "name": "Key Visualizer",
"version": "1.3.0", "version": "1.3.1",
"description": "Shows the keys you press on screen. Great for keybinding tutorials, demos, and screencasts.", "description": "Shows the keys you press on screen. Great for keybinding tutorials, demos, and screencasts.",
"kinds": [ "kinds": [
"panel", "panel",