quickshell: wallpaper switcher with per-wallpaper palettes

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
rope 2026-08-19 13:45:56 +01:00
parent 9d4b1f8c93
commit 965e9af5cf
2 changed files with 22 additions and 11 deletions

View file

@ -469,12 +469,26 @@ in
wallFile.writeAdapter();
}
property var pal: ({})
// The live palette. A JsonAdapter rather than a manual
// JSON.parse: its properties ARE QML properties, so a path
// change reloads the file and every colour binding below
// re-fires on its own. Defaults are stylix's build-time
// scheme (walls/wallpaper.png), which is also what shows if
// a palette file is ever missing or malformed.
property FileView palFile: FileView {
path: theme.currentWall ? theme.currentWall.palette : ""
printErrors: false
// Synchronous: an async first read paints a frame in the
// previous scheme on every switch.
blockLoading: true
onLoaded: theme.pal = JSON.parse(text())
adapter: JsonAdapter {
id: pal
property string base00: "${c.base00}"
property string base03: "${c.base03}"
property string base04: "${c.base04}"
property string base05: "${c.base05}"
property string base0D: "${c.base0D}"
}
}
// Surfaces: one hue, three steps. base01/base02 are tints of
@ -483,20 +497,16 @@ in
// purple card floating over a slate bar. Tinting keeps
// bar card hover reading as one stack. Two numbers, and
// they are the whole surface ladder.
//
// The "#${c.base00}" fallbacks are stylix's build-time scheme
// (walls/wallpaper.png): what shows for the frame or two
// before palFile lands, and if a palette file ever goes bad.
readonly property color base00: "#" + (pal.base00 || "${c.base00}")
readonly property color base00: "#" + pal.base00
readonly property color base01: Qt.lighter(base00, 1.7) // card
readonly property color base02: Qt.lighter(base00, 2.4) // hover / chip / track
// Ink, wallpaper-derived: base05 primary, base04 muted,
// base03 disabled (also the border colour).
readonly property color base03: "#" + (pal.base03 || "${c.base03}")
readonly property color base04: "#" + (pal.base04 || "${c.base04}")
readonly property color base05: "#" + (pal.base05 || "${c.base05}")
readonly property color base03: "#" + pal.base03
readonly property color base04: "#" + pal.base04
readonly property color base05: "#" + pal.base05
// The one themed accent: active, focused, selected, filled.
readonly property color base0D: "#" + (pal.base0D || "${c.base0D}")
readonly property color base0D: "#" + pal.base0D
// Status colours: fixed hues, pulled toward the theme.
// Sourcing these from stylix doesn't work base08-base0F all