diff --git a/.gitignore b/.gitignore index c42aa6c..75e4a28 100644 --- a/.gitignore +++ b/.gitignore @@ -18,6 +18,7 @@ !/dolphinrc !/Thunar !/kdeglobals +!/sddm !/.gitignore !/README.md !/install.sh @@ -26,6 +27,11 @@ *.bak-* /hypr/backups/ +# Just a copy of hypr/wallpaper.png, refreshed by render.py's sync_sddm_theme() so the +# greeter (which can't read ~/.config) has its own copy - tracking it too would just +# double this repo's size with identical bytes. +/sddm/aether-rice/wallpaper.png + # Python bytecode cache (theme/presets.py imports theme/render.py as a module) __pycache__/ diff --git a/README.md b/README.md index dbff4da..8f01f8e 100644 --- a/README.md +++ b/README.md @@ -86,6 +86,28 @@ Theming used to go through a third-party app called aether; it's gone now (it di 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. +**The SDDM login screen** ([`sddm/aether-rice/`](sddm/aether-rice/)) is a custom theme matching the rest of the rice, palette-driven the same way as everything else - but it needs a one-time root setup that isn't part of `install.sh --deps`, since the greeter runs as its own `sddm` user and can't read anything under `~/.config` ($HOME is `700`): + +```bash +sudo mkdir -p /usr/share/sddm/themes/aether-rice +sudo chown "$USER":"$USER" /usr/share/sddm/themes/aether-rice # so render.py can sync it without sudo from here on +sudo mkdir -p /etc/sddm.conf.d +printf '[Theme]\nCurrent=aether-rice\n\n[X11]\nDisplayCommand=/usr/share/sddm/themes/aether-rice/Xsetup\n' | sudo tee /etc/sddm.conf.d/theme.conf +``` + +After that, `theme/render.py` (called by the widget on every palette change, same as everything else) copies the current wallpaper and re-renders [`theme/templates/sddm/theme.conf`](theme/templates/sddm/theme.conf) straight into that system path (`sync_sddm_theme()` in `render.py`) - no further sudo needed, and it's a silent no-op if the system dir doesn't exist yet or isn't writable, so a machine that skips this setup just doesn't get a themed login screen instead of erroring. + +Wallpaper changes need the same sync: `theme/wallpaper.py` doesn't go through `render.py` at all normally, so it calls `render.sync_sddm_theme()` itself directly at the end of `restart_wallpaper_daemon()` - without that, picking a new wallpaper in the widget would silently leave the login screen on the old one. + +Things specific to SDDM that don't come up anywhere else in this rice: +- **Each connected monitor gets its own separate `Main.qml` instance** (confirmed with `sddm-greeter --test-mode`, two monitors, two windows) with its own local coordinate space - a `screenModel`-with-manual-geometry-offset approach (the pattern used in SDDM's own bundled `maya` theme) would push each screen's background out of that screen's own view. Plain `anchors.fill: parent` is what actually works here. The login card itself is only shown where the `primaryScreen` context property is true, so a dual-monitor setup gets exactly one card, not one per screen. +- **Which monitor SDDM considers primary defaults to whichever it enumerates first, not the biggest one.** `sddm/aether-rice/Xsetup` (wired up as `DisplayCommand` above) runs `xrandr --output --primary` before the greeter starts to fix that - `` is picked dynamically as whichever connected output has the largest resolution, not hardcoded, since Xorg (particularly with the nvidia driver, in use here) often names outputs differently than Wayland/DRM does (e.g. `DP-0` vs. Hyprland's `DP-1`) - a name copied from `hyprctl monitors` can silently match nothing in the greeter's own X server. It logs what it found and did to `/tmp/aether-rice-xsetup.log` for the next login if it ever needs re-diagnosing. +- **`SddmComponents`' `ComboBox`/`LayoutBox` open their dropdown as a plain child `Rectangle` anchored below themselves, not an actual popup** - it paints under whatever comes later in the same `Column`, not over it. The session/layout row is the last thing in the card for exactly this reason; putting it anywhere earlier (e.g. above the Login button, as originally built) gets its dropdown list rendered underneath - technically open, but invisible and unclickable behind the buttons below it. +- **`SddmComponents`' own `Button` can get its background stuck on the wrong color** (e.g. hover) instead of reverting to idle - it drives color through named QML `states`, and once something sets `color` outside that state machine, the idle state has nothing correct left to revert to. `Main.qml`'s Login/Shutdown/Reboot buttons are plain `Rectangle` + `MouseArea` instead, with color bound directly to `containsMouse` - no state machine, nothing to get stuck. +- **The keyboard layout shows/applies as the wrong one until the first keypress, every time.** This is a confirmed, still-open upstream SDDM 0.21 bug ([sddm/sddm#1845](https://github.com/sddm/sddm/issues/1845)), reproducible with every theme including SDDM's own bundled ones (the maintainer asked reporters to test other themes - same result on all of them). Nothing in a theme's QML can fix a backend bug; two different `keyboard.currentLayout` reassignment workarounds were tried here and removed again since neither helped. + +`sddm-greeter --test-mode --theme ` can't verify everything: `sddm.hostName` comes back empty in test mode (no real greeter daemon behind it), so the heading shows "Welcome to" with nothing after it there specifically - expected to resolve once it's actually running as the login screen. Multi-monitor primary selection and the keyboard layout bug above need an actual logout to check, since test-mode doesn't run a real X server per screen or a real XKB backend. + 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. @@ -255,4 +277,5 @@ mako/ Notification daemon config (colors.ini generated by theme/render.py theme/ Palette source (colors.toml), per-app templates, render.py + wallpaper.py + presets.py btop/ System monitor config qt5ct/ qt6ct/ nwg-look/ gtk-3.0/ Qt/GTK theming +sddm/ Login screen theme (Main.qml, theme.conf generated by theme/render.py) - see Theming ``` diff --git a/sddm/aether-rice/Main.qml b/sddm/aether-rice/Main.qml new file mode 100644 index 0000000..f5b3f14 --- /dev/null +++ b/sddm/aether-rice/Main.qml @@ -0,0 +1,330 @@ +import QtQuick 2.0 +import SddmComponents 2.0 + +Rectangle { + id: root + color: "#000000" + + property color accent: config.accent ? config.accent : "#1793d1" + property color foreground: config.foreground ? config.foreground : "#c0caf5" + property color background: config.background ? config.background : "#1a1b26" + property color popupColor: config.popup_color ? config.popup_color : "#1a1b26" + property real popupOpacity: config.popup_opacity ? parseFloat(config.popup_opacity) : 0.9 + property color pillColor: config.pill_color ? config.pill_color : "#1a1b26" + property real pillOpacity: config.pill_opacity ? parseFloat(config.pill_opacity) : 0.85 + property color mutedColor: config.color8 ? config.color8 : "#565f89" + + // Same trick as Bar.qml/ThemeWidget.qml: turns a #rrggbb + 0-1 alpha into #aarrggbb, + // since theme.conf hands us plain hex strings and a separate opacity float, not a + // pre-blended color. + function argb(hex, alpha) { + var h = hex.toString().replace("#", "") + var a = Math.round(Math.max(0, Math.min(1, alpha)) * 255) + var aHex = a.toString(16).padStart(2, "0") + return "#" + aHex + h + } + + TextConstants { id: textConstants } + + signal tryLogin() + onTryLogin: sddm.login(userField.text, passwordField.text, sessionCombo.index) + + Connections { + target: sddm + function onLoginFailed() { + passwordField.text = "" + statusText.text = textConstants.loginFailed + } + function onLoginSucceeded() { + statusText.text = textConstants.loginSucceeded + } + } + + // Background: wallpaper.png is a plain copy of the active rice wallpaper, refreshed + // by theme/render.py on every render (see theme/templates/sddm/) - not templated + // itself, just kept in sync as a file. anchors.fill, not a screenModel Repeater with + // manual geometry offsets: SDDM gives each screen its own Main.qml instance already + // sized and locally-coordinated to just that screen (confirmed via test-mode with two + // monitors - a geometry-offset approach would push the image out of view). + Image { + anchors.fill: parent + source: "wallpaper.png" + fillMode: Image.PreserveAspectCrop + asynchronous: true + } + + Rectangle { + anchors.fill: parent + color: "#000000" + opacity: 0.45 + } + + // Clock pill, top right - shown on every screen, same look as the bar's pills + Rectangle { + anchors.top: parent.top + anchors.right: parent.right + anchors.margins: 24 + width: clockText.implicitWidth + 28 + height: 40 + radius: height / 2 + color: root.argb(pillColor, pillOpacity) + border.width: 1 + border.color: root.argb(accent, 0.25) + + Text { + id: clockText + anchors.centerIn: parent + color: foreground + font.family: "JetBrainsMono Nerd Font" + font.pixelSize: 15 + + property date now: new Date() + text: Qt.formatDateTime(now, "hh:mm ddd, d MMM") + + Timer { + interval: 1000; running: true; repeat: true + onTriggered: clockText.now = new Date() + } + } + } + + // Login card - only on the primary screen, so a multi-monitor setup gets exactly + // one, not one duplicated per screen. + Rectangle { + id: card + visible: primaryScreen + anchors.centerIn: parent + width: 400 + height: cardColumn.implicitHeight + 48 + radius: 14 + color: root.argb(popupColor, popupOpacity) + border.width: 1 + border.color: root.argb(accent, 0.35) + + Column { + id: cardColumn + anchors.centerIn: parent + width: parent.width - 64 + spacing: 14 + + Text { + width: parent.width + text: textConstants.welcomeText.arg(sddm.hostName) + color: accent + font.family: "JetBrainsMono Nerd Font" + font.bold: true + font.pixelSize: 20 + horizontalAlignment: Text.AlignHCenter + wrapMode: Text.WordWrap + } + + TextBox { + id: userField + width: parent.width + height: 40 + radius: 8 + color: background + borderColor: mutedColor + hoverColor: accent + focusColor: accent + textColor: foreground + font.family: "JetBrainsMono Nerd Font" + font.pixelSize: 14 + text: userModel.lastUser + + KeyNavigation.tab: passwordField + Keys.onReturnPressed: passwordField.forceActiveFocus() + } + + PasswordBox { + id: passwordField + width: parent.width + height: 40 + radius: 8 + color: background + borderColor: mutedColor + hoverColor: accent + focusColor: accent + textColor: foreground + font.family: "JetBrainsMono Nerd Font" + font.pixelSize: 14 + + KeyNavigation.tab: loginButton + Keys.onPressed: { + if (event.key === Qt.Key_Return || event.key === Qt.Key_Enter) { + root.tryLogin() + event.accepted = true + } + } + } + + // Login button: plain Rectangle + MouseArea, not SddmComponents' Button. + // That component's background can get stuck on its pressed/hover color + // instead of reverting to idle, because it drives color through named + // `states` while also assigning it as a plain (non-bound) property - once + // something sets it outside the state machine, the "idle" state has nothing + // to revert to. Binding color straight to containsMouse here has no such + // intermediate state to get stuck in. + Rectangle { + id: loginButton + width: parent.width + height: 40 + radius: 8 + color: loginArea.containsMouse ? Qt.lighter(accent, 1.15) : accent + + Text { + anchors.centerIn: parent + text: textConstants.login + color: "#0f111a" + font.family: "JetBrainsMono Nerd Font" + font.bold: true + font.pixelSize: 14 + } + + MouseArea { + id: loginArea + anchors.fill: parent + hoverEnabled: true + cursorShape: Qt.PointingHandCursor + onClicked: root.tryLogin() + } + + Keys.onReturnPressed: root.tryLogin() + KeyNavigation.tab: shutdownButton + } + + Text { + id: statusText + width: parent.width + height: 16 + horizontalAlignment: Text.AlignHCenter + color: "#e88388" + font.family: "JetBrainsMono Nerd Font" + font.pixelSize: 12 + } + + Row { + width: parent.width + spacing: 10 + + Rectangle { + id: shutdownButton + width: (parent.width - 10) / 2 + height: 36 + radius: 8 + color: shutdownArea.containsMouse ? root.argb(mutedColor, 0.35) : "transparent" + border.width: 1 + border.color: shutdownArea.containsMouse ? accent : mutedColor + + Text { + anchors.centerIn: parent + text: textConstants.shutdown + color: shutdownArea.containsMouse ? accent : foreground + font.family: "JetBrainsMono Nerd Font" + font.pixelSize: 12 + } + + MouseArea { + id: shutdownArea + anchors.fill: parent + hoverEnabled: true + cursorShape: Qt.PointingHandCursor + onClicked: sddm.powerOff() + } + + KeyNavigation.tab: rebootButton + } + + Rectangle { + id: rebootButton + width: (parent.width - 10) / 2 + height: 36 + radius: 8 + color: rebootArea.containsMouse ? root.argb(mutedColor, 0.35) : "transparent" + border.width: 1 + border.color: rebootArea.containsMouse ? accent : mutedColor + + Text { + anchors.centerIn: parent + text: textConstants.reboot + color: rebootArea.containsMouse ? accent : foreground + font.family: "JetBrainsMono Nerd Font" + font.pixelSize: 12 + } + + MouseArea { + id: rebootArea + anchors.fill: parent + hoverEnabled: true + cursorShape: Qt.PointingHandCursor + onClicked: sddm.reboot() + } + + KeyNavigation.tab: sessionCombo + } + } + + // Session/layout row last, not between the password field and the login + // button: SddmComponents' ComboBox/LayoutBox open their dropdown as a plain + // child Rectangle anchored below themselves, not a top-level popup - it + // paints under whatever comes after it in the Column (it did, right under + // the login/shutdown/reboot buttons, when this row was above them). Nothing + // else in the card comes after this row now, so there's nothing left to + // paint over it. + Row { + width: parent.width + spacing: 10 + + ComboBox { + id: sessionCombo + width: (parent.width - 10) / 2 + height: 36 + model: sessionModel + index: sessionModel.lastIndex + color: background + borderColor: mutedColor + hoverColor: accent + focusColor: accent + textColor: foreground + menuColor: background + font.family: "JetBrainsMono Nerd Font" + font.pixelSize: 12 + + KeyNavigation.tab: layoutBox + } + + LayoutBox { + id: layoutBox + width: (parent.width - 10) / 2 + height: 36 + color: background + borderColor: mutedColor + hoverColor: accent + focusColor: accent + textColor: foreground + menuColor: background + font.family: "JetBrainsMono Nerd Font" + font.pixelSize: 12 + + KeyNavigation.tab: userField + } + } + } + } + + // Note: the keyboard layout showing/defaulting to the wrong thing until the first + // keypress (github.com/sddm/sddm#1845) is a confirmed, still-open upstream SDDM 0.21 + // bug, reproducible with every theme including SDDM's own bundled ones - not + // something fixable from a theme's QML. Two different property-reassignment + // workarounds were tried here and removed again; neither helped, which tracks with + // this being a backend issue, not a frontend one. + + Component.onCompleted: { + if (primaryScreen) { + if (userField.text === "") + userField.forceActiveFocus() + else + passwordField.forceActiveFocus() + } + } +} diff --git a/sddm/aether-rice/Xsetup b/sddm/aether-rice/Xsetup new file mode 100755 index 0000000..9b6a359 --- /dev/null +++ b/sddm/aether-rice/Xsetup @@ -0,0 +1,36 @@ +#!/bin/sh +# Runs as root before the greeter appears (SDDM's [X11] DisplayCommand=). +# The biggest monitor isn't otherwise marked primary in a fresh X session - SDDM's own +# X server then just defaults to whichever output it enumerates first, which is why +# Main.qml's `primaryScreen` would land on the wrong screen without this. +# +# Not a hardcoded output name: Xorg (especially with the nvidia driver, in use here) +# often names outputs differently than Wayland/DRM does (e.g. "DP-0" vs Hyprland's +# "DP-1") - a name copied from `hyprctl monitors` can silently match nothing here. +# Picking by resolution instead works regardless of what this X server calls it. +BIGGEST=$(xrandr --query | awk ' + /^[A-Za-z0-9_-]+ connected/ { + name = $1 + for (i = 1; i <= NF; i++) { + if ($i ~ /^[0-9]+x[0-9]+\+/) { + split($i, wh, "x") + split(wh[2], hxy, "+") + area = wh[1] * hxy[1] + if (area > maxarea) { maxarea = area; biggest = name } + } + } + } + END { print biggest } +') +{ + echo "$(date -Iseconds) xrandr --query:" + xrandr --query + echo "$(date -Iseconds) picked biggest output: '$BIGGEST'" + if [ -n "$BIGGEST" ]; then + xrandr --output "$BIGGEST" --primary + echo "$(date -Iseconds) xrandr --output $BIGGEST --primary exit code: $?" + fi +} >/tmp/aether-rice-xsetup.log 2>&1 + +# Preserve whatever the stock script does, in case a future sddm update adds to it. +exec /usr/share/sddm/scripts/Xsetup "$@" diff --git a/sddm/aether-rice/metadata.desktop b/sddm/aether-rice/metadata.desktop new file mode 100644 index 0000000..c905bd7 --- /dev/null +++ b/sddm/aether-rice/metadata.desktop @@ -0,0 +1,12 @@ +[SddmGreeterTheme] +Name=aether-rice +Description=Palette-driven SDDM theme matching the rest of the rice +Author=nico +Copyright=(c) 2026, nico +License=MIT +Type=sddm-theme +Version=1.0 +MainScript=Main.qml +ConfigFile=theme.conf +Theme-Id=aether-rice +Theme-API=2.0 diff --git a/sddm/aether-rice/theme.conf b/sddm/aether-rice/theme.conf new file mode 100644 index 0000000..c3c2fe7 --- /dev/null +++ b/sddm/aether-rice/theme.conf @@ -0,0 +1,9 @@ +[General] +accent=#1793d1 +foreground=#c0caf5 +background=#1a1b26 +popup_color=#1a1b26 +popup_opacity=0.9 +pill_color=#1a1b26 +pill_opacity=0.85 +color8=#565f89 diff --git a/theme/render.py b/theme/render.py index 000b382..e0c1299 100755 --- a/theme/render.py +++ b/theme/render.py @@ -15,6 +15,7 @@ alpha - what KDE's kdeglobals/*.colors files use), or {key.rgba:ALPHA}. import json import os import re +import shutil import subprocess import sys import tomllib @@ -25,6 +26,10 @@ HERE = os.path.dirname(os.path.abspath(__file__)) COLORS = os.path.join(HERE, "colors.toml") TEMPLATES = os.path.join(HERE, "templates") +SDDM_THEME_SRC = os.path.expanduser("~/.config/sddm/aether-rice") +SDDM_THEME_DEST = "/usr/share/sddm/themes/aether-rice" +WALLPAPER = os.path.expanduser("~/.config/hypr/wallpaper.png") + PLACEHOLDER = re.compile(r"\{([a-zA-Z0-9_]+)(?:\.([a-zA-Z0-9_]+))?(?::([^}]+))?\}") @@ -74,6 +79,27 @@ def render_all(colors): print(f"rendered {app} -> {dest}") icon_theme.render(colors) print(f"rendered gtk3-icons -> {icon_theme.DEST_THEME}") + sync_sddm_theme() + + +def sync_sddm_theme(): + """Copies the wallpaper into the SDDM theme dir, then mirrors that whole (small) + dir to /usr/share/sddm/themes/aether-rice - the greeter can't read anything under + ~/.config (it runs as its own user, and $HOME is 700), so this is the live copy it + actually loads. No sudo here: /usr/share/sddm/themes/aether-rice is set up once + (see README) with its ownership handed to this user, specifically so this can run + on every render like everything else. A no-op, not an error, if that hasn't been + done yet - the theme link just won't be enabled until it has. + """ + if not os.path.isdir(SDDM_THEME_SRC): + return + if os.path.isfile(WALLPAPER): + shutil.copy2(WALLPAPER, os.path.join(SDDM_THEME_SRC, "wallpaper.png")) + if not os.path.isdir(SDDM_THEME_DEST) or not os.access(SDDM_THEME_DEST, os.W_OK): + return + for name in os.listdir(SDDM_THEME_SRC): + shutil.copy2(os.path.join(SDDM_THEME_SRC, name), os.path.join(SDDM_THEME_DEST, name)) + print(f"synced sddm theme -> {SDDM_THEME_DEST}") def reload_apps(): diff --git a/theme/templates/sddm/config.json b/theme/templates/sddm/config.json new file mode 100644 index 0000000..dab633d --- /dev/null +++ b/theme/templates/sddm/config.json @@ -0,0 +1,4 @@ +{ + "template": "theme.conf", + "destination": "~/.config/sddm/aether-rice/theme.conf" +} diff --git a/theme/templates/sddm/theme.conf b/theme/templates/sddm/theme.conf new file mode 100644 index 0000000..c9bed6c --- /dev/null +++ b/theme/templates/sddm/theme.conf @@ -0,0 +1,9 @@ +[General] +accent={accent} +foreground={foreground} +background={background} +popup_color={popup_color} +popup_opacity={popup_opacity} +pill_color={pill_color} +pill_opacity={pill_opacity} +color8={color8} diff --git a/theme/wallpaper.py b/theme/wallpaper.py index f9dc3f0..cbe4f28 100755 --- a/theme/wallpaper.py +++ b/theme/wallpaper.py @@ -29,6 +29,8 @@ import subprocess import sys import time +import render + ACTIVE = os.path.expanduser("~/.config/hypr/wallpaper.png") ARCHIVE = os.path.expanduser("~/.local/share/quickshell/wallpapers") MANIFEST = os.path.join(ARCHIVE, "manifest.json") @@ -100,6 +102,9 @@ def restart_wallpaper_daemon(): subprocess.Popen(["swaybg", "-i", ACTIVE, "-m", "fill"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, start_new_session=True) + render.sync_sddm_theme() # wallpaper.py never calls render.py, so this doesn't + # happen automatically otherwise - the login screen's + # background would just keep showing whatever it last was. def cmd_list():