diff options
| author | Danilo M. <danix@danix.xyz> | 2026-10-17 13:12:44 +0200 |
|---|---|---|
| committer | Danilo M. <danix@danix.xyz> | 2026-10-17 13:12:44 +0200 |
| commit | f114ab947afbca8b301ae5d2fa903667ef200711 (patch) | |
| tree | 678628b1edeaa17a935998a66cb97aeb69f0fea2 /desktop/island | |
| parent | d3717bc4b42c5b0b6c7e8b5055585c1a1ba061aa (diff) | |
| download | quickshell-f114ab947afbca8b301ae5d2fa903667ef200711.tar.gz quickshell-f114ab947afbca8b301ae5d2fa903667ef200711.zip | |
island: watched scene icon map singleton
Diffstat (limited to 'desktop/island')
| -rw-r--r-- | desktop/island/SceneIcons.qml | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/desktop/island/SceneIcons.qml b/desktop/island/SceneIcons.qml new file mode 100644 index 0000000..44bcf9c --- /dev/null +++ b/desktop/island/SceneIcons.qml @@ -0,0 +1,46 @@ +// Copyright (C) 2026 Danilo M. <danix@danix.xyz> +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License version 2 as +// published by the Free Software Foundation. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +pragma Singleton + +import Quickshell +import Quickshell.Io +import QtQuick +import "SceneIcons.js" as Icons + +// The scene-icon map from ~/.config, watched so a settings edit or a hand edit +// recolours the pill with no restart. The starter map covers a missing file. +Singleton { + id: root + + readonly property string path: + (Quickshell.env("XDG_CONFIG_HOME") || Quickshell.env("HOME") + "/.config") + + "/quickshell/obs-scene-icons.json" + + property var map: Icons.defaults + + function iconFor(name) { return Icons.iconFor(root.map, name); } + + function save(map) { + root.map = map; + fv.setText(Icons.serialize(map)); + } + + FileView { + id: fv + path: root.path + atomicWrites: true + watchChanges: true + onFileChanged: reload() + onLoaded: root.map = Icons.parse(text()) + onLoadFailed: root.map = Icons.defaults + } +} |
