Theme presets, and make the bar itself actually re-theme (colors + opacity)

Presets (theme/presets.py): named snapshots of the whole palette, saved/loaded/
deleted from a new bookmark button on the theme widget. Stored outside the
repo in ~/.local/share/quickshell/theme-presets/ (JSON, per-machine data, same
precedent as the wallpaper history). A built-in Default entry can't be
overwritten or deleted.

Wiring that up exposed a real gap: the bar's own colors were hand-matched
hardcoded QML literals, not actually driven by theme/colors.toml, and opacity
wasn't themeable anywhere yet. Fixed both:
- colors.toml gains bar_color/pill_color/popup_color (paired with the existing
  *_opacity floats) plus generic opacity support in render.py (--set now
  accepts a 0-1 float, not just #rrggbb)
- Bar.qml now fetches the palette via render.py --dump and rebinds every
  matching hardcoded hex literal (accent, foreground, color1/2/3/5/6/8/12,
  the bar/pill/popup backgrounds, the logo tint and the bar's bottom border)
  to it; kitty's background_opacity is template-driven instead of a second
  hardcoded line fighting the themed one
- both the bar and the widget listen on their own Quickshell IPC target
  (render.py/presets.py ping both after every change) so edits reload with no
  restart, matching the "instant" promise the color editor already had
- the theme widget's color popup gained a slider + matching color swatch per
  surface (Bar/Pills/Popups/Terminal) below the existing role list, and its
  role labels now say what each color actually paints instead of "Color N"
  (verified against the templates and Bar.qml's literals, not guessed) with
  unused roles honestly marked as such
- the CPU pill's icon color is deliberately hardcoded again after this -
  it coincidentally shared color12's hex value with the help icon/detail
  text, so theming color12 was recoloring it too

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Dujsk9jYfxUVLtb5B8eC94
This commit is contained in:
nico
2026-09-28 22:45:09 +02:00
parent e66691b469
commit 63a56f4a01
10 changed files with 813 additions and 124 deletions

3
.gitignore vendored
View File

@@ -25,3 +25,6 @@
*.bak-*
/hypr/backups/
# Python bytecode cache (theme/presets.py imports theme/render.py as a module)
__pycache__/

View File

@@ -68,14 +68,17 @@ The artwork is drawn procedurally in [`hypr/cursor/shapes.py`](hypr/cursor/shape
Theming used to go through a third-party app called aether; it's gone now (it didn't work reliably), replaced with a small homegrown system in [`theme/`](theme/):
- [`theme/colors.toml`](theme/colors.toml) is the single source of truth for the palette (accent, cursor, foreground/background, 16 ANSI colors)
- [`theme/colors.toml`](theme/colors.toml) is the single source of truth for the palette: accent, cursor, foreground/background, 16 ANSI colors, three extra `*_color` fields (`bar_color`, `pill_color`, `popup_color` — the terminal reuses `background`, already shared with mako), and four matching `*_opacity` floats (`bar_opacity`, `pill_opacity`, `popup_opacity`, `terminal_opacity`, each 0-1)
- [`theme/templates/<app>/`](theme/templates/) holds one `{config.json, template}` pair per themed app (Hyprland, Kitty, Rofi, mako). `config.json` names the destination file; the template uses `{key}` placeholders (`{color4}`, `{background}`, `{accent}`, …), `{key.strip}` for the hex without `#`, or `{key.rgba:ALPHA}` for a `rgba(r, g, b, ALPHA)` string
- [`theme/render.py`](theme/render.py) renders every template to its destination and reloads the affected apps (`hyprctl reload`, `makoctl reload`, kitty via `SIGUSR1`). Run it after editing a template by hand, or use `--set KEY '#rrggbb'` to change one color from a terminal, `--get KEY` / `--dump` to read the palette back out
- [`theme/render.py`](theme/render.py) renders every template to its destination and reloads the affected apps (`hyprctl reload`, `makoctl reload`, kitty via `SIGUSR1`). It also pings the running shell over Quickshell's two IPC targets (`theme` for the bar, `theme-widget` for the widget itself — two separate top-level QML components) so the bar's own accent/border/pill colors and all four opacities, which live in QML rather than a config file another app reads, pick up changes immediately too — no restart. Run it after editing a template by hand, or use `--set KEY VALUE` to change one color (`#rrggbb`) or opacity (`0`-`1`) from a terminal, `--get KEY` / `--dump` to read the palette back out
- [`theme/wallpaper.py`](theme/wallpaper.py) swaps the wallpaper: `apply <path>` archives the current one (deduped by hash) into `~/.local/share/quickshell/wallpapers/` and copies the new one to [`hypr/wallpaper.png`](hypr/wallpaper.png) (loaded via `swaybg` in `hyprland.lua`), `pick` does the same via a native file picker, `list` feeds the widget's gallery of past wallpapers
- [`theme/presets.py`](theme/presets.py) saves/loads/deletes named snapshots of the *entire* palette (every color and opacity value) as JSON files in `~/.local/share/quickshell/theme-presets/` — per-machine user data, not project config, so it's never tracked by this repo, same reasoning as the wallpaper history above. A built-in `Default` entry (the palette below) is always available, can't be saved over or deleted, and doesn't live in that folder — it's hardcoded in both `presets.py` and the widget
mako's per-urgency border colors (normal = accent, low = muted, critical = red) work the same way as Hyprland's border colors: edit the template at `theme/templates/mako/colors.ini`, not `mako/colors.ini` itself — that gets overwritten on the next render.
Day to day, neither script needs to be run by hand — the **theme widget**, a small standalone Quickshell window pinned to the top-left corner of the main monitor (independent of the bar), has two buttons: a picture icon opens the wallpaper gallery/picker, a paintbrush icon opens a menu to pick which color role to change and then a palette (plus a hex field) to change it to. Both call straight into the scripts above.
Day to day, none of those scripts need to be run by hand — the **theme widget**, a small standalone Quickshell window pinned to the top-left corner of the main monitor (independent of the bar, and deliberately on the Bottom wlr layer so normal windows cover it instead of sitting over everything), has three buttons: a picture icon opens the wallpaper gallery/picker; a paintbrush icon opens a menu to pick which color role to change and then a palette (plus a hex field) to change it to, with an Opacity section below the role list — a slider per surface (Bar/Pills/Popups/Terminal) with its own small color swatch right next to it, since each of those pairs a `*_color` with a `*_opacity`; and a bookmark icon opens the preset list — a name field + Save button at the top, `Default` and every saved preset below it (click to load, trash icon to delete a saved one), with a checkmark on whichever one matches the palette currently live. All three call straight into the scripts above and reflect changes instantly — dragging a slider updates its own live preview continuously but only actually calls `render.py --set` (which reloads everything) on release, not on every pixel of movement.
A few icon colors in the bar are deliberately hardcoded rather than bound to the palette, where they happened to reuse the exact hex value of an unrelated role (e.g. the CPU pill's icon used to share `color12` with the help icon and every popup's detail text — recoloring one recolored the other) — see the comments at each spot in `Bar.qml` if a bar icon doesn't seem to follow a color change.
It's a blue theme (`#1793d1` accent on a dark `#1a1b26` background) built around the stock default Hyprland wallpaper — the anime girl waiting at the train stop with the glowing blue Hyprland-logo cats. Every accent color across the bar, Rofi, Kitty, and the rest was picked to match that wallpaper's palette rather than the other way around.

View File

@@ -1,9 +1,6 @@
# Farben aus theme/colors.toml (wird bei jedem Theme-Wechsel neu generiert, siehe theme/render.py)
include ~/.config/kitty/theme.conf
# Transparenz
background_opacity 0.85
# Cursor
cursor #7aa2f7

View File

@@ -3,3 +3,4 @@
background #1a1b26
foreground #c0caf5
cursor #c0caf5
background_opacity 0.85

View File

@@ -19,6 +19,30 @@ Variants {
property bool windowSwitcherOpen: false
property bool helpOpen: false
// Bar/pill/popup opacity from theme/colors.toml - defaults match what was hardcoded
// here before theming picked these up, so nothing changes until a fetch lands.
property real barOpacity: 0.18
property real pillOpacity: 0.85
property real popupOpacity: 0.90
// Bar colors from theme/colors.toml - defaults match what was hardcoded as literal hex
// strings throughout this file before theming picked them up (see README's Theming
// section for exactly which role paints what). Keyed exactly like colors.toml so the
// fetch below can copy straight across.
property var palette: ({
accent: "#1793d1", foreground: "#c0caf5",
color1: "#f7768e", color2: "#a6e3a1", color3: "#f9e2af",
color5: "#cba6f7", color6: "#89dceb", color8: "#565f89", color12: "#7aa2f7",
bar_color: "#12131b", pill_color: "#1a1b26", popup_color: "#1a1b26",
})
// "#rrggbb" + 0-1 alpha -> "#aarrggbb", so bar/pill/popup backgrounds can have both an
// editable color *and* an editable opacity instead of a fixed base tint.
function argb(hex, alpha) {
var a = Math.round(Math.max(0, Math.min(1, alpha)) * 255).toString(16).padStart(2, "0")
return "#" + a + hex.slice(1)
}
// Kept in sync with the Hotkeys section of README.md by hand: Hyprland's Lua config binds
// everything through one opaque "__lua" dispatcher, so hyprctl binds -j can't recover a
// human-readable action for any of them - there's nothing meaningful left to auto-fetch.
@@ -181,6 +205,38 @@ Variants {
}
}
Loader {
active: modelData === Quickshell.screens[0]
sourceComponent: Item {
Process {
id: themeDump
command: ["python3", "/home/nico/.config/theme/render.py", "--dump"]
stdout: StdioCollector { id: themeDumpCollector }
onExited: {
try {
var c = JSON.parse(themeDumpCollector.text)
if ("bar_opacity" in c) root.barOpacity = c.bar_opacity
if ("pill_opacity" in c) root.pillOpacity = c.pill_opacity
if ("popup_opacity" in c) root.popupOpacity = c.popup_opacity
var p = {}
for (var key in root.palette) p[key] = (key in c) ? c[key] : root.palette[key]
root.palette = p
} catch (e) {}
}
}
IpcHandler {
target: "theme"
function changed(): void {
themeDump.running = true
}
}
Timer { interval: 300; running: true; repeat: false; onTriggered: themeDump.running = true }
}
}
property string hovered: ""
property bool menuOpen: false
property bool calendarOpen: false
@@ -298,14 +354,14 @@ Variants {
Rectangle {
anchors.fill: parent
radius: 10
color: (bellArea.containsMouse || bar.notifOpen) ? "#1793d1" : Qt.rgba(0.102, 0.106, 0.149, 0.85)
color: (bellArea.containsMouse || bar.notifOpen) ? root.palette.accent : root.argb(root.palette.pill_color, root.pillOpacity)
Text {
anchors.centerIn: parent
text: bar.notifList.length > 0 ? "\uf0f3" : "\uf0a2"
font.family: "JetBrainsMono Nerd Font"
font.pixelSize: 14
color: (bellArea.containsMouse || bar.notifOpen) ? "#0f111a" : (bar.notifList.length > 0 ? "#1793d1" : "#565f89")
color: (bellArea.containsMouse || bar.notifOpen) ? "#0f111a" : (bar.notifList.length > 0 ? root.palette.accent : root.palette.color8)
}
Rectangle {
@@ -314,7 +370,7 @@ Variants {
width: Math.max(14, badgeText.implicitWidth + 6)
height: 14
radius: 7
color: "#f7768e"
color: root.palette.color1
Text {
id: badgeText
anchors.centerIn: parent
@@ -461,13 +517,13 @@ Variants {
Rectangle {
anchors.fill: parent
color: Qt.rgba(0.071, 0.075, 0.106, 0.18)
color: root.argb(root.palette.bar_color, root.barOpacity)
}
Rectangle {
anchors { left: parent.left; right: parent.right; bottom: parent.bottom }
height: 1
color: Qt.rgba(0.090, 0.576, 0.820, 0.45)
color: root.argb(root.palette.accent, 0.45)
}
// ================= LEFT =================
@@ -480,7 +536,7 @@ Variants {
Layout.preferredWidth: logoText.implicitWidth + 28
Layout.preferredHeight: 26
radius: 10
color: Qt.rgba(0.090, 0.576, 0.820, 0.12)
color: root.argb(root.palette.accent, 0.12)
Text {
id: logoText
@@ -488,7 +544,7 @@ Variants {
text: ""
font.family: "JetBrainsMono Nerd Font"
font.pixelSize: 18
color: "#1793d1"
color: root.palette.accent
}
MouseArea {
@@ -502,7 +558,7 @@ Variants {
Layout.preferredWidth: visible ? wsRow.implicitWidth + 8 : 0
Layout.preferredHeight: 26
radius: 10
color: Qt.rgba(0.102, 0.106, 0.149, 0.85)
color: root.argb(root.palette.pill_color, root.pillOpacity)
RowLayout {
id: wsRow
@@ -526,7 +582,7 @@ Variants {
Layout.preferredWidth: 22
Layout.preferredHeight: 20
radius: 8
color: active ? "#1793d1" : (wsArea.containsMouse ? Qt.rgba(0.478, 0.635, 0.969, 0.22) : "transparent")
color: active ? root.palette.accent : (wsArea.containsMouse ? Qt.rgba(0.478, 0.635, 0.969, 0.22) : "transparent")
Text {
anchors.centerIn: parent
@@ -540,7 +596,7 @@ Variants {
}
font.family: "JetBrainsMono Nerd Font"
font.pixelSize: 13
color: wsBtn.active ? "#0f111a" : "#565f89"
color: wsBtn.active ? "#0f111a" : root.palette.color8
}
MouseArea {
@@ -594,21 +650,21 @@ Variants {
font.family: "JetBrainsMono Nerd Font"
font.pixelSize: 13
font.bold: centerContainer.showingMedia
color: "#c0caf5"
color: root.palette.foreground
}
Text {
visible: centerContainer.artistText !== ""
text: "—"
font.family: "JetBrainsMono Nerd Font"
font.pixelSize: 13
color: "#1793d1"
color: root.palette.accent
}
Text {
visible: centerContainer.artistText !== ""
text: centerContainer.artistText
font.family: "JetBrainsMono Nerd Font"
font.pixelSize: 13
color: "#7aa2f7"
color: root.palette.color12
}
}
@@ -689,7 +745,7 @@ Variants {
text: root.isGerman ? "Keine Fenster geöffnet" : "No open windows"
font.family: "JetBrainsMono Nerd Font"
font.pixelSize: 12
color: "#565f89"
color: root.palette.color8
}
Repeater {
@@ -728,7 +784,7 @@ Variants {
Layout.preferredWidth: 32
Layout.preferredHeight: 26
radius: 8
color: taskBtn.isActive ? "#1793d1" : (taskArea.containsMouse ? Qt.rgba(0.478, 0.635, 0.969, 0.22) : Qt.rgba(0.102, 0.106, 0.149, 0.85))
color: taskBtn.isActive ? root.palette.accent : (taskArea.containsMouse ? Qt.rgba(0.478, 0.635, 0.969, 0.22) : root.argb(root.palette.pill_color, root.pillOpacity))
Image {
visible: taskBtn.iconSource !== ""
@@ -746,7 +802,7 @@ Variants {
font.family: "JetBrainsMono Nerd Font"
font.pixelSize: 13
font.bold: true
color: taskBtn.isActive ? "#0f111a" : "#c0caf5"
color: taskBtn.isActive ? "#0f111a" : root.palette.foreground
}
// Multi-window indicator
@@ -759,7 +815,7 @@ Variants {
width: 14
height: 14
radius: 7
color: "#7aa2f7"
color: root.palette.color12
border.width: 1
border.color: Qt.rgba(0.102, 0.106, 0.149, 1)
@@ -810,7 +866,7 @@ Variants {
Rectangle {
anchors.fill: parent
radius: 8
color: "#e61a1b26"
color: root.argb(root.palette.popup_color, root.popupOpacity)
border.width: 1
border.color: Qt.rgba(0.478, 0.635, 0.969, 0.35)
@@ -839,7 +895,7 @@ Variants {
Layout.fillWidth: true
implicitHeight: 24
radius: 6
color: groupRowArea.containsMouse ? "#1793d1" : "transparent"
color: groupRowArea.containsMouse ? root.palette.accent : "transparent"
Text {
anchors.fill: parent
@@ -850,7 +906,7 @@ Variants {
text: taskGroupRow.modelData.title
font.family: "JetBrainsMono Nerd Font"
font.pixelSize: 12
color: groupRowArea.containsMouse ? "#0f111a" : "#c0caf5"
color: groupRowArea.containsMouse ? "#0f111a" : root.palette.foreground
}
MouseArea {
@@ -886,7 +942,7 @@ Variants {
Layout.preferredWidth: visible ? trayRow.implicitWidth + 16 : 0
Layout.preferredHeight: 26
radius: 10
color: Qt.rgba(0.102, 0.106, 0.149, 0.85)
color: root.argb(root.palette.pill_color, root.pillOpacity)
RowLayout {
id: trayRow
@@ -932,7 +988,7 @@ Variants {
Layout.preferredWidth: cpuRow.implicitWidth + 14
Layout.preferredHeight: 26
radius: 10
color: bar.hovered === "cpu" ? "#1793d1" : Qt.rgba(0.102, 0.106, 0.149, 0.85)
color: bar.hovered === "cpu" ? root.palette.accent : root.argb(root.palette.pill_color, root.pillOpacity)
Row {
id: cpuRow
@@ -942,6 +998,8 @@ Variants {
text: ""
font.family: "JetBrainsMono Nerd Font"
font.pixelSize: 13
// Deliberately hardcoded, not theme-bound: sharing color12 with the
// help icon/detail text meant recoloring one recolored the other.
color: bar.hovered === "cpu" ? "#0f111a" : (bar.showCpuTemp ? (bar.tempCritical ? "#f7768e" : "#f9e2af") : "#7aa2f7")
}
Text {
@@ -950,7 +1008,7 @@ Variants {
font.pixelSize: 13
width: valueFont.advanceWidth("100%")
horizontalAlignment: Text.AlignRight
color: bar.hovered === "cpu" ? "#0f111a" : "#c0caf5"
color: bar.hovered === "cpu" ? "#0f111a" : root.palette.foreground
}
}
@@ -969,7 +1027,7 @@ Variants {
Layout.preferredWidth: memRow.implicitWidth + 20
Layout.preferredHeight: 26
radius: 10
color: bar.hovered === "mem" ? "#1793d1" : Qt.rgba(0.102, 0.106, 0.149, 0.85)
color: bar.hovered === "mem" ? root.palette.accent : root.argb(root.palette.pill_color, root.pillOpacity)
Row {
id: memRow
@@ -979,7 +1037,7 @@ Variants {
text: ""
font.family: "JetBrainsMono Nerd Font"
font.pixelSize: 13
color: bar.hovered === "mem" ? "#0f111a" : "#89dceb"
color: bar.hovered === "mem" ? "#0f111a" : root.palette.color6
}
Text {
text: bar.memPct + "%"
@@ -987,7 +1045,7 @@ Variants {
font.pixelSize: 13
width: valueFont.advanceWidth("100%")
horizontalAlignment: Text.AlignRight
color: bar.hovered === "mem" ? "#0f111a" : "#c0caf5"
color: bar.hovered === "mem" ? "#0f111a" : root.palette.foreground
}
}
@@ -1005,7 +1063,7 @@ Variants {
Layout.preferredWidth: diskRow.implicitWidth + 20
Layout.preferredHeight: 26
radius: 10
color: bar.hovered === "disk" ? "#1793d1" : Qt.rgba(0.102, 0.106, 0.149, 0.85)
color: bar.hovered === "disk" ? root.palette.accent : root.argb(root.palette.pill_color, root.pillOpacity)
Row {
id: diskRow
@@ -1015,7 +1073,7 @@ Variants {
text: ""
font.family: "JetBrainsMono Nerd Font"
font.pixelSize: 13
color: bar.hovered === "disk" ? "#0f111a" : "#c0caf5"
color: bar.hovered === "disk" ? "#0f111a" : root.palette.foreground
}
Text {
text: bar.currentDisk.pct + "%"
@@ -1023,7 +1081,7 @@ Variants {
font.pixelSize: 13
width: valueFont.advanceWidth("100%")
horizontalAlignment: Text.AlignRight
color: bar.hovered === "disk" ? "#0f111a" : "#c0caf5"
color: bar.hovered === "disk" ? "#0f111a" : root.palette.foreground
}
}
@@ -1042,7 +1100,7 @@ Variants {
Layout.preferredWidth: visible ? gpuRow.implicitWidth + 14 : 0
Layout.preferredHeight: 26
radius: 10
color: bar.hovered === "gpu" ? "#1793d1" : Qt.rgba(0.102, 0.106, 0.149, 0.85)
color: bar.hovered === "gpu" ? root.palette.accent : root.argb(root.palette.pill_color, root.pillOpacity)
Row {
id: gpuRow
@@ -1052,7 +1110,7 @@ Variants {
text: "󰢮"
font.family: "JetBrainsMono Nerd Font"
font.pixelSize: 13
color: bar.hovered === "gpu" ? "#0f111a" : (bar.showGpuTemp ? "#f9e2af" : "#a6e3a1")
color: bar.hovered === "gpu" ? "#0f111a" : (bar.showGpuTemp ? root.palette.color3 : root.palette.color2)
}
Text {
text: bar.showGpuTemp ? (bar.gpuTemp + "°C") : (bar.gpuUtil + "%")
@@ -1060,7 +1118,7 @@ Variants {
font.pixelSize: 13
width: valueFont.advanceWidth("100%")
horizontalAlignment: Text.AlignRight
color: bar.hovered === "gpu" ? "#0f111a" : "#c0caf5"
color: bar.hovered === "gpu" ? "#0f111a" : root.palette.foreground
}
}
@@ -1079,7 +1137,7 @@ Variants {
Layout.preferredWidth: volRow.implicitWidth + 20
Layout.preferredHeight: 26
radius: 10
color: bar.hovered === "vol" ? "#1793d1" : Qt.rgba(0.102, 0.106, 0.149, 0.85)
color: bar.hovered === "vol" ? root.palette.accent : root.argb(root.palette.pill_color, root.pillOpacity)
Row {
id: volRow
@@ -1089,13 +1147,13 @@ Variants {
text: bar.volumeMuted ? "" : ""
font.family: "JetBrainsMono Nerd Font"
font.pixelSize: 13
color: bar.hovered === "vol" ? "#0f111a" : (bar.volumeMuted ? "#565f89" : "#cba6f7")
color: bar.hovered === "vol" ? "#0f111a" : (bar.volumeMuted ? root.palette.color8 : root.palette.color5)
}
Text {
text: (bar.volumeMuted ? (root.isGerman ? "muted" : "muted") : bar.volumePct + "%")
font.family: "JetBrainsMono Nerd Font"
font.pixelSize: 13
color: bar.hovered === "vol" ? "#0f111a" : "#c0caf5"
color: bar.hovered === "vol" ? "#0f111a" : root.palette.foreground
}
}
@@ -1125,11 +1183,11 @@ Variants {
Layout.preferredWidth: netRow.implicitWidth + 20
Layout.preferredHeight: 26
radius: 10
color: bar.hovered === "net" ? "#1793d1" : Qt.rgba(0.102, 0.106, 0.149, 0.85)
color: bar.hovered === "net" ? root.palette.accent : root.argb(root.palette.pill_color, root.pillOpacity)
readonly property string icon: bar.connType === "wifi" ? "" : bar.connType === "ethernet" ? "󰈀" : "󰤭"
readonly property string statusText: bar.connType === "wifi" ? (bar.connName || "WLAN") : bar.connType === "ethernet" ? "LAN" : "offline"
readonly property color statusColor: bar.connType === "" ? "#565f89" : "#a6e3a1"
readonly property color statusColor: bar.connType === "" ? root.palette.color8 : root.palette.color2
Row {
id: netRow
@@ -1147,7 +1205,7 @@ Variants {
font.pixelSize: 13
elide: Text.ElideRight
width: Math.min(implicitWidth, 90)
color: bar.hovered === "net" ? "#0f111a" : "#c0caf5"
color: bar.hovered === "net" ? "#0f111a" : root.palette.foreground
}
}
@@ -1179,14 +1237,14 @@ Variants {
Layout.preferredWidth: visible ? 32 : 0
Layout.preferredHeight: 26
radius: 10
color: (helpArea.containsMouse || root.helpOpen) ? "#1793d1" : Qt.rgba(0.102, 0.106, 0.149, 0.85)
color: (helpArea.containsMouse || root.helpOpen) ? root.palette.accent : root.argb(root.palette.pill_color, root.pillOpacity)
Text {
anchors.centerIn: parent
text: ""
font.family: "JetBrainsMono Nerd Font"
font.pixelSize: 14
color: (helpArea.containsMouse || root.helpOpen) ? "#0f111a" : "#7aa2f7"
color: (helpArea.containsMouse || root.helpOpen) ? "#0f111a" : root.palette.color12
}
MouseArea {
@@ -1204,14 +1262,14 @@ Variants {
Layout.preferredWidth: 100
Layout.preferredHeight: 26
radius: 10
color: (clockArea.containsMouse || bar.calendarOpen) ? "#1793d1" : Qt.rgba(0.102, 0.106, 0.149, 0.85)
color: (clockArea.containsMouse || bar.calendarOpen) ? root.palette.accent : root.argb(root.palette.pill_color, root.pillOpacity)
Text {
anchors.centerIn: parent
text: Qt.formatDateTime(bar.now, "dd.MM. hh:mm")
font.family: "JetBrainsMono Nerd Font"
font.pixelSize: 13
color: (clockArea.containsMouse || bar.calendarOpen) ? "#0f111a" : "#c0caf5"
color: (clockArea.containsMouse || bar.calendarOpen) ? "#0f111a" : root.palette.foreground
}
MouseArea {
@@ -1229,14 +1287,14 @@ Variants {
Layout.preferredWidth: 32
Layout.preferredHeight: 26
radius: 10
color: (powerArea.containsMouse || bar.menuOpen) ? "#1793d1" : Qt.rgba(0.102, 0.106, 0.149, 0.85)
color: (powerArea.containsMouse || bar.menuOpen) ? root.palette.accent : root.argb(root.palette.pill_color, root.pillOpacity)
Text {
anchors.centerIn: parent
text: ""
font.family: "JetBrainsMono Nerd Font"
font.pixelSize: 15
color: (powerArea.containsMouse || bar.menuOpen) ? "#0f111a" : "#1793d1"
color: (powerArea.containsMouse || bar.menuOpen) ? "#0f111a" : root.palette.accent
}
MouseArea {
@@ -1268,7 +1326,7 @@ Variants {
Rectangle {
anchors.fill: parent
radius: 10
color: "#e61a1b26"
color: root.argb(root.palette.popup_color, root.popupOpacity)
border.width: 1
border.color: Qt.rgba(0.478, 0.635, 0.969, 0.35)
@@ -1289,21 +1347,21 @@ Variants {
font.family: "JetBrainsMono Nerd Font"
font.pixelSize: 13
font.bold: true
color: "#1793d1"
color: root.palette.accent
}
Text {
visible: bar.hovered === "cpu"
text: (root.isGerman ? "Last (1/5/15 Min): " : "Load (1/5/15 min): ") + bar.load1 + " / " + bar.load5 + " / " + bar.load15
font.family: "JetBrainsMono Nerd Font"
font.pixelSize: 12
color: "#c0caf5"
color: root.palette.foreground
}
Text {
visible: bar.hovered === "cpu" && bar.tempAvailable
text: (root.isGerman ? "Temperatur (Tctl): " : "Temperature (Tctl): ") + bar.tempC + "°C"
font.family: "JetBrainsMono Nerd Font"
font.pixelSize: 12
color: "#7aa2f7"
color: root.palette.color12
}
GridLayout {
visible: bar.hovered === "cpu" && bar.perCore.length > 0
@@ -1319,7 +1377,7 @@ Variants {
text: "C" + index + ": " + modelData + "%"
font.family: "JetBrainsMono Nerd Font"
font.pixelSize: 11
color: "#565f89"
color: root.palette.color8
}
}
}
@@ -1328,14 +1386,14 @@ Variants {
text: root.isGerman ? "Klicken zum Wechseln" : "Click to toggle"
font.family: "JetBrainsMono Nerd Font"
font.pixelSize: 11
color: "#565f89"
color: root.palette.color8
}
Text {
visible: bar.hovered === "mem"
text: (root.isGerman ? "Belegt: " : "Used: ") + bar.memUsed.toFixed(1) + " / " + bar.memTotal.toFixed(1) + " GiB"
font.family: "JetBrainsMono Nerd Font"
font.pixelSize: 12
color: "#c0caf5"
color: root.palette.foreground
}
ColumnLayout {
visible: bar.hovered === "disk"
@@ -1358,19 +1416,19 @@ Variants {
font.bold: index === bar.diskIndex
elide: Text.ElideMiddle
Layout.fillWidth: true
color: index === bar.diskIndex ? "#c0caf5" : "#9aa5ce"
color: index === bar.diskIndex ? root.palette.foreground : "#9aa5ce"
}
Text {
text: modelData.pct + "%" + " · " + (root.isGerman ? "Belegt " : "Used ") + modelData.used.toFixed(0) + " / " + modelData.total.toFixed(0) + " GiB" + " · " + (root.isGerman ? "Frei " : "Free ") + modelData.avail.toFixed(0) + " GiB"
font.family: "JetBrainsMono Nerd Font"
font.pixelSize: 11
color: "#565f89"
color: root.palette.color8
}
Text {
text: "R: " + root.fmtRate(modelData.readKBps) + " W: " + root.fmtRate(modelData.writeKBps)
font.family: "JetBrainsMono Nerd Font"
font.pixelSize: 11
color: "#565f89"
color: root.palette.color8
}
}
}
@@ -1380,28 +1438,28 @@ Variants {
text: root.isGerman ? "Klicken zum Wechseln" : "Click to toggle"
font.family: "JetBrainsMono Nerd Font"
font.pixelSize: 11
color: "#565f89"
color: root.palette.color8
}
Text {
visible: bar.hovered === "gpu"
text: (root.isGerman ? "Temperatur: " : "Temperature: ") + bar.gpuTemp + "°C"
font.family: "JetBrainsMono Nerd Font"
font.pixelSize: 12
color: "#7aa2f7"
color: root.palette.color12
}
Text {
visible: bar.hovered === "gpu"
text: "VRAM: " + bar.gpuMemUsed + " / " + bar.gpuMemTotal + " MiB"
font.family: "JetBrainsMono Nerd Font"
font.pixelSize: 12
color: "#565f89"
color: root.palette.color8
}
Text {
visible: bar.hovered === "gpu"
text: root.isGerman ? "Klicken zum Wechseln" : "Click to toggle"
font.family: "JetBrainsMono Nerd Font"
font.pixelSize: 11
color: "#565f89"
color: root.palette.color8
}
Text {
visible: bar.hovered === "vol"
@@ -1410,7 +1468,7 @@ Variants {
text: root.isGerman ? "Klick: Mixer · Rechtsklick: Stumm · Scroll: Lautstärke" : "Click: Mixer · Right-click: Mute · Scroll: Volume"
font.family: "JetBrainsMono Nerd Font"
font.pixelSize: 11
color: "#565f89"
color: root.palette.color8
}
}
}
@@ -1433,7 +1491,7 @@ Variants {
Rectangle {
anchors.fill: parent
radius: 10
color: "#e61a1b26"
color: root.argb(root.palette.popup_color, root.popupOpacity)
border.width: 1
border.color: Qt.rgba(0.478, 0.635, 0.969, 0.35)
@@ -1448,13 +1506,13 @@ Variants {
font.family: "JetBrainsMono Nerd Font"
font.pixelSize: 13
font.bold: true
color: "#1793d1"
color: root.palette.accent
}
Text {
text: bar.connType === "" ? (root.isGerman ? "Nicht verbunden" : "Not connected") : (bar.connType === "wifi" ? (root.isGerman ? "WLAN" : "Wi-Fi") : (root.isGerman ? "Kabelgebunden" : "Wired"))
font.family: "JetBrainsMono Nerd Font"
font.pixelSize: 12
color: "#c0caf5"
color: root.palette.foreground
}
Text {
visible: bar.connType === "wifi"
@@ -1463,33 +1521,33 @@ Variants {
wrapMode: Text.WrapAnywhere
font.family: "JetBrainsMono Nerd Font"
font.pixelSize: 12
color: "#a6e3a1"
color: root.palette.color2
}
Text {
text: (bar.showPublicIp ? (root.isGerman ? "Öffentliche IP: " : "Public IP: ") + (bar.publicIpLoading ? "…" : (bar.publicIp || "n/a")) : (root.isGerman ? "Lokale IP: " : "Local IP: ") + (bar.localIp || "n/a"))
font.family: "JetBrainsMono Nerd Font"
font.pixelSize: 12
color: "#7aa2f7"
color: root.palette.color12
}
Text {
visible: bar.netDevice !== ""
text: (root.isGerman ? "Gerät: " : "Device: ") + bar.netDevice
font.family: "JetBrainsMono Nerd Font"
font.pixelSize: 12
color: "#565f89"
color: root.palette.color8
}
Text {
visible: bar.connType !== ""
text: " " + root.fmtBitrate(bar.netRxKBps) + "  " + root.fmtBitrate(bar.netTxKBps)
font.family: "JetBrainsMono Nerd Font"
font.pixelSize: 12
color: "#c0caf5"
color: root.palette.foreground
}
Text {
text: root.isGerman ? "Klicken zum Wechseln" : "Click to toggle"
font.family: "JetBrainsMono Nerd Font"
font.pixelSize: 11
color: "#565f89"
color: root.palette.color8
}
}
}
@@ -1512,7 +1570,7 @@ Variants {
Rectangle {
anchors.fill: parent
radius: 10
color: "#e61a1b26"
color: root.argb(root.palette.popup_color, root.popupOpacity)
border.width: 1
border.color: Qt.rgba(0.478, 0.635, 0.969, 0.35)
@@ -1527,19 +1585,19 @@ Variants {
font.family: "JetBrainsMono Nerd Font"
font.pixelSize: 13
font.bold: true
color: "#c0caf5"
color: root.palette.foreground
}
Text {
text: (root.isGerman ? "KW " : "Week ") + root.isoWeek(bar.now)
font.family: "JetBrainsMono Nerd Font"
font.pixelSize: 12
color: "#7aa2f7"
color: root.palette.color12
}
Text {
text: Qt.formatDateTime(bar.now, "hh:mm:ss")
font.family: "JetBrainsMono Nerd Font"
font.pixelSize: 12
color: "#565f89"
color: root.palette.color8
}
}
}
@@ -1562,7 +1620,7 @@ Variants {
Rectangle {
anchors.fill: parent
radius: 10
color: "#e61a1b26"
color: root.argb(root.palette.popup_color, root.popupOpacity)
border.width: 1
border.color: Qt.rgba(0.478, 0.635, 0.969, 0.35)
@@ -1572,7 +1630,7 @@ Variants {
text: root.isGerman ? "Zeigt alle Tastenkombinationen" : "Shows all keybinds"
font.family: "JetBrainsMono Nerd Font"
font.pixelSize: 12
color: "#c0caf5"
color: root.palette.foreground
}
}
}
@@ -1601,7 +1659,7 @@ Variants {
Rectangle {
anchors.fill: parent
radius: 12
color: "#f01a1b26"
color: root.argb(root.palette.popup_color, root.popupOpacity)
border.width: 1
border.color: Qt.rgba(0.478, 0.635, 0.969, 0.35)
@@ -1616,7 +1674,7 @@ Variants {
font.family: "JetBrainsMono Nerd Font"
font.pixelSize: 18
font.bold: true
color: "#c0caf5"
color: root.palette.foreground
}
Flickable {
@@ -1645,7 +1703,7 @@ Variants {
font.family: "JetBrainsMono Nerd Font"
font.pixelSize: 15
font.bold: true
color: "#1793d1"
color: root.palette.accent
}
Repeater {
@@ -1660,7 +1718,7 @@ Variants {
text: modelData.keys
font.family: "JetBrainsMono Nerd Font"
font.pixelSize: 14
color: "#7aa2f7"
color: root.palette.color12
Layout.preferredWidth: 225
wrapMode: Text.WrapAnywhere
}
@@ -1669,7 +1727,7 @@ Variants {
text: root.isGerman ? modelData.de : modelData.en
font.family: "JetBrainsMono Nerd Font"
font.pixelSize: 14
color: "#c0caf5"
color: root.palette.foreground
wrapMode: Text.WordWrap
}
}
@@ -1705,7 +1763,7 @@ Variants {
Rectangle {
anchors.fill: parent
radius: 12
color: "#f01a1b26"
color: root.argb(root.palette.popup_color, root.popupOpacity)
border.width: 1
border.color: Qt.rgba(0.478, 0.635, 0.969, 0.35)
@@ -1723,7 +1781,7 @@ Variants {
font.family: "JetBrainsMono Nerd Font"
font.pixelSize: 14
font.bold: true
color: "#c0caf5"
color: root.palette.foreground
}
Rectangle {
@@ -1731,7 +1789,7 @@ Variants {
Layout.preferredWidth: readAllText.implicitWidth + 16
Layout.preferredHeight: 24
radius: 8
color: readAllArea.containsMouse ? "#1793d1" : Qt.rgba(0.478, 0.635, 0.969, 0.15)
color: readAllArea.containsMouse ? root.palette.accent : Qt.rgba(0.478, 0.635, 0.969, 0.15)
Text {
id: readAllText
@@ -1739,7 +1797,7 @@ Variants {
text: "\uf00c " + (root.isGerman ? "Alle gelesen" : "Mark all read")
font.family: "JetBrainsMono Nerd Font"
font.pixelSize: 11
color: readAllArea.containsMouse ? "#0f111a" : "#c0caf5"
color: readAllArea.containsMouse ? "#0f111a" : root.palette.foreground
}
MouseArea {
@@ -1759,7 +1817,7 @@ Variants {
text: root.isGerman ? "Alles gelesen" : "All caught up"
font.family: "JetBrainsMono Nerd Font"
font.pixelSize: 12
color: "#565f89"
color: root.palette.color8
}
ListView {
@@ -1777,7 +1835,7 @@ Variants {
radius: 10
color: cardArea.containsMouse ? Qt.rgba(0.478, 0.635, 0.969, 0.18) : Qt.rgba(0.478, 0.635, 0.969, 0.08)
border.width: modelData.urgency === "critical" ? 1 : 0
border.color: "#f7768e"
border.color: root.palette.color1
ColumnLayout {
id: cardCol
@@ -1792,13 +1850,13 @@ Variants {
elide: Text.ElideRight
font.family: "JetBrainsMono Nerd Font"
font.pixelSize: 10
color: "#1793d1"
color: root.palette.accent
}
Text {
text: "\uf00c"
font.family: "JetBrainsMono Nerd Font"
font.pixelSize: 11
color: cardArea.containsMouse ? "#a6e3a1" : "#565f89"
color: cardArea.containsMouse ? root.palette.color2 : root.palette.color8
}
}
Text {
@@ -1810,7 +1868,7 @@ Variants {
font.family: "JetBrainsMono Nerd Font"
font.pixelSize: 12
font.bold: true
color: "#c0caf5"
color: root.palette.foreground
}
Text {
visible: modelData.body !== ""
@@ -1861,7 +1919,7 @@ Variants {
Rectangle {
anchors.fill: parent
radius: 10
color: "#e61a1b26"
color: root.argb(root.palette.popup_color, root.popupOpacity)
border.width: 1
border.color: Qt.rgba(0.478, 0.635, 0.969, 0.35)
@@ -1877,7 +1935,7 @@ Variants {
Text {
text: "‹"
font.pixelSize: 16
color: "#7aa2f7"
color: root.palette.color12
MouseArea {
anchors.fill: parent
anchors.margins: -6
@@ -1898,13 +1956,13 @@ Variants {
text: Qt.formatDateTime(new Date(bar.viewYear, bar.viewMonth, 1), "MMMM yyyy")
font.bold: true
font.pixelSize: 13
color: "#c0caf5"
color: root.palette.foreground
}
Text {
text: "›"
font.pixelSize: 16
color: "#7aa2f7"
color: root.palette.color12
MouseArea {
anchors.fill: parent
anchors.margins: -6
@@ -1933,7 +1991,7 @@ Variants {
horizontalAlignment: Text.AlignHCenter
text: Qt.locale().dayName(index + 1, Locale.ShortFormat)
font.pixelSize: 11
color: "#565f89"
color: root.palette.color8
}
}
}
@@ -1951,7 +2009,7 @@ Variants {
horizontalAlignment: Text.AlignHCenter
text: modelData.weekNum
font.pixelSize: 10
color: "#565f89"
color: root.palette.color8
}
Repeater {
@@ -1962,12 +2020,12 @@ Variants {
Layout.preferredWidth: 24
Layout.preferredHeight: 22
radius: 6
color: modelData.isToday ? "#1793d1" : "transparent"
color: modelData.isToday ? root.palette.accent : "transparent"
Text {
anchors.centerIn: parent
text: modelData.day ?? ""
font.pixelSize: 11
color: modelData.isToday ? "#0f111a" : (modelData.day ? "#c0caf5" : "transparent")
color: modelData.isToday ? "#0f111a" : (modelData.day ? root.palette.foreground : "transparent")
}
}
}
@@ -2001,7 +2059,7 @@ Variants {
Rectangle {
anchors.fill: parent
radius: 10
color: "#e61a1b26"
color: root.argb(root.palette.popup_color, root.popupOpacity)
border.width: 1
border.color: Qt.rgba(0.478, 0.635, 0.969, 0.35)
@@ -2072,7 +2130,7 @@ Variants {
Rectangle {
anchors.fill: parent
radius: 10
color: "#e61a1b26"
color: root.argb(root.palette.popup_color, root.popupOpacity)
border.width: 1
border.color: Qt.rgba(0.478, 0.635, 0.969, 0.35)
@@ -2087,7 +2145,7 @@ Variants {
text: root.isGerman ? "Keine Fenster ge\u00f6ffnet" : "No open windows"
font.family: "JetBrainsMono Nerd Font"
font.pixelSize: 12
color: "#565f89"
color: root.palette.color8
}
Repeater {
@@ -2099,7 +2157,7 @@ Variants {
Layout.fillWidth: true
implicitHeight: 30
radius: 8
color: winRowArea.containsMouse ? "#1793d1" : "transparent"
color: winRowArea.containsMouse ? root.palette.accent : "transparent"
RowLayout {
anchors.fill: parent
@@ -2112,7 +2170,7 @@ Variants {
text: winRow.modelData.workspace ? winRow.modelData.workspace.name : ""
font.family: "JetBrainsMono Nerd Font"
font.pixelSize: 11
color: winRowArea.containsMouse ? "#0f111a" : "#565f89"
color: winRowArea.containsMouse ? "#0f111a" : root.palette.color8
}
Text {
@@ -2121,7 +2179,7 @@ Variants {
text: winRow.modelData.title
font.family: "JetBrainsMono Nerd Font"
font.pixelSize: 13
color: winRowArea.containsMouse ? "#0f111a" : "#c0caf5"
color: winRowArea.containsMouse ? "#0f111a" : root.palette.foreground
}
}

View File

@@ -29,10 +29,23 @@ PanelWindow {
property bool wallpaperOpen: false
property bool colorsOpen: false
property bool presetsOpen: false
property var wallpapers: []
// ---- presets: named snapshots of the whole palette (theme/presets.py) ----
property var presetsDefault: ({ name: "Default", current: true })
property var presetsList: []
property string presetNameInput: ""
// ---- color roles: key -> current hex, kept in sync with theme/colors.toml ----
property var colorValues: ({})
readonly property real popupOpacity: colorValues.popup_opacity !== undefined ? colorValues.popup_opacity : 0.90
readonly property string popupColor: colorValues.popup_color !== undefined ? colorValues.popup_color : "#1a1b26"
function argb(hex, alpha) {
var a = Math.round(Math.max(0, Math.min(1, alpha)) * 255).toString(16).padStart(2, "0")
return "#" + a + hex.slice(1)
}
property string editingKey: ""
property string hexInput: ""
@@ -41,16 +54,48 @@ PanelWindow {
"color0", "color1", "color2", "color3", "color4", "color5", "color6", "color7",
"color8", "color9", "color10", "color11", "color12", "color13", "color14", "color15"]
// What each role actually paints, verified against theme/templates/ (border/urgency/accent
// colors) and the literal hex values hardcoded in Bar.qml (the bar isn't template-driven,
// its colors were hand-matched to the palette - see the Theming section of README.md).
// Several ANSI slots aren't wired up to anything yet (background, selection, color0/15) or
// currently equal their "bright" sibling 1:1 - labelled as such rather than guessed at.
readonly property var roleLabels: ({
accent: "Accent", cursor: "Cursor", foreground: "Foreground", background: "Background",
selection_foreground: isGerman ? "Auswahl (Text)" : "Selection (fg)",
selection_background: isGerman ? "Auswahl (Hintergrund)" : "Selection (bg)",
color0: "Color 0", color1: "Color 1", color2: "Color 2", color3: "Color 3",
color4: "Color 4", color5: "Color 5", color6: "Color 6", color7: "Color 7",
color8: "Color 8", color9: "Color 9", color10: "Color 10", color11: "Color 11",
color12: "Color 12", color13: "Color 13", color14: "Color 14", color15: "Color 15",
accent: isGerman ? "Akzent (Hervorhebung)" : "Accent (highlights)",
cursor: isGerman ? "Cursor (Terminal)" : "Cursor (terminal)",
foreground: isGerman ? "Vordergrund (Text)" : "Foreground (text)",
background: isGerman ? "Hintergrund (Terminal, mako)" : "Background (terminal, mako)",
selection_foreground: isGerman ? "Auswahltext (ungenutzt)" : "Selection text (unused)",
selection_background: isGerman ? "Auswahlhintergrund (ungenutzt)" : "Selection bg (unused)",
color0: isGerman ? "Schwarz (ungenutzt)" : "Black (unused)",
color1: isGerman ? "Rot (kritisch, Badges)" : "Red (critical, badges)",
color2: isGerman ? "Grün (GPU-Icon, verbunden)" : "Green (GPU icon, connected)",
color3: isGerman ? "Gelb (Temp-Warnung)" : "Yellow (temp warning)",
color4: isGerman ? "Blau (Rahmenfarben)" : "Blue (border colors)",
color5: isGerman ? "Magenta (Lautstärke-Icon)" : "Magenta (volume icon)",
color6: isGerman ? "Cyan (RAM-Icon)" : "Cyan (RAM icon)",
color7: isGerman ? "Weiß (= Vordergrund)" : "White (= Foreground)",
color8: isGerman ? "Gedämpft (inaktiv, Hinweise)" : "Muted (inactive, hints)",
color9: isGerman ? "Hellrot (= Rot)" : "Bright red (= Red)",
color10: isGerman ? "Hellgrün (= Grün)" : "Bright green (= Green)",
color11: isGerman ? "Hellgelb (= Gelb)" : "Bright yellow (= Yellow)",
color12: isGerman ? "Hellblau (Detailtext, Hilfe)" : "Bright blue (detail text, help)",
color13: isGerman ? "Hellmagenta (= Magenta)" : "Bright magenta (= Magenta)",
color14: isGerman ? "Hellcyan (= Cyan)" : "Bright cyan (= Cyan)",
color15: isGerman ? "Hellweiß (ungenutzt)" : "Bright white (unused)",
bar_color: isGerman ? "Bar-Hintergrund" : "Bar background",
pill_color: isGerman ? "Pill-Hintergrund" : "Pill background",
popup_color: isGerman ? "Popup-Hintergrund" : "Popup background",
})
// colorKey pairs each opacity with the color it fades - clicking its swatch jumps into
// the same role editor (step 2 below) used for every other color.
readonly property var opacityFields: [
{ key: "bar_opacity", colorKey: "bar_color", label: isGerman ? "Bar" : "Bar" },
{ key: "pill_opacity", colorKey: "pill_color", label: isGerman ? "Pills" : "Pills" },
{ key: "popup_opacity", colorKey: "popup_color", label: isGerman ? "Popups" : "Popups" },
{ key: "terminal_opacity", colorKey: "background", label: isGerman ? "Terminal" : "Terminal" },
]
// A curated set of preset swatches for the color picker - independent of the current
// theme, so it always offers real alternatives instead of just the colors already in use.
readonly property var presetPalette: [
@@ -62,6 +107,10 @@ PanelWindow {
function refreshColors() { colorsDump.running = true }
function refreshWallpapers() { wallpaperList.running = true }
function refreshPresets() {
presetsDefaultProc.running = true
presetsListProc.running = true
}
Process {
id: colorsDump
@@ -78,6 +127,51 @@ PanelWindow {
onExited: widget.refreshColors()
}
Process {
id: opacitySet
stdout: StdioCollector {}
onExited: widget.refreshColors()
}
Process {
id: presetsDefaultProc
command: ["python3", widget.themeDir + "/presets.py", "default"]
stdout: StdioCollector { id: presetsDefaultCollector }
onExited: {
try { widget.presetsDefault = JSON.parse(presetsDefaultCollector.text) } catch (e) {}
}
}
Process {
id: presetsListProc
command: ["python3", widget.themeDir + "/presets.py", "list"]
stdout: StdioCollector { id: presetsListCollector }
onExited: {
try { widget.presetsList = JSON.parse(presetsListCollector.text) } catch (e) {}
}
}
Process {
id: presetsSave
stdout: StdioCollector {}
onExited: widget.refreshPresets()
}
Process {
id: presetsLoad
stdout: StdioCollector {}
onExited: {
widget.refreshPresets()
widget.refreshColors()
}
}
Process {
id: presetsDelete
stdout: StdioCollector {}
onExited: widget.refreshPresets()
}
Process {
id: wallpaperList
command: ["python3", widget.themeDir + "/wallpaper.py", "list"]
@@ -100,9 +194,19 @@ PanelWindow {
onExited: widget.refreshWallpapers()
}
IpcHandler {
target: "theme-widget"
function changed(): void {
widget.refreshColors()
widget.refreshPresets()
}
}
Component.onCompleted: {
refreshColors()
refreshWallpapers()
refreshPresets()
}
Rectangle {
@@ -138,6 +242,7 @@ PanelWindow {
hoverEnabled: true
onClicked: {
widget.colorsOpen = false
widget.presetsOpen = false
widget.wallpaperOpen = !widget.wallpaperOpen
if (widget.wallpaperOpen) widget.refreshWallpapers()
}
@@ -163,6 +268,7 @@ PanelWindow {
hoverEnabled: true
onClicked: {
widget.wallpaperOpen = false
widget.presetsOpen = false
widget.colorsOpen = !widget.colorsOpen
if (widget.colorsOpen) {
widget.editingKey = ""
@@ -171,6 +277,35 @@ PanelWindow {
}
}
}
Rectangle {
width: 30; height: 26
radius: 8
color: (presetArea.containsMouse || widget.presetsOpen) ? "#1793d1" : "transparent"
Text {
anchors.centerIn: parent
text: ""
font.family: "JetBrainsMono Nerd Font"
font.pixelSize: 14
color: (presetArea.containsMouse || widget.presetsOpen) ? "#0f111a" : "#a6e3a1"
}
MouseArea {
id: presetArea
anchors.fill: parent
hoverEnabled: true
onClicked: {
widget.wallpaperOpen = false
widget.colorsOpen = false
widget.presetsOpen = !widget.presetsOpen
if (widget.presetsOpen) {
widget.presetNameInput = ""
widget.refreshPresets()
}
}
}
}
}
}
@@ -198,7 +333,7 @@ PanelWindow {
Rectangle {
anchors.fill: parent
radius: 12
color: "#f01a1b26"
color: widget.argb(widget.popupColor, widget.popupOpacity)
border.width: 1
border.color: Qt.rgba(0.478, 0.635, 0.969, 0.35)
@@ -319,7 +454,7 @@ PanelWindow {
screen: widget.screen
anchors { top: true; left: true }
margins { top: 48; left: 10 }
implicitWidth: 340
implicitWidth: 460
implicitHeight: colorsCol.implicitHeight + 24
color: "transparent"
WlrLayershell.namespace: "theme-widget-colors"
@@ -334,7 +469,7 @@ PanelWindow {
Rectangle {
anchors.fill: parent
radius: 12
color: "#f01a1b26"
color: widget.argb(widget.popupColor, widget.popupOpacity)
border.width: 1
border.color: Qt.rgba(0.478, 0.635, 0.969, 0.35)
@@ -408,6 +543,115 @@ PanelWindow {
}
}
}
Rectangle {
Layout.fillWidth: true
Layout.preferredHeight: 1
Layout.topMargin: 2
color: Qt.rgba(0.478, 0.635, 0.969, 0.2)
}
Text {
text: widget.isGerman ? "Transparenz" : "Opacity"
font.family: "JetBrainsMono Nerd Font"
font.pixelSize: 12
font.bold: true
color: "#565f89"
}
Repeater {
model: widget.opacityFields
RowLayout {
required property var modelData
Layout.fillWidth: true
spacing: 8
readonly property real liveValue: widget.colorValues[modelData.key] !== undefined ? widget.colorValues[modelData.key] : 1
property real dragValue: liveValue
readonly property real shownValue: track.pressed ? dragValue : liveValue
Text {
Layout.preferredWidth: 52
text: modelData.label
font.family: "JetBrainsMono Nerd Font"
font.pixelSize: 11
color: "#c0caf5"
}
Rectangle {
Layout.preferredWidth: 16
Layout.preferredHeight: 16
radius: 4
color: widget.colorValues[modelData.colorKey] || "#000000"
border.width: 1
border.color: Qt.rgba(1, 1, 1, 0.2)
MouseArea {
anchors.fill: parent
onClicked: {
widget.editingKey = modelData.colorKey
widget.hexInput = widget.colorValues[modelData.colorKey] || ""
}
}
}
Item {
Layout.fillWidth: true
Layout.preferredHeight: 20
Rectangle {
id: sliderTrack
anchors.verticalCenter: parent.verticalCenter
width: parent.width
height: 6
radius: 3
color: Qt.rgba(0.478, 0.635, 0.969, 0.15)
}
Rectangle {
anchors.verticalCenter: parent.verticalCenter
width: sliderTrack.width * Math.max(0, Math.min(1, shownValue))
height: 6
radius: 3
color: "#1793d1"
}
Rectangle {
anchors.verticalCenter: parent.verticalCenter
x: Math.max(0, Math.min(sliderTrack.width, sliderTrack.width * shownValue)) - width / 2
width: 14; height: 14
radius: 7
color: "#c0caf5"
border.width: track.pressed ? 2 : 0
border.color: "#1793d1"
}
MouseArea {
id: track
anchors.fill: parent
preventStealing: true
function valueAt(mx) {
return Math.max(0, Math.min(1, mx / width))
}
onPressed: (mouse) => { dragValue = valueAt(mouse.x) }
onPositionChanged: (mouse) => { if (pressed) dragValue = valueAt(mouse.x) }
onReleased: {
opacitySet.command = ["python3", widget.themeDir + "/render.py", "--set", modelData.key, dragValue.toFixed(2)]
opacitySet.running = true
}
}
}
Text {
Layout.preferredWidth: 34
horizontalAlignment: Text.AlignRight
text: Math.round(shownValue * 100) + "%"
font.family: "JetBrainsMono Nerd Font"
font.pixelSize: 11
color: "#565f89"
}
}
}
}
// ---- step 2: pick a new color for widget.editingKey ----
@@ -535,4 +779,234 @@ PanelWindow {
}
}
}
// ================= PRESETS POPUP =================
LazyLoader {
active: widget.presetsOpen
PanelWindow {
id: presetsWindow
screen: widget.screen
anchors { top: true; left: true }
margins { top: 48; left: 10 }
implicitWidth: 320
implicitHeight: presetsCol.implicitHeight + 24
color: "transparent"
WlrLayershell.namespace: "theme-widget-presets"
WlrLayershell.layer: WlrLayer.Top
HyprlandFocusGrab {
windows: [ presetsWindow ]
active: true
onCleared: widget.presetsOpen = false
}
Rectangle {
anchors.fill: parent
radius: 12
color: widget.argb(widget.popupColor, widget.popupOpacity)
border.width: 1
border.color: Qt.rgba(0.478, 0.635, 0.969, 0.35)
ColumnLayout {
id: presetsCol
anchors.fill: parent
anchors.margins: 12
spacing: 8
Text {
text: widget.isGerman ? "Gespeicherte Profile" : "Saved presets"
font.family: "JetBrainsMono Nerd Font"
font.pixelSize: 15
font.bold: true
color: "#c0caf5"
}
RowLayout {
Layout.fillWidth: true
spacing: 8
Rectangle {
Layout.fillWidth: true
Layout.preferredHeight: 30
radius: 6
color: "#0f111a"
border.width: 1
border.color: Qt.rgba(0.478, 0.635, 0.969, 0.3)
TextInput {
anchors.fill: parent
anchors.margins: 6
text: widget.presetNameInput
onTextEdited: widget.presetNameInput = text
maximumLength: 40
font.family: "JetBrainsMono Nerd Font"
font.pixelSize: 12
color: "#c0caf5"
selectByMouse: true
validator: RegularExpressionValidator { regularExpression: /[A-Za-z0-9 _-]*/ }
Text {
visible: parent.text === ""
text: "Name…"
font: parent.font
color: "#565f89"
}
}
}
Rectangle {
Layout.preferredWidth: 70
Layout.preferredHeight: 30
radius: 6
readonly property bool valid: widget.presetNameInput.trim().length > 0
color: !valid ? Qt.rgba(0.478, 0.635, 0.969, 0.1) : (saveArea.containsMouse ? "#1793d1" : Qt.rgba(0.478, 0.635, 0.969, 0.25))
opacity: valid ? 1.0 : 0.5
Text {
anchors.centerIn: parent
text: widget.isGerman ? "Speichern" : "Save"
font.family: "JetBrainsMono Nerd Font"
font.pixelSize: 11
color: saveArea.containsMouse ? "#0f111a" : "#c0caf5"
}
MouseArea {
id: saveArea
anchors.fill: parent
hoverEnabled: true
enabled: parent.valid
onClicked: {
presetsSave.command = ["python3", widget.themeDir + "/presets.py", "save", widget.presetNameInput.trim()]
presetsSave.running = true
widget.presetNameInput = ""
}
}
}
}
Rectangle {
Layout.fillWidth: true
Layout.preferredHeight: 1
color: Qt.rgba(0.478, 0.635, 0.969, 0.2)
}
ColumnLayout {
Layout.fillWidth: true
spacing: 3
Rectangle {
Layout.fillWidth: true
Layout.preferredHeight: 30
radius: 8
color: defaultArea.containsMouse ? Qt.rgba(0.478, 0.635, 0.969, 0.18) : (widget.presetsDefault.current ? Qt.rgba(0.478, 0.635, 0.969, 0.1) : "transparent")
RowLayout {
anchors.fill: parent
anchors.leftMargin: 8
anchors.rightMargin: 8
spacing: 6
Text {
Layout.fillWidth: true
text: widget.isGerman ? "Standard" : "Default"
font.family: "JetBrainsMono Nerd Font"
font.pixelSize: 12
color: "#c0caf5"
}
Text {
visible: widget.presetsDefault.current
text: ""
font.family: "JetBrainsMono Nerd Font"
font.pixelSize: 11
color: "#1793d1"
}
}
MouseArea {
id: defaultArea
anchors.fill: parent
hoverEnabled: true
onClicked: {
presetsLoad.command = ["python3", widget.themeDir + "/presets.py", "load", "Default"]
presetsLoad.running = true
}
}
}
Repeater {
model: widget.presetsList
Rectangle {
required property var modelData
Layout.fillWidth: true
Layout.preferredHeight: 30
radius: 8
color: rowArea.containsMouse ? Qt.rgba(0.478, 0.635, 0.969, 0.18) : (modelData.current ? Qt.rgba(0.478, 0.635, 0.969, 0.1) : "transparent")
// Declared before the row content below, so the trash icon's own
// MouseArea (a descendant of a later sibling) sits on top of this
// one and claims its clicks first; this one gets the rest of the row.
MouseArea {
id: rowArea
anchors.fill: parent
hoverEnabled: true
onClicked: {
presetsLoad.command = ["python3", widget.themeDir + "/presets.py", "load", modelData.name]
presetsLoad.running = true
}
}
RowLayout {
anchors.fill: parent
anchors.leftMargin: 8
anchors.rightMargin: 8
spacing: 6
Text {
Layout.fillWidth: true
text: modelData.name
elide: Text.ElideRight
font.family: "JetBrainsMono Nerd Font"
font.pixelSize: 12
color: "#c0caf5"
}
Text {
visible: modelData.current
text: ""
font.family: "JetBrainsMono Nerd Font"
font.pixelSize: 11
color: "#1793d1"
}
Rectangle {
width: 20; height: 20
radius: 5
color: deleteArea.containsMouse ? "#f7768e" : "transparent"
Text {
anchors.centerIn: parent
text: ""
font.family: "JetBrainsMono Nerd Font"
font.pixelSize: 10
color: deleteArea.containsMouse ? "#0f111a" : "#565f89"
}
MouseArea {
id: deleteArea
anchors.fill: parent
hoverEnabled: true
onClicked: {
presetsDelete.command = ["python3", widget.themeDir + "/presets.py", "delete", modelData.name]
presetsDelete.running = true
}
}
}
}
}
}
}
}
}
}
}
}

View File

@@ -29,3 +29,15 @@ color12 = "#7aa2f7"
color13 = "#cba6f7"
color14 = "#89dceb"
color15 = "#ffffff"
# Bar/pill/popup background colors (the terminal's is "background" above, already shared
# with mako) - each paired with the matching *_opacity float below for its transparency
bar_color = "#12131b"
pill_color = "#1a1b26"
popup_color = "#1a1b26"
# Opacity (0-1) for the bar itself, its pills, its popups, and the terminal background
bar_opacity = 0.18
pill_opacity = 0.85
popup_opacity = 0.9
terminal_opacity = 0.85

119
theme/presets.py Executable file
View File

@@ -0,0 +1,119 @@
#!/usr/bin/env python3
"""Named snapshots of the whole palette (theme/colors.toml) - save, load, delete.
presets.py list JSON array of saved presets: [{name, current}, ...]
presets.py default JSON of the built-in Default baseline + whether it's active
presets.py save <name> snapshot the current palette under <name> (overwrites if it exists)
presets.py load <name> apply a saved preset (or "Default") as the active palette,
re-render every themed app's config and reload it
presets.py delete <name> remove a saved preset ("Default" can't be deleted)
Presets are per-machine user data, not project config, so - like the wallpaper history -
they live outside the dotfiles repo, in ~/.local/share/quickshell/theme-presets/.
"""
import json
import os
import re
import sys
sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
import render # noqa: E402 - theme/render.py: load_colors, render_all, reload_apps, COLORS
STORE = os.path.expanduser("~/.local/share/quickshell/theme-presets")
NAME_RE = re.compile(r"^[A-Za-z0-9 _-]{1,40}$")
DEFAULT_NAME = "Default"
DEFAULT_PALETTE = {
"accent": "#1793d1", "cursor": "#c0caf5",
"foreground": "#c0caf5", "background": "#1a1b26",
"selection_foreground": "#1a1b26", "selection_background": "#c0caf5",
"color0": "#1a1b26", "color1": "#f7768e", "color2": "#a6e3a1", "color3": "#f9e2af",
"color4": "#1793d1", "color5": "#cba6f7", "color6": "#89dceb", "color7": "#c0caf5",
"color8": "#565f89", "color9": "#f7768e", "color10": "#a6e3a1", "color11": "#f9e2af",
"color12": "#7aa2f7", "color13": "#cba6f7", "color14": "#89dceb", "color15": "#ffffff",
"bar_color": "#12131b", "pill_color": "#1a1b26", "popup_color": "#1a1b26",
"bar_opacity": 0.18, "pill_opacity": 0.85, "popup_opacity": 0.90, "terminal_opacity": 0.85,
}
def validate_name(name):
if name == DEFAULT_NAME:
sys.exit("presets.py: 'Default' is built in, can't save/delete over it")
if not NAME_RE.match(name):
sys.exit("presets.py: preset names may only use letters, digits, spaces, '-' and '_' "
"(max 40 characters)")
def path_for(name):
return os.path.join(STORE, f"{name}.json")
def list_names():
if not os.path.isdir(STORE):
return []
return sorted(f[:-5] for f in os.listdir(STORE) if f.endswith(".json"))
def load_preset(name):
try:
return json.load(open(path_for(name)))
except OSError:
sys.exit(f"presets.py: no preset named '{name}'")
def cmd_list():
current = render.load_colors()
out = [{"name": n, "current": load_preset(n) == current} for n in list_names()]
print(json.dumps(out))
def cmd_default():
current = render.load_colors()
print(json.dumps({"name": DEFAULT_NAME, "current": DEFAULT_PALETTE == current}))
def cmd_save(name):
validate_name(name)
os.makedirs(STORE, exist_ok=True)
json.dump(render.load_colors(), open(path_for(name), "w"), indent=1)
def cmd_load(name):
palette = DEFAULT_PALETTE if name == DEFAULT_NAME else load_preset(name)
current = render.load_colors()
if palette.keys() - current.keys():
sys.exit(f"presets.py: '{name}' has keys colors.toml doesn't know about "
f"({', '.join(sorted(palette.keys() - current.keys()))})")
# Reuses colors.toml's own regex-substitution updater (same one --set uses) instead of
# rewriting the file, so the comments/section headers a human wrote stay intact.
render.set_colors([(k, str(v)) for k, v in palette.items()])
render.render_all(render.load_colors())
render.reload_apps()
def cmd_delete(name):
validate_name(name)
path = path_for(name)
if not os.path.isfile(path):
sys.exit(f"presets.py: no preset named '{name}'")
os.remove(path)
def main():
args = sys.argv[1:]
if args[:1] == ["list"] and len(args) == 1:
cmd_list()
elif args[:1] == ["default"] and len(args) == 1:
cmd_default()
elif args[:1] == ["save"] and len(args) == 2:
cmd_save(args[1])
elif args[:1] == ["load"] and len(args) == 2:
cmd_load(args[1])
elif args[:1] == ["delete"] and len(args) == 2:
cmd_delete(args[1])
else:
sys.exit(__doc__)
if __name__ == "__main__":
main()

View File

@@ -5,7 +5,7 @@
render.py --no-reload same, but skip reloading apps (used right after --set, which reloads itself)
render.py --dump print every color as JSON (used by ThemeWidget.qml)
render.py --get KEY print one color (e.g. for shell scripts)
render.py --set KEY VALUE [KEY VALUE ...] change one or more colors in colors.toml, re-render, reload
render.py --set KEY VALUE [KEY VALUE ...] change one or more colors/opacities in colors.toml, re-render, reload
Templates live in theme/templates/<app>/{config.json,template}: config.json names the
template file and the destination it gets rendered to (~ expanded). Placeholders in a
@@ -42,7 +42,9 @@ def substitute(text, colors):
sys.exit(f"render.py: unknown color key '{key}' in template")
value = colors[key]
if fmt is None:
return value
return str(value)
if not isinstance(value, str):
sys.exit(f"render.py: '.{fmt}' needs a #rrggbb color, '{key}' is {value!r}")
if fmt == "strip":
return value.lstrip("#")
if fmt == "rgba":
@@ -70,6 +72,13 @@ def reload_apps():
subprocess.run(["hyprctl", "reload"], check=False, capture_output=True)
subprocess.run(["makoctl", "reload"], check=False, capture_output=True)
subprocess.run(["pkill", "--signal", "USR1", "-x", "kitty"], check=False, capture_output=True)
# Best-effort: tell the running shell (bar + theme widget, two separate IPC targets
# since they're two separate top-level QML components) to re-fetch the palette, for
# the bits of it (pill/popup/bar opacity) that only live in QML, not another app's
# config file. A no-op if quickshell isn't running.
for target in ("theme", "theme-widget"):
subprocess.run(["quickshell", "-c", "default", "ipc", "call", target, "changed"],
check=False, capture_output=True, timeout=3)
def set_colors(pairs):
@@ -78,12 +87,24 @@ def set_colors(pairs):
for key, value in pairs:
if key not in colors:
sys.exit(f"render.py: unknown color key '{key}'")
if not re.fullmatch(r"#[0-9a-fA-F]{6}", value):
sys.exit(f"render.py: '{value}' is not a #rrggbb color")
new_text, n = re.subn(rf"(?m)^{re.escape(key)}\s*=\s*\"#[0-9a-fA-F]{{6}}\"",
f'{key} = "{value.lower()}"', text)
if isinstance(colors[key], str):
if not re.fullmatch(r"#[0-9a-fA-F]{6}", value):
sys.exit(f"render.py: '{value}' is not a #rrggbb color")
literal = f'"{value.lower()}"'
pattern = r'"#[0-9a-fA-F]{6}"'
else:
try:
v = float(value)
except ValueError:
sys.exit(f"render.py: '{value}' is not a number (expected 0-1, for '{key}')")
if not 0 <= v <= 1:
sys.exit(f"render.py: '{value}' is out of range (expected 0-1, for '{key}')")
literal = repr(v)
pattern = r"[0-9]*\.?[0-9]+"
new_text, n = re.subn(rf"(?m)^{re.escape(key)}\s*=\s*{pattern}",
f"{key} = {literal}", text)
if n != 1:
sys.exit(f"render.py: could not find a single '{key} = \"...\"' line to replace")
sys.exit(f"render.py: could not find a single '{key} = ...' line to replace")
text = new_text
open(COLORS, "w").write(text)

View File

@@ -3,3 +3,4 @@
background {background}
foreground {foreground}
cursor {cursor}
background_opacity {terminal_opacity}