Compare commits
7
Commits
15e081e52d
...
f7b12bc7cd
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f7b12bc7cd | ||
|
|
b3c3cc38f0 | ||
|
|
27b924f5e9 | ||
|
|
38608c4008 | ||
|
|
05d26e386f | ||
|
|
2bf71494f4 | ||
|
|
3aecaf9de5 |
@@ -74,6 +74,9 @@ nix build .#nixosConfigurations.mercury-vm.config.system.build.vm -o result
|
||||
nix build .#nixosConfigurations.jupiter-vbox.config.system.build.virtualBoxOVA
|
||||
# end-to-end VM test of `deploy kexec-local` (~45s once the tarball is built)
|
||||
nix build .#checks.x86_64-linux.kexec-local -L
|
||||
# VM test of luna's app hosting on mars (hosts/mars/luna-sites.nix): podman socket
|
||||
# proxy, registry validation, caddy routes, reboot persistence
|
||||
nix build .#checks.x86_64-linux.luna-sites -L
|
||||
```
|
||||
|
||||
`checks.kexec-local` is the only way to exercise `kexec-local` at all: it jumps the
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
|
||||
Flake-based NixOS config. Hosts: `jupiter` (ZimaBlade, NAS + services),
|
||||
`neptun` (netcup VPS: public reverse proxy, Authentik, headscale),
|
||||
`mercury` (Raspberry Pi 3B+, DNS/DHCP), `terra` (desktop), `mars` (on-site,
|
||||
single-purpose: Hermes Agent only).
|
||||
`mercury` (Raspberry Pi 3B+, DNS/DHCP), `terra` (desktop), `mars` (on-site:
|
||||
Hermes Agent, plus the LAN web apps luna hosts at `http://mars.sol/<name>/`).
|
||||
|
||||
## Structure
|
||||
|
||||
@@ -27,9 +27,12 @@ hosts/
|
||||
vm.nix # VirtualBox test image (jupiter-vbox)
|
||||
neptun/ # netcup public reverse proxy + tailnet node
|
||||
configuration.nix disk-config.nix hardware-configuration.nix secrets.nix
|
||||
mars/ # on-site, single-purpose: Hermes Agent only
|
||||
mars/ # on-site: Hermes Agent + luna's LAN web apps
|
||||
configuration.nix disk-config.nix hardware-configuration.nix secrets.nix
|
||||
hermes-agent.nix # Hermes Agent (moved here from jupiter)
|
||||
luna-sites.nix # luna's apps: rootless podman + caddy, no nix edit per app
|
||||
luna-sites-README.md # what luna is told (mounted into her container)
|
||||
luna-sites-test.nix # VM test: nix build .#checks.x86_64-linux.luna-sites -L
|
||||
secrets/ # age-encrypted sops files, one per host
|
||||
scripts/ # deploy, edit_secrets
|
||||
```
|
||||
|
||||
+102
-13
@@ -4,38 +4,127 @@ This file provides guidance to Claude Code (claude.ai/code) when working with co
|
||||
|
||||
## What this is
|
||||
|
||||
A [Quickshell](https://quickshell.org/) configuration — a QML-based Wayland desktop shell (bar, launcher, tray, decorations) for a Hyprland/wlroots setup. `~/.config/quickshell` is a symlink to this repo, so Quickshell loads `shell.qml` here as the "default" config.
|
||||
A [Quickshell](https://quickshell.org/) configuration — a QML-based Wayland desktop shell (bar, launcher, tray, decorations) for a Hyprland/wlroots setup. `shell.qml` is the entry point.
|
||||
|
||||
## Running / testing changes
|
||||
|
||||
**`~/.config/quickshell` is NOT a symlink to this repo.** `hosts/terra/home.nix`
|
||||
ships the tree with `xdg.configFile."quickshell"`, which COPIES it into the nix
|
||||
store, so the config directory is a read-only symlink into `/nix/store/...`.
|
||||
Editing a file here therefore changes nothing about the running shell: it is
|
||||
watching the frozen store copy, and every edit would otherwise cost a
|
||||
`nixos-rebuild`. Two consequences worth knowing before debugging anything:
|
||||
|
||||
- **A new file must be `git add`ed before it can be deployed at all.** Flakes
|
||||
read the git tree, and untracked files are silently dropped — with no warning
|
||||
and no eval error. An untracked module that `shell.qml` imports produces a
|
||||
deployed config that fails to load, which does not surface until the next
|
||||
restart because the running shell keeps serving the store path it resolved at
|
||||
launch.
|
||||
- To check what a deploy actually shipped, compare the evaluated source with
|
||||
what is live:
|
||||
`nix eval --raw '.#nixosConfigurations.terra.config.home-manager.users.darman.xdg.configFile."quickshell".source'`
|
||||
then `ls` that path against `ls -l ~/.config/quickshell`.
|
||||
|
||||
```sh
|
||||
qs # runs ~/.config/quickshell/shell.qml (this repo, since it's the symlinked default config)
|
||||
qs -p . # run this directory explicitly regardless of symlink
|
||||
qs -n # exit immediately if another instance is already running (use to avoid duplicate shells while iterating)
|
||||
nix develop # then: qs-dev — swap the running shell for the WORKING TREE, no rebuild
|
||||
qs # runs the packaged (store) config
|
||||
qs -p . # run this directory explicitly
|
||||
qs -n # exit immediately if another instance is already running
|
||||
qs kill # kill the default-config instance ('qs kill -p <path>' for a working-tree one)
|
||||
```
|
||||
|
||||
Quickshell hot-reloads QML on file save when already running, so for most edits just save and check the running instance rather than restarting `qs`. It watches file CONTENT: `touch` alone never reloads (mtime is not a change), while any real edit does, including inode-replacing ones (`sed -i`, `perl -i`). A save that is not picked up leaves the shell rendering the previous config with no error — `qs log` shows a `Reloading configuration...` line for every save it saw, so that is the check. There is no separate build/lint/test tooling in this repo — verification is visual/behavioral via the running shell. `qmlls` (QML language server) is configured via `.qmlls.ini` for editor diagnostics.
|
||||
`qs-dev` is the edit-save-see loop: it starts a working-tree instance, waits
|
||||
until it is confirmed up, and only then kills the packaged one, so a QML error
|
||||
leaves you on your normal bar instead of no bar. It is a SWAP rather than a
|
||||
second instance because quickshell keys instance identity on the config path —
|
||||
two instances would both map layer-shell bars onto every output. See the
|
||||
`nix develop` block in `flake.nix`.
|
||||
|
||||
Pointed at the working tree, quickshell hot-reloads on file save. It watches
|
||||
file CONTENT: `touch` alone never reloads (mtime is not a change), while any
|
||||
real edit does, including inode-replacing ones (`sed -i`, `perl -i`). A save
|
||||
that is not picked up leaves the shell rendering the previous config with no
|
||||
error — `qs log` shows a `Reloading configuration...` line for every save it
|
||||
saw, so that is the check.
|
||||
|
||||
A single component can also be run in isolation, which is the way to exercise
|
||||
something that owns a service or a surface without bringing up the whole rail:
|
||||
point `qs -p` at a scratch directory whose `shell.qml` instantiates only that
|
||||
component, with the repo's directories symlinked in for the `qs.` imports.
|
||||
|
||||
There is no build/lint/test tooling wired up in this repo, but two things are
|
||||
worth reaching for. `qmllint` (from qtdeclarative) catches syntax and binding
|
||||
errors without a compositor — expect noise from the synthesized `qs.*` modules
|
||||
and the `Theme` singleton, which it cannot resolve:
|
||||
|
||||
```sh
|
||||
qmllint -I <qtdeclarative>/lib/qt-6/qml -I <quickshell>/lib/qt-6/qml -I . <file>.qml
|
||||
```
|
||||
|
||||
And `tools/quickshell-preview/render.sh` renders an `Item`-rooted component to
|
||||
a PNG offscreen (see `tests/`). Keep production `PanelWindow` wrappers thin and
|
||||
put the visuals in an `Item` so they can go through that path. `qmlls` is
|
||||
configured via `.qmlls.ini` for editor diagnostics.
|
||||
|
||||
## Architecture
|
||||
|
||||
`shell.qml` is the entry point: a `Scope` that instantiates the top-level pieces — `Bar`, `BarBottom`, `BarTop`, and a hidden `Launcher` — as siblings. Each top-level widget manages its own `PanelWindow`(s); there's no central layout manager.
|
||||
`shell.qml` is a `Scope` instantiating the top-level pieces as siblings:
|
||||
`HyprChromeShell` (the status rail), the eleven launcher variants,
|
||||
`Notifications`, `VolumeOsd` and `Vitals`. Each manages its own
|
||||
`PanelWindow`(s); there is no central layout manager.
|
||||
|
||||
The one exception, and the pattern to follow for anything new that needs it, is
|
||||
`HyprChromeShell`: it owns the state its surfaces have to AGREE on rather than
|
||||
letting each decide — which monitor they live on, the rail's density, whether a
|
||||
polkit prompt is open, and the layer pair. A second reader is what makes a
|
||||
property shell state; the file's own header comment enumerates them and says
|
||||
why each qualifies. Layer levels in particular are derived TOGETHER, because
|
||||
two surfaces on one layer stack by creation order while one layer apart is a
|
||||
guarantee.
|
||||
|
||||
**Import convention**: QML modules are imported by their path under the repo root using the `qs.` namespace, e.g. `import qs.widgets.launcher`, `import qs.widgets.decoration`. Sibling files in the same directory are imported with a relative string import instead (e.g. `Bar.qml` does `import "modules"`).
|
||||
|
||||
**Multi-monitor**: Bar/BarTop/BarBottom each wrap their `PanelWindow` in `Variants { model: Quickshell.screens }`, so one window instance is created per connected screen. `pragma ComponentBehavior: Bound` + `required property var modelData` is the standard pattern for these per-screen delegates.
|
||||
**Multi-monitor**: a surface that must exist on every screen wraps its
|
||||
`PanelWindow` in `Variants { model: Quickshell.screens }`, one instance per
|
||||
connected screen; `pragma ComponentBehavior: Bound` + `required property var
|
||||
modelData` is the standard pattern for those delegates. A surface that belongs
|
||||
to ONE screen instead takes it as a property from the shell. Note
|
||||
`Quickshell.screens` is a QML list, not a JS array — no `.find()` or `.filter()`
|
||||
on it, hence the index loops in `HyprChromeShell`.
|
||||
|
||||
**Directory layout**:
|
||||
- `widgets/bar/` — `Bar.qml` is the main sidebar (right-anchored, full height) hosting the module stack (date, clock, tray, decorative dividers); `BarTop.qml`/`BarBottom.qml` are thin accent-colored strips anchored to the top/bottom edges.
|
||||
- `widgets/bar/modules/` — individual bar widgets (`Clock`, `Date`, `Tray`/`TrayItem`, `Volume`) built on the shared `BarWidget` base component.
|
||||
- `widgets/launcher/` — shared `AppModel` search/execution plus eight launcher variants. `ApplicationLauncher` (variant 8 and the primary `SUPER` launcher) keeps its visual core in the headlessly renderable `ApplicationLauncherContent`; variants 1–7 remain available on `SUPER CTRL 1–7` for comparison.
|
||||
- `HyprChrome/` — the current shell. `Widgets/HyprChromeShell.qml` is the owner
|
||||
described above; `Widgets/ChromeBackdrop.qml` is the scrim (dim + drafting
|
||||
grid) shared by the rail and the polkit prompt; `Widgets/Bar/` holds the rail
|
||||
and its panels, with `Bar/Panels/BarPanel.qml` the chamfered chrome they all
|
||||
extend; `Widgets/Polkit/` is the authentication agent and its dialog;
|
||||
`Widgets/Launcher/` is the primary application launcher (`SUPER_L`);
|
||||
`Theme/Theme.qml` is this tree's palette singleton. `DebugWindow.qml` stages a
|
||||
single widget on the secondary monitor for eyeballing it in isolation.
|
||||
|
||||
The prompt and the launcher are MODALS: each raises the shared scrim, lands
|
||||
on the focused monitor, and takes the keyboard off the rail. That is why the
|
||||
shell instantiates them rather than `shell.qml` — see `modalOpen` there, which
|
||||
is the one place a new modal has to be named.
|
||||
- `widgets/bar/` — `DenseBar` and `StatusBarPanel`, the rail's predecessor. Not
|
||||
instantiated by `shell.qml` any more; `StatusBarPanel` is still used by the
|
||||
remaining launcher variants.
|
||||
- `widgets/launcher/` — shared `AppModel` search/execution plus the ten launcher
|
||||
variants still under evaluation, on `SUPER CTRL 1–11`. Variant 8 has moved to
|
||||
`HyprChrome/Widgets/Launcher/`; `AppModel.qml` is duplicated there so the
|
||||
HyprChrome tree stands alone, and this copy goes when the variants do.
|
||||
- `widgets/decoration/` — reusable QtQuick `Shape`-based visual accents (angled panel edges, slashes) used to give bar panels their non-rectangular look. `Dummy.qml` is a placeholder/test rectangle.
|
||||
- `widgets/input/` — thin wrappers around `QtQuick.Controls` inputs (currently just `TextField`).
|
||||
- `widgets/layout/` — `HorizontalStack`/`VerticalStack`: `RowLayout`/`ColumnLayout` wrappers that expose `default property alias content` for terser call sites, with a trailing filler `Item` that soaks up remaining space.
|
||||
- `assets/` — SVG icons referenced via `file://${Quickshell.shellDir}/assets/...`.
|
||||
|
||||
**Styling**: All colors and font families come from the `Theme` singleton
|
||||
(`widgets/theme/Theme.qml`, `import qs.widgets.theme`) — there are no color or
|
||||
font literals left anywhere under `widgets/`. Add a token there rather than
|
||||
**Styling**: All colors and font families come from a `Theme` singleton — there
|
||||
are no color or font literals left anywhere under `widgets/`. There are TWO,
|
||||
carrying the same palette for the two trees: `widgets/theme/Theme.qml`
|
||||
(`import qs.widgets.theme`) and `HyprChrome/Theme/Theme.qml`
|
||||
(`import qs.HyprChrome.Theme`). Match the one your file's tree already uses; a
|
||||
token added to one does not exist in the other. Add a token rather than
|
||||
hardcoding a value; alpha variants of the two main colors go through
|
||||
`Theme.textAlpha(a)` / `Theme.accentAlpha(a)` instead of a hand-written
|
||||
`Qt.rgba(...)`. Metrics (sizes, spacing) are still per-component.
|
||||
|
||||
+1
-1
@@ -4,7 +4,7 @@ import Quickshell
|
||||
import Quickshell.Hyprland
|
||||
import Quickshell.Wayland
|
||||
import QtQuick
|
||||
import qs.widgets.theme
|
||||
import qs.HyprChrome.Theme
|
||||
|
||||
// Debug stage: a bare, chrome-less staging area in the middle of ONE monitor
|
||||
// (the secondary by default), used to look at a widget in isolation before it
|
||||
@@ -0,0 +1,182 @@
|
||||
pragma ComponentBehavior: Bound
|
||||
|
||||
import Quickshell
|
||||
import Quickshell.Io
|
||||
import Quickshell.Wayland
|
||||
import QtQuick
|
||||
import qs.HyprChrome.Theme
|
||||
import qs.HyprChrome.Widgets.Polkit
|
||||
|
||||
// GUI password prompt for `sudo -A`, reusing the polkit dialog.
|
||||
//
|
||||
// sudo does NOT speak polkit — it is setuid + PAM reading your tty, and no
|
||||
// sudoers option bridges the two. What it does support is an ASKPASS helper: a
|
||||
// program it runs to obtain the password, which prints it on stdout. So this is
|
||||
// not the polkit agent serving sudo; it is a second, separate path that happens
|
||||
// to render the same dialog.
|
||||
//
|
||||
// Flow, driven by the helper in home.nix (`qs-askpass`):
|
||||
//
|
||||
// sudo -A
|
||||
// -> qs-askpass makes a 0600 fifo under XDG_RUNTIME_DIR
|
||||
// -> qs ipc call askpass prompt "<prompt>" "<fifo>" (returns at once)
|
||||
// -> this dialog opens, user types
|
||||
// -> a one-line writer is started here, secret written to its STDIN
|
||||
// -> qs-askpass reads the fifo and prints the secret on stdout
|
||||
// -> sudo reads it
|
||||
//
|
||||
// The secret travels on a pipe the whole way. It is never an argument and never
|
||||
// an environment variable, so it does not appear in /proc for any process — the
|
||||
// fifo PATH is in argv, which is not secret. It does cross more process
|
||||
// boundaries than the polkit path, where the password stays inside the PAM
|
||||
// conversation; that is the inherent cost of askpass, not of this design.
|
||||
//
|
||||
// Cancelling answers with an empty line, so the helper reads nothing, exits
|
||||
// non-zero, and sudo aborts rather than burning a retry on a blank password.
|
||||
Scope {
|
||||
id: root
|
||||
|
||||
// Which output to appear on; the shell puts it on the focused monitor.
|
||||
property var screen: null
|
||||
|
||||
// The fifo the helper is blocked reading. Non-empty means a request is in
|
||||
// flight, which is exactly what "a prompt is open" means here.
|
||||
property string fifoPath: ""
|
||||
property string promptText: ""
|
||||
property bool failed: false
|
||||
|
||||
readonly property bool active: root.fifoPath !== ""
|
||||
|
||||
// Held only between submit and the writer process actually starting: a
|
||||
// Process cannot be written to before it is running.
|
||||
property string pendingSecret: ""
|
||||
|
||||
IpcHandler {
|
||||
target: "askpass"
|
||||
|
||||
// Called by qs-askpass. Returns immediately — the helper blocks on the
|
||||
// fifo, not on this call, because an IpcHandler function runs on the
|
||||
// QML thread and blocking here would freeze the whole shell.
|
||||
function prompt(message: string, fifo: string): string {
|
||||
if (root.active)
|
||||
return "busy";
|
||||
|
||||
root.promptText = message === "" ? "Password:" : message;
|
||||
root.fifoPath = fifo;
|
||||
root.failed = false;
|
||||
return "ok";
|
||||
}
|
||||
|
||||
// So a helper that times out can take the dialog down with it rather
|
||||
// than leaving it on screen with nothing listening.
|
||||
function cancel(): string {
|
||||
root.dismiss();
|
||||
return "ok";
|
||||
}
|
||||
}
|
||||
|
||||
// Cancelling answers with an EMPTY line rather than by closing silently:
|
||||
// the helper then reads zero bytes and exits non-zero, so sudo aborts
|
||||
// instead of spending a retry on a blank password.
|
||||
function dismiss() {
|
||||
root.respond("");
|
||||
}
|
||||
|
||||
function submit(secret) {
|
||||
root.respond(secret);
|
||||
}
|
||||
|
||||
// The writer reads ONE LINE and exits; it does not wait for EOF.
|
||||
//
|
||||
// The obvious version — `cat > fifo`, write the secret, then close stdin by
|
||||
// setting stdinEnabled false — does not terminate. Measured: the secret
|
||||
// arrives intact but `cat` never sees EOF, so the fifo is never closed and
|
||||
// the helper blocks until its timeout. sudo would hang after you typed.
|
||||
//
|
||||
// A single `read` needs no EOF at all: the trailing newline ends it, the
|
||||
// shell writes what it got and exits, and THAT close is what gives the
|
||||
// helper its EOF. `IFS=` keeps leading and trailing whitespace, `-r` keeps
|
||||
// backslashes, and the secret still travels on stdin rather than in argv.
|
||||
function respond(secret) {
|
||||
if (!root.active)
|
||||
return;
|
||||
|
||||
root.pendingSecret = secret + "\n";
|
||||
writer.command = ["sh", "-c", "IFS= read -r line; printf %s \"$line\" > \"$1\"", "sh", root.fifoPath];
|
||||
writer.running = true;
|
||||
root.fifoPath = "";
|
||||
}
|
||||
|
||||
// Opening a fifo for writing BLOCKS until a reader attaches, which is why
|
||||
// this is a subprocess rather than a FileView: the helper's `cat` is that
|
||||
// reader, and blocking the QML thread on it would freeze the shell.
|
||||
Process {
|
||||
id: writer
|
||||
|
||||
stdinEnabled: true
|
||||
|
||||
// Written on `started`, not at respond() time: a Process has no stdin
|
||||
// to write to until it is actually running.
|
||||
onStarted: {
|
||||
writer.write(root.pendingSecret);
|
||||
root.pendingSecret = "";
|
||||
}
|
||||
}
|
||||
|
||||
PanelWindow {
|
||||
id: win
|
||||
|
||||
screen: root.screen
|
||||
visible: root.active
|
||||
|
||||
WlrLayershell.layer: WlrLayer.Overlay
|
||||
WlrLayershell.keyboardFocus: WlrKeyboardFocus.Exclusive
|
||||
exclusionMode: ExclusionMode.Ignore
|
||||
color: Theme.textAlpha(0)
|
||||
|
||||
anchors {
|
||||
top: true
|
||||
left: true
|
||||
right: true
|
||||
bottom: true
|
||||
}
|
||||
|
||||
// No click-off dismissal, for the same reason the polkit dialog has
|
||||
// none: something is blocked waiting on the answer, and losing it to a
|
||||
// stray click would leave sudo hanging with no visible cause.
|
||||
|
||||
PolkitPromptContent {
|
||||
id: content
|
||||
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
y: Math.max(32, Math.round(parent.height / 3 - height / 2))
|
||||
width: 520
|
||||
|
||||
// Deliberately the polkit dialog's own content component: this is a
|
||||
// password prompt with the same shape, and keeping one means a
|
||||
// restyle of PolkitPanel covers both. `identities` stays empty —
|
||||
// sudo offers no choice of who authenticates — which hides the
|
||||
// picker and the "AS" line on its own.
|
||||
message: "Authentication is required to run a command as another user"
|
||||
actionId: "sudo"
|
||||
iconName: ""
|
||||
showIcon: false
|
||||
identities: []
|
||||
|
||||
responseRequired: true
|
||||
inputPrompt: root.promptText
|
||||
responseVisible: false
|
||||
failed: root.failed
|
||||
|
||||
onSubmitted: value => root.submit(value)
|
||||
onCancelled: root.dismiss()
|
||||
}
|
||||
|
||||
onVisibleChanged: {
|
||||
if (win.visible) {
|
||||
content.clearResponse();
|
||||
content.focusInput();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+2
-2
@@ -1,8 +1,8 @@
|
||||
pragma ComponentBehavior: Bound
|
||||
|
||||
import QtQuick
|
||||
import qs.hyprchrome.theme
|
||||
import qs.hyprchrome.widgets.panels
|
||||
import qs.HyprChrome.Theme
|
||||
import qs.HyprChrome.Widgets.Bar.Panels
|
||||
|
||||
// Staging widget for the debug window: a BarPanel carrying filler copy in both
|
||||
// of the panel's densities — the full block when expanded, one elided line when
|
||||
@@ -0,0 +1,69 @@
|
||||
pragma ComponentBehavior: Bound
|
||||
|
||||
import QtQuick
|
||||
import qs.HyprChrome.Theme
|
||||
import qs.HyprChrome.Widgets.Bar.Panels
|
||||
|
||||
// Staging slot for whatever is being worked on, sized to itself so it can be
|
||||
// dropped anywhere in the rail without a width. It counts seconds since the
|
||||
// shell loaded, which is the cheapest thing that proves the panel is live and
|
||||
// not a still frame — a reload visibly restarts it.
|
||||
//
|
||||
// It also stands ALONE between two spacers, so it is the pair of caps and
|
||||
// traces that a rail of butted panels never exercises: a right cap joining the
|
||||
// next panel's left cap across a gap, twice over.
|
||||
BarPanel {
|
||||
id: test
|
||||
|
||||
panelId: "TST"
|
||||
title: "TEST"
|
||||
meta: "STAGE"
|
||||
|
||||
property int seconds: 0
|
||||
|
||||
// Sized to its content, like the tray: a staging panel has no business
|
||||
// reserving a share of the rail.
|
||||
implicitWidth: Math.max(test.headerMinWidth,
|
||||
test.briefLeft + brief.implicitWidth + test.padding,
|
||||
test.padding * 2 + body.implicitWidth)
|
||||
|
||||
Timer {
|
||||
interval: 1000
|
||||
running: true
|
||||
repeat: true
|
||||
onTriggered: test.seconds++
|
||||
}
|
||||
|
||||
summary: Text {
|
||||
id: brief
|
||||
|
||||
text: "T+" + test.seconds
|
||||
color: Theme.accent
|
||||
font.family: Theme.displayFont
|
||||
font.pixelSize: 13
|
||||
font.bold: true
|
||||
}
|
||||
|
||||
Column {
|
||||
id: body
|
||||
|
||||
spacing: 2
|
||||
|
||||
Text {
|
||||
text: "T+" + test.seconds
|
||||
color: Theme.text
|
||||
font.family: Theme.displayFont
|
||||
font.pixelSize: 17
|
||||
font.bold: true
|
||||
font.letterSpacing: 1
|
||||
}
|
||||
|
||||
Text {
|
||||
text: "SECONDS SINCE LOAD"
|
||||
color: Theme.muted
|
||||
font.family: Theme.microFont
|
||||
font.pixelSize: 9
|
||||
font.letterSpacing: 1.4
|
||||
}
|
||||
}
|
||||
}
|
||||
+2
-2
@@ -4,8 +4,8 @@ import Quickshell
|
||||
import Quickshell.Io
|
||||
import QtQuick
|
||||
import QtQuick.Layouts
|
||||
import qs.hyprchrome.theme
|
||||
import qs.hyprchrome.widgets.panels
|
||||
import qs.HyprChrome.Theme
|
||||
import qs.HyprChrome.Widgets.Bar.Panels
|
||||
|
||||
// Host identity in the hyprchrome panel chrome: the machine's name set large,
|
||||
// with its timezone and the current date and time.
|
||||
@@ -0,0 +1,261 @@
|
||||
import QtQuick
|
||||
import QtQuick.Shapes
|
||||
import QtQuick.Layouts
|
||||
import Quickshell
|
||||
import Quickshell.Wayland
|
||||
import qs.HyprChrome.Theme
|
||||
import qs.HyprChrome.Widgets.Bar.Debug
|
||||
import qs.HyprChrome.Widgets.Bar.Host
|
||||
import qs.HyprChrome.Widgets.Bar.Vitals
|
||||
import qs.HyprChrome.Widgets.Bar.Workspaces
|
||||
import qs.HyprChrome.Widgets.Bar.Tray
|
||||
|
||||
// The dense status rail itself: one layer surface holding the panel row.
|
||||
//
|
||||
// It owns nothing shared — the screen, the density and its layer all arrive
|
||||
// from HyprChromeShell, which is also what keeps this surface and the backdrop
|
||||
// one layer apart. What it does own is its own measurement: `contentHeight` is
|
||||
// the settled height of the current density, which the shell hands to the
|
||||
// backdrop and which sizes the exclusive zone.
|
||||
PanelWindow {
|
||||
id: window
|
||||
|
||||
// Density for every panel on the rail; driven by the shell.
|
||||
property bool expanded: false
|
||||
|
||||
// Which layer to sit on. An int rather than a private decision: it is half
|
||||
// of a pair with the backdrop's, so the shell derives both. See
|
||||
// HyprChromeShell.
|
||||
property int wlrLayer: WlrLayer.Overlay
|
||||
|
||||
// Whether the rail should hold the keyboard, so ESC can close it. Driven by
|
||||
// the shell rather than derived from `expanded`, because the rail is not the
|
||||
// only thing that wants the keyboard: while a polkit prompt is up the shell
|
||||
// withholds this, so ESC reaches the DIALOG and dismisses that instead.
|
||||
// Once the prompt is gone the rail gets the keyboard back and a second ESC
|
||||
// closes the rail — one key, one thing at a time, innermost first.
|
||||
property bool grabsKeyboard: false
|
||||
|
||||
// EXCLUSIVE rather than OnDemand: OnDemand only offers focus to a surface
|
||||
// the user clicks, and the whole point here is to answer a keypress the
|
||||
// user has not aimed at anything. Taking the keyboard is defensible because
|
||||
// an expanded rail is already a modal-ish state — it dims the desktop
|
||||
// behind itself with the same scrim the prompt uses.
|
||||
WlrLayershell.keyboardFocus: window.grabsKeyboard
|
||||
? WlrKeyboardFocus.Exclusive
|
||||
: WlrKeyboardFocus.None
|
||||
|
||||
signal dismissed
|
||||
|
||||
// A layer surface only delivers keys to an item that has active focus, and
|
||||
// nothing in the rail wants focus for its own sake — the panels are
|
||||
// readouts. So one focus sink covers the whole surface. It re-takes focus
|
||||
// whenever the grab is handed back, since losing the surface's focus drops
|
||||
// the item's too.
|
||||
Item {
|
||||
id: keySink
|
||||
|
||||
anchors.fill: parent
|
||||
focus: true
|
||||
|
||||
Keys.onEscapePressed: event => {
|
||||
window.dismissed();
|
||||
event.accepted = true;
|
||||
}
|
||||
|
||||
Connections {
|
||||
target: window
|
||||
function onGrabsKeyboardChanged() {
|
||||
if (window.grabsKeyboard)
|
||||
keySink.forceActiveFocus();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Own namespace so a layerrule can exempt the rail from Hyprland's layer
|
||||
// animation without also catching the launchers, which share the default
|
||||
// "quickshell" namespace and do want their fade.
|
||||
WlrLayershell.namespace: "hyprchrome-bar"
|
||||
WlrLayershell.layer: window.wlrLayer
|
||||
|
||||
property int margin: 12
|
||||
|
||||
// The surface never resizes: it is always tall enough for the expanded
|
||||
// rail, and only the exclusive zone tracks the current state. Resizing a
|
||||
// layer surface makes Hyprland animate the change, which showed up as the
|
||||
// panels twitching a pixel or two the moment the collapse finished.
|
||||
//
|
||||
// The zone still follows the target height, so tiled windows reflow once
|
||||
// per toggle, at the start, and slide while the panels animate.
|
||||
readonly property real expandedContent: Math.max(hostPanel.expandedHeight, workspacesPanel.expandedHeight, vitalsPanel.expandedHeight, testPanel.expandedHeight, trayPanel.expandedHeight) + window.margin * 2
|
||||
readonly property real contentHeight: Math.max(hostPanel.targetHeight, workspacesPanel.targetHeight, vitalsPanel.targetHeight, testPanel.targetHeight, trayPanel.targetHeight) + window.margin * 2
|
||||
|
||||
implicitHeight: Math.round(window.expandedContent)
|
||||
|
||||
exclusionMode: ExclusionMode.Normal
|
||||
exclusiveZone: Math.round(window.contentHeight)
|
||||
|
||||
// Only the panels take input. Without this the surface would keep eating
|
||||
// clicks across its full height while the rail is collapsed.
|
||||
mask: Region {
|
||||
item: panelRow
|
||||
}
|
||||
|
||||
anchors { top: true; left: true; right: true; }
|
||||
|
||||
color: "transparent"
|
||||
|
||||
RowLayout {
|
||||
id: panelRow
|
||||
x: window.margin
|
||||
y: window.margin
|
||||
width: window.width - window.margin * 2
|
||||
spacing: 0
|
||||
|
||||
HostPanel {
|
||||
id: hostPanel
|
||||
|
||||
expanded: window.expanded
|
||||
// Workspaces butt against its right edge; the left end of the row is free.
|
||||
rightChamfer: false
|
||||
|
||||
toggleOnClick: false
|
||||
Layout.preferredWidth: 400
|
||||
Layout.fillHeight: true
|
||||
}
|
||||
|
||||
WorkspacesPanel {
|
||||
id: workspacesPanel
|
||||
|
||||
expanded: window.expanded
|
||||
// Mid-rail: a panel on either side, so neither corner is cut.
|
||||
leftChamfer: false
|
||||
rightChamfer: false
|
||||
|
||||
toggleOnClick: false
|
||||
// No preferred width: the panel sizes itself to however many outputs
|
||||
// the session has, the same way the tray sizes itself to its items.
|
||||
Layout.fillHeight: true
|
||||
}
|
||||
|
||||
VitalsPanel {
|
||||
id: vitalsPanel
|
||||
|
||||
expanded: window.expanded
|
||||
// Workspaces on the left, the spacer on the right — and a spacer is not
|
||||
// a panel, so that edge keeps its cut.
|
||||
leftChamfer: false
|
||||
|
||||
toggleOnClick: false
|
||||
Layout.preferredWidth: 500
|
||||
Layout.fillHeight: true
|
||||
}
|
||||
|
||||
// Slack on both sides of the staging panel, so it floats between the left
|
||||
// group and the tray rather than butting against either. Two spacers is
|
||||
// also what puts a gap on both of its sides, which is what gives it a cap
|
||||
// and a trace at each end.
|
||||
Item { Layout.fillWidth: true }
|
||||
|
||||
TestPanel {
|
||||
id: testPanel
|
||||
|
||||
expanded: window.expanded
|
||||
toggleOnClick: false
|
||||
Layout.fillHeight: true
|
||||
}
|
||||
|
||||
Item { Layout.fillWidth: true }
|
||||
|
||||
TrayPanel {
|
||||
id: trayPanel
|
||||
|
||||
expanded: window.expanded
|
||||
toggleOnClick: false
|
||||
Layout.fillHeight: true
|
||||
}
|
||||
}
|
||||
|
||||
// Traces between the panels' caps. They live here rather than in BarPanel
|
||||
// because the run they draw is the gap BETWEEN two panels, which is the one
|
||||
// piece of this geometry no panel can see. Laid over the row, in the row's
|
||||
// own coordinates, so a panel's x is directly usable.
|
||||
Item {
|
||||
id: traces
|
||||
|
||||
x: panelRow.x
|
||||
y: panelRow.y
|
||||
width: panelRow.width
|
||||
height: panelRow.height
|
||||
|
||||
// Consecutive PANELS, with the spacers dropped — a spacer has no caps, so
|
||||
// it is not something a trace can start or end at, and skipping it is
|
||||
// exactly what makes the trace span it. `rightChamfer` is the tell: an
|
||||
// Item put in the row for slack has no such property.
|
||||
readonly property var pairs: {
|
||||
const panels = [];
|
||||
for (let i = 0; i < panelRow.children.length; i++) {
|
||||
const child = panelRow.children[i];
|
||||
if (child.rightChamfer !== undefined)
|
||||
panels.push(child);
|
||||
}
|
||||
|
||||
// A cap only exists on an open chamfer, so a pair that has both is
|
||||
// exactly a pair with something to join.
|
||||
const found = [];
|
||||
for (let i = 0; i + 1 < panels.length; i++) {
|
||||
if (panels[i].rightChamfer && panels[i + 1].leftChamfer)
|
||||
found.push({ from: panels[i], to: panels[i + 1] });
|
||||
}
|
||||
return found;
|
||||
}
|
||||
|
||||
Repeater {
|
||||
model: traces.pairs
|
||||
|
||||
CapTrace {
|
||||
anchors.fill: parent
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// One run: out of a panel's top-right cap, along the top, one 45° step down
|
||||
// at the midpoint of the gap, then along the bottom into the next panel's
|
||||
// bottom-left cap. 45° means the step is as wide as it is tall, so the run
|
||||
// IS the drop — clamped if the gap is too narrow to fit it, which is the
|
||||
// only case where the angle gives.
|
||||
component CapTrace: Item {
|
||||
id: trace
|
||||
|
||||
required property var modelData
|
||||
|
||||
property int lineWidth: 3
|
||||
|
||||
readonly property real fromX: trace.modelData.from.x + trace.modelData.from.rightCapX
|
||||
readonly property real fromY: trace.modelData.from.y + trace.modelData.from.rightCapY
|
||||
readonly property real toX: trace.modelData.to.x + trace.modelData.to.leftCapX
|
||||
readonly property real toY: trace.modelData.to.y + trace.modelData.to.leftCapY
|
||||
|
||||
readonly property real drop: trace.toY - trace.fromY
|
||||
readonly property real gap: trace.toX - trace.fromX
|
||||
readonly property real step: Math.max(0, Math.min(Math.abs(trace.drop), trace.gap))
|
||||
readonly property real mid: (trace.fromX + trace.toX) / 2
|
||||
|
||||
Shape {
|
||||
anchors.fill: parent
|
||||
preferredRendererType: Shape.CurveRenderer
|
||||
|
||||
ShapePath {
|
||||
fillColor: "transparent"
|
||||
strokeColor: Theme.accent
|
||||
// Nothing to draw while the panels overlap, which they do for a frame
|
||||
// or two while the row is still laying itself out.
|
||||
strokeWidth: trace.gap > 0 ? trace.lineWidth : 0
|
||||
startX: trace.fromX; startY: trace.fromY
|
||||
PathLine { x: trace.mid - trace.step / 2; y: trace.fromY }
|
||||
PathLine { x: trace.mid + trace.step / 2; y: trace.toY }
|
||||
PathLine { x: trace.toX; y: trace.toY }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+55
-16
@@ -2,7 +2,7 @@ pragma ComponentBehavior: Bound
|
||||
|
||||
import QtQuick
|
||||
import QtQuick.Shapes
|
||||
import qs.hyprchrome.theme
|
||||
import qs.HyprChrome.Theme
|
||||
|
||||
// Chamfered panel chrome for the dense status rail: outline, corner accent
|
||||
// lines, header strip (id chip / title / meta / tick marks) and a collapsing
|
||||
@@ -82,7 +82,7 @@ Item {
|
||||
// Where the summary sits when collapsed: just past the slug chip, and
|
||||
// centred in the strip the panel collapses to, which is sized to the
|
||||
// summary itself (or the height floor, whichever is taller).
|
||||
readonly property real briefLeft: panel.headerContentWidth
|
||||
readonly property real briefLeft: panel.headerContentWidth + 6
|
||||
readonly property real collapsedHeight: Math.max(panel.minimumHeight, brief.height + panel.headerPadding * 2)
|
||||
readonly property real briefTop: Math.round((panel.collapsedHeight - brief.height) / 2)
|
||||
|
||||
@@ -135,6 +135,36 @@ Item {
|
||||
property int outlineWidth: 1
|
||||
readonly property int connectorWidth: panel.outlineWidth + 2
|
||||
|
||||
// A cut corner has nothing butting against it, so it gets capped: the very
|
||||
// corner the chamfer removed, put back OUTSIDE the panel as a detached
|
||||
// accent triangle. Its hypotenuse faces the cut and its right angle points
|
||||
// away, so the cap and the notch read as two halves of one corner.
|
||||
//
|
||||
// Nothing guards these — a chamfer that is off measures zero, which
|
||||
// collapses its triangle to no area at all, so one piece of geometry covers
|
||||
// both cases.
|
||||
//
|
||||
// capGap is the perpendicular distance from the chamfer, which is why the
|
||||
// per-axis shift is it over root 2 rather than the gap itself: the cap
|
||||
// moves along the cut's normal, not along an axis.
|
||||
property real capGap: 4
|
||||
readonly property real capOffset: panel.capGap / Math.SQRT2
|
||||
|
||||
// Where a trace attaches: the MIDDLE of the cap's outward-facing edge — the
|
||||
// vertical one, since a trace arrives horizontally — rather than the tip,
|
||||
// so the line meets the triangle's face instead of clipping its corner.
|
||||
// That edge runs from the cut's end to the corner, so its midpoint is the
|
||||
// half-way point between them, carried out by the same offset as the cap.
|
||||
//
|
||||
// The RAIL draws those traces, between one panel's right cap and the next
|
||||
// panel's left cap, because the run between two panels is the one piece of
|
||||
// this that no panel can see. All a panel owes it is where its own caps
|
||||
// ended up.
|
||||
readonly property real rightCapX: panel.width + panel.capOffset
|
||||
readonly property real rightCapY: (panel.offsetY + panel.activeChamfer) / 2 - panel.capOffset
|
||||
readonly property real leftCapX: -panel.capOffset
|
||||
readonly property real leftCapY: panel.height - panel.activeChamfer / 2 + panel.capOffset
|
||||
|
||||
Shape {
|
||||
id: panelShape
|
||||
anchors.fill: parent
|
||||
@@ -154,22 +184,31 @@ Item {
|
||||
PathLine { x: 0; y: panel.offsetY }
|
||||
}
|
||||
|
||||
// Connecting edges — drawn only on a side whose chamfer is off, which is
|
||||
// exactly where a neighbour butts against this panel.
|
||||
// Cap on the top-right chamfer: the corner the cut removed, sitting
|
||||
// just outside it. The two ends of its hypotenuse are the same points
|
||||
// the outline turns on, shifted clear along the cut's normal; the third
|
||||
// is the corner itself, which the outline never reaches.
|
||||
ShapePath {
|
||||
fillColor: "transparent"
|
||||
strokeColor: Theme.accent
|
||||
strokeWidth: panel.rightChamfer ? 0 : panel.connectorWidth
|
||||
startX: panelShape.width; startY: panel.offsetY
|
||||
PathLine { x: panelShape.width; y: panelShape.height }
|
||||
fillColor: Theme.accent
|
||||
strokeWidth: 0
|
||||
startX: panelShape.width - panel.rightCut + panel.capOffset; startY: panel.offsetY - panel.capOffset
|
||||
PathLine {
|
||||
x: panelShape.width + panel.capOffset
|
||||
y: (panel.rightChamfer ? panel.activeChamfer : panel.offsetY) - panel.capOffset
|
||||
}
|
||||
PathLine { x: panelShape.width + panel.capOffset; y: panel.offsetY - panel.capOffset }
|
||||
PathLine { x: panelShape.width - panel.rightCut + panel.capOffset; y: panel.offsetY - panel.capOffset }
|
||||
}
|
||||
|
||||
// Cap on the bottom-left chamfer, the same triangle mirrored, clearing
|
||||
// the panel in the other direction.
|
||||
ShapePath {
|
||||
fillColor: "transparent"
|
||||
strokeColor: Theme.accent
|
||||
strokeWidth: panel.leftChamfer ? 0 : panel.connectorWidth
|
||||
startX: 0; startY: panel.offsetY
|
||||
PathLine { x: 0; y: panelShape.height }
|
||||
fillColor: Theme.accent
|
||||
strokeWidth: 0
|
||||
startX: panel.leftCut - panel.capOffset; startY: panelShape.height + panel.capOffset
|
||||
PathLine { x: -panel.capOffset; y: panelShape.height - panel.leftCut + panel.capOffset }
|
||||
PathLine { x: -panel.capOffset; y: panelShape.height + panel.capOffset }
|
||||
PathLine { x: panel.leftCut - panel.capOffset; y: panelShape.height + panel.capOffset }
|
||||
}
|
||||
|
||||
// Upper left accent line
|
||||
@@ -206,7 +245,7 @@ Item {
|
||||
y: Math.round((panel.headerHeight - height) / 2)
|
||||
// Puts the title where the accent line ends: chip + headerPadding on
|
||||
// both sides of it.
|
||||
spacing: panel.headerPadding
|
||||
spacing: panel.headerPadding + 6
|
||||
|
||||
// Header slug — the one piece that survives a collapse, so the strip
|
||||
// still says which panel it is.
|
||||
@@ -223,7 +262,7 @@ Item {
|
||||
text: panel.panelId
|
||||
color: Theme.surface
|
||||
font.family: Theme.microFont
|
||||
font.pixelSize: 9
|
||||
font.pixelSize: 11
|
||||
font.bold: true
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -4,7 +4,7 @@ import Quickshell
|
||||
import Quickshell.Services.SystemTray
|
||||
import QtQuick
|
||||
import QtQuick.Shapes
|
||||
import qs.hyprchrome.theme
|
||||
import qs.HyprChrome.Theme
|
||||
|
||||
// One tray item as a chamfered cell. Declares `modelData` required so it can be
|
||||
// a Repeater delegate directly, without an Item wrapper in between.
|
||||
+2
-2
@@ -3,8 +3,8 @@ pragma ComponentBehavior: Bound
|
||||
import Quickshell
|
||||
import Quickshell.Services.SystemTray
|
||||
import QtQuick
|
||||
import qs.hyprchrome.theme
|
||||
import qs.hyprchrome.widgets.panels
|
||||
import qs.HyprChrome.Theme
|
||||
import qs.HyprChrome.Widgets.Bar.Panels
|
||||
|
||||
// System tray in the hyprchrome panel chrome, in both densities: the same
|
||||
// items, drawn large enough to hit when expanded and shrunk onto the header
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
pragma ComponentBehavior: Bound
|
||||
|
||||
import QtQuick
|
||||
import qs.hyprchrome.theme
|
||||
import qs.HyprChrome.Theme
|
||||
|
||||
// Segmented horizontal meter: a row of cells lit up to `value`.
|
||||
//
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
pragma ComponentBehavior: Bound
|
||||
|
||||
import QtQuick
|
||||
import qs.hyprchrome.theme
|
||||
import qs.HyprChrome.Theme
|
||||
|
||||
// One metric of the expanded vitals panel: label, meter, readout on a line.
|
||||
//
|
||||
+2
-2
@@ -3,8 +3,8 @@ pragma ComponentBehavior: Bound
|
||||
import QtQuick
|
||||
import QtQuick.Layouts
|
||||
|
||||
import qs.hyprchrome.theme
|
||||
import qs.hyprchrome.widgets.panels
|
||||
import qs.HyprChrome.Theme
|
||||
import qs.HyprChrome.Widgets.Bar.Panels
|
||||
import qs.widgets.vitals
|
||||
|
||||
// Host vitals in the hyprchrome panel chrome, in both of BarPanel's densities.
|
||||
@@ -0,0 +1,237 @@
|
||||
pragma ComponentBehavior: Bound
|
||||
|
||||
import Quickshell
|
||||
import Quickshell.Hyprland
|
||||
import QtQuick
|
||||
import qs.HyprChrome.Theme
|
||||
import qs.HyprChrome.Widgets.Bar.Panels
|
||||
|
||||
// Which workspace each monitor is currently showing, in the hyprchrome panel
|
||||
// chrome, in both of BarPanel's densities.
|
||||
//
|
||||
// One indicator in both: a box carrying the workspace's name, filled accent
|
||||
// while its monitor is showing it and outlined otherwise. Collapsed, each
|
||||
// output gets exactly one — the workspace it is on. Expanded, it gets the whole
|
||||
// strip it cycles through, at a larger cell, with the shown one filled.
|
||||
//
|
||||
// Expanded, the strips line up in a column: the output name sits in a
|
||||
// fixed-width cell, so the boxes start at the same x on every line regardless
|
||||
// of how long a connector name is.
|
||||
//
|
||||
// Both densities read the same two models, so they cannot disagree. Hyprland's
|
||||
// own distinction is kept: `active` is the workspace its monitor is showing
|
||||
// (one per output), `focused` is the single one taking input — so the fill
|
||||
// marks the shown workspace and the accent marker marks where the keyboard is.
|
||||
//
|
||||
// Display only: workspaces expose activate(), but BarPanel's density toggle
|
||||
// covers the whole panel, so a chip could not receive the click anyway.
|
||||
BarPanel {
|
||||
id: panel
|
||||
|
||||
panelId: "WKS"
|
||||
title: "WORKSPACES"
|
||||
meta: panel.monitorCount + (panel.monitorCount === 1 ? " OUTPUT" : " OUTPUTS")
|
||||
|
||||
readonly property int monitorCount: Hyprland.monitors.values.length
|
||||
|
||||
// Sizes itself horizontally, like the tray: how many outputs a session has
|
||||
// is not something the bar can hardcode.
|
||||
implicitWidth: Math.max(panel.headerMinWidth,
|
||||
panel.briefLeft + brief.implicitWidth + panel.padding,
|
||||
panel.padding * 2 + outputs.implicitWidth)
|
||||
|
||||
// Height of one expanded output line; every cell on it centres against this.
|
||||
readonly property int lineHeight: 26
|
||||
|
||||
// Width of the output-name cell, which is what makes the strips align.
|
||||
// Fixed rather than measured: a connector name is "DP-2" or "HDMI-A-1", and
|
||||
// the alternative is probing every name's rendered width to take a maximum,
|
||||
// which costs a hidden Text per output to save nothing. Anything longer
|
||||
// elides.
|
||||
readonly property int nameWidth: 64
|
||||
|
||||
// What to call a workspace. Hyprland numbers them, but a named workspace
|
||||
// carries its name instead and a scratchpad arrives as "special:<name>" —
|
||||
// the prefix is noise once it is sitting next to a monitor's name.
|
||||
function label(ws): string {
|
||||
if (!ws)
|
||||
return "--";
|
||||
const name = ws.name ?? "";
|
||||
if (name.startsWith("special:"))
|
||||
return name.slice(8).toUpperCase();
|
||||
return (name.length > 0 ? name : String(ws.id)).toUpperCase();
|
||||
}
|
||||
|
||||
// The ordinary workspaces on one output, lowest id first. Specials share
|
||||
// the same list under negative ids: they show up as the active workspace
|
||||
// when one is open, but never as a slot in the strip, which is meant to be
|
||||
// the fixed set the output cycles through.
|
||||
function slots(monitor): var {
|
||||
return Hyprland.workspaces.values
|
||||
.filter(ws => ws.monitor === monitor && ws.id > 0)
|
||||
.sort((a, b) => a.id - b.id);
|
||||
}
|
||||
|
||||
// Collapsed: output name and the one box it is showing.
|
||||
summary: Row {
|
||||
id: brief
|
||||
|
||||
spacing: 14
|
||||
|
||||
Repeater {
|
||||
model: Hyprland.monitors
|
||||
|
||||
Row {
|
||||
id: briefOutput
|
||||
|
||||
required property HyprlandMonitor modelData
|
||||
|
||||
spacing: 8
|
||||
height: 18
|
||||
|
||||
// A Row aligns its children by their tops only, so the label
|
||||
// takes the box's height and centres its text in it.
|
||||
Text {
|
||||
text: briefOutput.modelData.name
|
||||
color: briefOutput.modelData.focused ? Theme.accent : Theme.muted
|
||||
font.family: Theme.microFont
|
||||
font.pixelSize: 11
|
||||
font.letterSpacing: 1.2
|
||||
height: parent.height
|
||||
verticalAlignment: Text.AlignVCenter
|
||||
}
|
||||
|
||||
Chip {
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
modelData: briefOutput.modelData.activeWorkspace
|
||||
// Filled by construction: this box IS the output's active
|
||||
// workspace, so it does not wait on the flag that says so.
|
||||
shown: true
|
||||
cell: 16
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Text {
|
||||
visible: panel.monitorCount === 0
|
||||
text: "NO OUTPUTS"
|
||||
color: Theme.muted
|
||||
font.family: Theme.microFont
|
||||
font.pixelSize: 9
|
||||
font.letterSpacing: 1.2
|
||||
height: 18
|
||||
verticalAlignment: Text.AlignVCenter
|
||||
}
|
||||
}
|
||||
|
||||
// Expanded: one line per output, strips aligned.
|
||||
Column {
|
||||
id: outputs
|
||||
|
||||
spacing: 4
|
||||
|
||||
Repeater {
|
||||
model: Hyprland.monitors
|
||||
|
||||
Output {}
|
||||
}
|
||||
|
||||
Text {
|
||||
visible: panel.monitorCount === 0
|
||||
text: "NO OUTPUTS"
|
||||
color: Theme.muted
|
||||
font.family: Theme.microFont
|
||||
font.pixelSize: 9
|
||||
font.letterSpacing: 1.2
|
||||
height: panel.lineHeight
|
||||
verticalAlignment: Text.AlignVCenter
|
||||
}
|
||||
}
|
||||
|
||||
// One output: focus marker, name, then its workspace strip. Every cell is
|
||||
// lineHeight tall and centres its own content, so the pieces sit on one
|
||||
// line and the same cell widths repeat down the column.
|
||||
component Output: Row {
|
||||
id: output
|
||||
|
||||
required property HyprlandMonitor modelData
|
||||
|
||||
spacing: 10
|
||||
|
||||
// Marker rather than a colored name: the focused output has to be
|
||||
// findable without reading anything.
|
||||
Rectangle {
|
||||
width: 3
|
||||
height: panel.lineHeight
|
||||
color: output.modelData.focused ? Theme.accent : Theme.hair
|
||||
}
|
||||
|
||||
Item {
|
||||
width: panel.nameWidth
|
||||
height: panel.lineHeight
|
||||
|
||||
Text {
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
width: parent.width
|
||||
text: output.modelData.name
|
||||
color: output.modelData.focused ? Theme.accent : Theme.muted
|
||||
font.family: Theme.microFont
|
||||
font.pixelSize: 10
|
||||
font.letterSpacing: 1.4
|
||||
elide: Text.ElideRight
|
||||
}
|
||||
}
|
||||
|
||||
Item {
|
||||
width: strip.implicitWidth
|
||||
height: panel.lineHeight
|
||||
|
||||
Row {
|
||||
id: strip
|
||||
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
spacing: 4
|
||||
|
||||
Repeater {
|
||||
model: panel.slots(output.modelData)
|
||||
|
||||
Chip {
|
||||
cell: 22
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// The indicator, at whatever size the density asks for: filled accent while
|
||||
// its output is showing that workspace, outlined otherwise.
|
||||
component Chip: Rectangle {
|
||||
id: chip
|
||||
|
||||
required property HyprlandWorkspace modelData
|
||||
|
||||
// Box height; the width grows with the label and the type scales with
|
||||
// the box, so one component covers both densities.
|
||||
property int cell: 16
|
||||
property bool shown: chip.modelData?.active ?? false
|
||||
|
||||
readonly property bool urgent: chip.modelData?.urgent ?? false
|
||||
|
||||
width: Math.max(chip.cell, chipText.implicitWidth + chip.cell / 2)
|
||||
height: chip.cell
|
||||
color: chip.shown ? Theme.accent : "transparent"
|
||||
border.width: 1
|
||||
border.color: chip.urgent ? Theme.hot : chip.shown ? Theme.accent : Theme.hair
|
||||
|
||||
Text {
|
||||
id: chipText
|
||||
|
||||
anchors.centerIn: parent
|
||||
text: panel.label(chip.modelData)
|
||||
color: chip.shown ? Theme.surface : chip.urgent ? Theme.hot : Theme.muted
|
||||
font.family: Theme.microFont
|
||||
font.pixelSize: 11
|
||||
font.bold: chip.shown
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,263 @@
|
||||
pragma ComponentBehavior: Bound
|
||||
|
||||
import Quickshell
|
||||
import Quickshell.Wayland
|
||||
import QtQuick
|
||||
import qs.HyprChrome.Theme
|
||||
|
||||
// Scrim behind the bar: dims the desktop and lays the dense bar's drafting grid
|
||||
// over it. It is always on screen — only how far DOWN it reaches changes.
|
||||
// Expanded, it covers the whole output; collapsed, it shrinks to the band the
|
||||
// rail itself occupies, so the bar keeps its backing without the desktop being
|
||||
// dimmed. That collapsed band ends in a fade rather than a cut, so there is no
|
||||
// hard line across the wallpaper; expanded there is nothing to fade against —
|
||||
// the scrim runs to the bottom of the output.
|
||||
//
|
||||
// Its layer arrives from HyprChromeShell, which derives it together with the
|
||||
// bar's so the two stay exactly one level apart — see that file for why the
|
||||
// pair cannot be split. Collapsed that puts it on BACKGROUND, shared with the
|
||||
// wallpaper (hyprpaper), where order IS creation order: if the wallpaper is
|
||||
// restarted under a running shell it comes up on top and the collapsed band
|
||||
// goes with it. A `layerrule = order` in the Hyprland config is the fix if that
|
||||
// ever bites.
|
||||
//
|
||||
// It reserves nothing and takes no input: the mask is an empty Region, so
|
||||
// clicks land on whatever is underneath rather than on the scrim.
|
||||
PanelWindow {
|
||||
id: backdrop
|
||||
|
||||
property bool active: true
|
||||
|
||||
// Which layer to sit on. An int rather than a private decision: it is half
|
||||
// of a pair with the bar's, so the shell derives both.
|
||||
property int wlrLayer: WlrLayer.Top
|
||||
|
||||
property real dim: 0.65
|
||||
property int gridSpacing: 60
|
||||
|
||||
// Height of the collapsed rail, including its margins — the band the scrim
|
||||
// stays behind while the bar is collapsed. Driven by the host, which is the
|
||||
// only thing that knows what the panels currently measure.
|
||||
property real barHeight: 0
|
||||
|
||||
// Share of the COLLAPSED band spent fading to nothing at the bottom, as a
|
||||
// fraction rather than a pixel length so the tail scales with whatever the
|
||||
// rail currently measures. Expanded there is no fade at all: the scrim runs
|
||||
// to the bottom of the output, where the screen edge ends it.
|
||||
property real fade: 0.5
|
||||
readonly property real fadeAmount: Math.max(0, Math.min(0.95, backdrop.fade))
|
||||
|
||||
// The share actually in force. Animated rather than switched, so expanding
|
||||
// shrinks the tail away as the scrim grows instead of dropping a hard edge
|
||||
// onto the desktop the moment the state flips.
|
||||
property real fadeSpan: backdrop.active ? 0 : backdrop.fadeAmount
|
||||
// Position, in fractions of revealHeight, where the falloff starts. 1 while
|
||||
// expanded, i.e. no falloff.
|
||||
readonly property real fadeStart: 1 - backdrop.fadeSpan
|
||||
|
||||
// Collapsed, the SOLID part is the bar band and the tail hangs below it,
|
||||
// hence the division: barHeight is what must survive the fade, not what the
|
||||
// whole scrim measures. Sized off the static fadeAmount, not the animated
|
||||
// fadeSpan — the height and the ramp have to animate independently or each
|
||||
// would be chasing the other. Bound rather than readonly so the Behavior
|
||||
// below can animate the state change.
|
||||
property real revealHeight: backdrop.active
|
||||
? backdrop.height
|
||||
: Math.min(backdrop.height, backdrop.barHeight / (1 - backdrop.fadeAmount))
|
||||
|
||||
// Both matched to the bar's own collapse so the scrim and the panels
|
||||
// resolve together rather than one trailing the other.
|
||||
Behavior on revealHeight {
|
||||
NumberAnimation {
|
||||
duration: 200
|
||||
easing.type: Easing.OutCubic
|
||||
}
|
||||
}
|
||||
|
||||
Behavior on fadeSpan {
|
||||
NumberAnimation {
|
||||
duration: 200
|
||||
easing.type: Easing.OutCubic
|
||||
}
|
||||
}
|
||||
|
||||
// The dense bar drew this grid at 0.018 against its own near-black panel.
|
||||
// Over a 55% scrim on top of lit windows that is invisible, so it is a
|
||||
// knob rather than a constant.
|
||||
property real gridOpacity: 0.10
|
||||
|
||||
// The accent with its saturation pulled back: warm enough to read as part
|
||||
// of the palette, not so loud that a full-screen grid competes with the
|
||||
// bar. Derived rather than a literal so it tracks a palette change.
|
||||
// Registration crosses sit on every other intersection of the grid.
|
||||
property color crossColor: Theme.muted
|
||||
property real crossOpacity: 0.15
|
||||
property int crossSize: 20
|
||||
|
||||
// Thickness in STEPS, not pixels: 1 -> 1px, 2 -> 3px, 3 -> 5px. Only odd
|
||||
// widths can straddle a 1px rule symmetrically, so an even pixel count
|
||||
// would push every mark half a pixel off the grid it registers against.
|
||||
property int crossThickness: 2
|
||||
readonly property int crossWeight: Math.max(1, backdrop.crossThickness) * 2 - 1
|
||||
|
||||
property color gridColor: Qt.hsla(Theme.accent.hslHue,
|
||||
Theme.accent.hslSaturation * 0.45,
|
||||
Theme.accent.hslLightness,
|
||||
1)
|
||||
|
||||
// Fade targets keep the source RGB and drop only the alpha: interpolating
|
||||
// toward a plain "transparent" would run the gradient through black.
|
||||
readonly property color gridSolid: Qt.rgba(backdrop.gridColor.r, backdrop.gridColor.g,
|
||||
backdrop.gridColor.b, backdrop.gridOpacity)
|
||||
readonly property color gridClear: Qt.rgba(backdrop.gridColor.r, backdrop.gridColor.g,
|
||||
backdrop.gridColor.b, 0)
|
||||
readonly property color dimSolid: Qt.rgba(Theme.surface.r, Theme.surface.g,
|
||||
Theme.surface.b, backdrop.dim)
|
||||
readonly property color dimClear: Qt.rgba(Theme.surface.r, Theme.surface.g,
|
||||
Theme.surface.b, 0)
|
||||
|
||||
// What the gradients END on. With no fade the ramp has zero length, so its
|
||||
// start stop and its end stop sit on the SAME position — and Qt sorts stops
|
||||
// with an unstable sort, leaving which of the two wins undefined. It picked
|
||||
// the transparent one, which turned "no fade" into a ramp across the entire
|
||||
// scrim. Ending on the solid color instead makes the degenerate case
|
||||
// unambiguous: all three stops match and the fill is flat.
|
||||
readonly property color gridEnd: backdrop.fadeSpan > 0 ? backdrop.gridClear : backdrop.gridSolid
|
||||
readonly property color dimEnd: backdrop.fadeSpan > 0 ? backdrop.dimClear : backdrop.dimSolid
|
||||
|
||||
// Same ramp as the gradients above, for the marks that are placed at a
|
||||
// single y and so cannot carry a gradient of their own. Reads revealHeight
|
||||
// and fadeStart, so bindings that call it re-evaluate when either changes.
|
||||
function fadeAt(y: real): real {
|
||||
const start = backdrop.revealHeight * backdrop.fadeStart;
|
||||
if (y <= start)
|
||||
return 1;
|
||||
if (y >= backdrop.revealHeight)
|
||||
return 0;
|
||||
return 1 - (y - start) / (backdrop.revealHeight - start);
|
||||
}
|
||||
|
||||
visible: backdrop.revealHeight > 0
|
||||
|
||||
WlrLayershell.namespace: "hyprchrome-scrim"
|
||||
WlrLayershell.layer: backdrop.wlrLayer
|
||||
WlrLayershell.keyboardFocus: WlrKeyboardFocus.None
|
||||
exclusionMode: ExclusionMode.Ignore
|
||||
color: "transparent"
|
||||
|
||||
readonly property int crossColumns: Math.ceil(backdrop.width / (backdrop.gridSpacing * 2)) + 1
|
||||
readonly property int crossRows: Math.ceil(backdrop.height / (backdrop.gridSpacing * 2)) + 1
|
||||
|
||||
anchors {
|
||||
top: true
|
||||
left: true
|
||||
right: true
|
||||
bottom: true
|
||||
}
|
||||
|
||||
mask: Region {}
|
||||
|
||||
Item {
|
||||
id: scrim
|
||||
|
||||
// Only as tall as the scrim currently reaches; everything inside is
|
||||
// laid out against this, so shrinking it scopes the whole drawing
|
||||
// rather than just clipping it.
|
||||
width: backdrop.width
|
||||
height: backdrop.revealHeight
|
||||
clip: true
|
||||
|
||||
Rectangle {
|
||||
anchors.fill: parent
|
||||
gradient: Gradient {
|
||||
GradientStop { position: 0; color: backdrop.dimSolid }
|
||||
GradientStop { position: backdrop.fadeStart; color: backdrop.dimSolid }
|
||||
GradientStop { position: 1; color: backdrop.dimEnd }
|
||||
}
|
||||
}
|
||||
|
||||
// Faint drafting grid; no gradient and deliberately subordinate to
|
||||
// whatever is showing through it — except at the bottom, where it has to
|
||||
// fade with the scrim it sits on.
|
||||
Repeater {
|
||||
model: Math.ceil(scrim.width / backdrop.gridSpacing)
|
||||
|
||||
Rectangle {
|
||||
required property int index
|
||||
|
||||
x: index * backdrop.gridSpacing
|
||||
width: 1
|
||||
height: scrim.height
|
||||
gradient: Gradient {
|
||||
GradientStop { position: 0; color: backdrop.gridSolid }
|
||||
GradientStop { position: backdrop.fadeStart; color: backdrop.gridSolid }
|
||||
GradientStop { position: 1; color: backdrop.gridEnd }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Repeater {
|
||||
// Modelled against the whole output, not the current reveal, so a
|
||||
// collapse fades the rules out where they stand instead of
|
||||
// restocking the Repeater on every animation frame.
|
||||
model: Math.ceil(backdrop.height / backdrop.gridSpacing)
|
||||
|
||||
Rectangle {
|
||||
required property int index
|
||||
readonly property real line: index * backdrop.gridSpacing
|
||||
|
||||
y: line
|
||||
width: scrim.width
|
||||
height: 1
|
||||
color: backdrop.gridColor
|
||||
opacity: backdrop.gridOpacity * backdrop.fadeAt(line)
|
||||
}
|
||||
}
|
||||
|
||||
// Register marks on every other line, so they land on a 2x grid rather
|
||||
// than on every crossing — sparse enough to read as drafting registration
|
||||
// rather than as texture.
|
||||
Repeater {
|
||||
model: backdrop.crossColumns * backdrop.crossRows
|
||||
|
||||
Item {
|
||||
required property int index
|
||||
|
||||
readonly property int column: index % backdrop.crossColumns
|
||||
readonly property int row: Math.floor(index / backdrop.crossColumns)
|
||||
|
||||
// Marks on every other rule in both directions, so they line up
|
||||
// in columns as well as rows. Both offsets are whole multiples of
|
||||
// gridSpacing, so every mark lands on a real intersection.
|
||||
//
|
||||
// Math.floor, not /2: the item offset and the bars inside it must
|
||||
// round the same way, or an even crossSize sits half a pixel off the
|
||||
// rule it marks.
|
||||
x: column * backdrop.gridSpacing * 2 - Math.floor(backdrop.crossSize / 2)
|
||||
y: row * backdrop.gridSpacing * 2 - Math.floor(backdrop.crossSize / 2)
|
||||
width: backdrop.crossSize
|
||||
height: backdrop.crossSize
|
||||
// Sampled at the intersection the mark registers against, not at
|
||||
// its own top edge, so a cross fades as one piece.
|
||||
opacity: backdrop.crossOpacity * backdrop.fadeAt(row * backdrop.gridSpacing * 2)
|
||||
|
||||
Rectangle {
|
||||
// Placed with the same Math.floor the item's own offset uses.
|
||||
// anchors.verticalCenter halves the height unfloored, so an even
|
||||
// crossSize put the 1px bar half a pixel off the rule it marks.
|
||||
y: Math.floor(backdrop.crossSize / 2) - Math.floor(backdrop.crossWeight / 2)
|
||||
width: parent.width
|
||||
height: backdrop.crossWeight
|
||||
color: backdrop.crossColor
|
||||
}
|
||||
|
||||
Rectangle {
|
||||
x: Math.floor(backdrop.crossSize / 2) - Math.floor(backdrop.crossWeight / 2)
|
||||
width: backdrop.crossWeight
|
||||
height: parent.height
|
||||
color: backdrop.crossColor
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,251 @@
|
||||
pragma ComponentBehavior: Bound
|
||||
|
||||
import Quickshell
|
||||
import Quickshell.Hyprland
|
||||
import Quickshell.Wayland
|
||||
import qs.HyprChrome.Widgets.Bar
|
||||
import qs.HyprChrome.Widgets
|
||||
import qs.HyprChrome.Widgets.Polkit
|
||||
import qs.HyprChrome.Widgets.Launcher
|
||||
import qs.HyprChrome.Widgets.Askpass
|
||||
|
||||
// The hyprchrome shell: owns everything the rail's surfaces have to agree on,
|
||||
// and instantiates them.
|
||||
//
|
||||
// State lives here rather than in any one surface because more than one of them
|
||||
// reads it, and a second reader is what turns a local property into shared
|
||||
// state. Four things qualify so far:
|
||||
//
|
||||
// * which monitor the shell lives on — every surface has to pick the same one
|
||||
// * the density — the whole rail expands and collapses as one, so the toggle
|
||||
// and the shortcut that drives it belong to the shell, not to the bar
|
||||
// * whether a MODAL is open — the polkit prompt, the launcher, or the sudo
|
||||
// askpass dialog. Each raises the same scrim the rail uses, freezes the
|
||||
// density, lands on the focused monitor and takes the keyboard off the
|
||||
// rail, so several surfaces read it. That is why they live here rather than
|
||||
// as siblings of the remaining launcher variants in shell.qml
|
||||
// * the layer PAIR — the backdrop must sit exactly one layer below the bar in
|
||||
// both densities. Two surfaces on the same layer stack by creation order,
|
||||
// which is not something to rely on; one layer apart is a guarantee. Split
|
||||
// across two files those two assignments drifted apart and the scrim ended
|
||||
// up over the bar, so they are derived together here and passed down.
|
||||
//
|
||||
// A future widget joins by taking `targetScreen` and `expanded` the same way.
|
||||
Scope {
|
||||
id: shell
|
||||
|
||||
// Monitor the rail lives on. Falls back to the FIRST connected screen when
|
||||
// the name matches nothing, so the bar still appears on a single-monitor
|
||||
// session or after a cable swap (DebugWindow falls back to the last one
|
||||
// instead — it wants the secondary).
|
||||
property string screenName: "DP-2"
|
||||
|
||||
// Quickshell.screens is a QML list, not a JS array — no .find() on it.
|
||||
readonly property var targetScreen: {
|
||||
const screens = Quickshell.screens;
|
||||
if (screens.length === 0)
|
||||
return null;
|
||||
for (let i = 0; i < screens.length; i++) {
|
||||
if (screens[i].name === shell.screenName)
|
||||
return screens[i];
|
||||
}
|
||||
return screens[0];
|
||||
}
|
||||
|
||||
// Every output the rail does NOT live on. They get a scrim of their own
|
||||
// while a prompt is up, because a modal that dims one monitor and leaves
|
||||
// the others lit does not read as modal at all — and the rail's backdrop
|
||||
// covers exactly one output.
|
||||
readonly property var otherScreens: {
|
||||
const out = [];
|
||||
const screens = Quickshell.screens;
|
||||
for (let i = 0; i < screens.length; i++) {
|
||||
if (screens[i] !== shell.targetScreen)
|
||||
out.push(screens[i]);
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
// Where a prompt appears: wherever the user is actually looking, which is
|
||||
// not necessarily where the rail lives. Hyprland reports the focused
|
||||
// monitor by name, and Quickshell.screens is keyed the same way, so the
|
||||
// two are matched by name exactly as targetScreen is above.
|
||||
//
|
||||
// Falls back to the rail's own screen rather than to nothing: a prompt that
|
||||
// fails to place itself would leave its caller blocked on a dialog nobody
|
||||
// can see.
|
||||
readonly property var focusedScreen: {
|
||||
const focused = Hyprland.focusedMonitor;
|
||||
if (!focused)
|
||||
return shell.targetScreen;
|
||||
|
||||
const screens = Quickshell.screens;
|
||||
for (let i = 0; i < screens.length; i++) {
|
||||
if (screens[i].name === focused.name)
|
||||
return screens[i];
|
||||
}
|
||||
return shell.targetScreen;
|
||||
}
|
||||
|
||||
// Density is a property of the SHELL: every panel follows it, so the whole
|
||||
// rail expands and collapses as one. Panels keep their own animation; only
|
||||
// the decision is centralised here.
|
||||
//
|
||||
// A prompt does NOT change it: an authorization request leaves the rail at
|
||||
// whatever density it was, and only freezes it there.
|
||||
property bool expanded: false
|
||||
|
||||
function toggle() {
|
||||
// Frozen while a prompt is up, and dropped rather than queued: SUPER A
|
||||
// during a prompt does nothing at all, instead of arming a change that
|
||||
// springs the rail open or shut the moment the dialog goes.
|
||||
if (shell.modalOpen)
|
||||
return;
|
||||
|
||||
shell.expanded = !shell.expanded;
|
||||
}
|
||||
|
||||
// The surfaces that take over the screen: they dim EVERY output, land on the
|
||||
// focused one, and take the keyboard off the rail. Grouped because
|
||||
// everything below treats them alike, so a fourth one joins by being named
|
||||
// here and nowhere else.
|
||||
readonly property bool modalOpen: polkit.prompting || launcher.active || askpass.active
|
||||
|
||||
// Whether the scrim is up, from ANY cause. This is the fact the surfaces
|
||||
// actually share — the rail's density is only one of the things that can
|
||||
// raise it — so the backdrop and the layer pair below key off this rather
|
||||
// than off `expanded`.
|
||||
//
|
||||
// One backdrop instance serves all of them. A modal opening over an already
|
||||
// expanded rail therefore changes nothing about the scrim on that monitor:
|
||||
// it is already up, already full height, and the modal simply appears above
|
||||
// it. Over a COLLAPSED rail the same scrim expands from its bar-height band
|
||||
// to the whole output, using the animation it already has, and the rail
|
||||
// stays collapsed throughout.
|
||||
readonly property bool scrimUp: shell.expanded || shell.modalOpen
|
||||
|
||||
// Scrim up, the rail is over everything; scrim down, it drops below ordinary
|
||||
// windows. BOTTOM rather than BACKGROUND for the lowered bar: it is the
|
||||
// lowest level that still leaves a layer underneath for the backdrop, and
|
||||
// it keeps the rail off the wallpaper's own level.
|
||||
//
|
||||
// Both key off `scrimUp`, not `expanded`, so the pair stays exactly one
|
||||
// level apart in every state — which is the whole point of deriving them
|
||||
// together. A prompt over a collapsed rail raises BOTH: the scrim has to
|
||||
// clear ordinary windows to dim them at all (BACKGROUND sits under them),
|
||||
// and the bar has to stay one above the scrim or the shell would be dimming
|
||||
// its own chrome. The rail is raised but still collapsed: its layer answers
|
||||
// to the scrim, its height to `expanded`.
|
||||
readonly property int barLayer: shell.scrimUp ? WlrLayer.Overlay : WlrLayer.Bottom
|
||||
readonly property int backdropLayer: shell.scrimUp ? WlrLayer.Top : WlrLayer.Background
|
||||
|
||||
// SUPER A — see hosts/terra/home/hyprland.nix.
|
||||
GlobalShortcut {
|
||||
name: "chrome"
|
||||
description: "Expand or collapse the hyprchrome bar"
|
||||
onPressed: shell.toggle()
|
||||
}
|
||||
|
||||
// Backdrop first: it is a layer below the bar, so stacking does not depend
|
||||
// on creation order, but keeping the declaration order the same as the
|
||||
// visual order costs nothing.
|
||||
ChromeBackdrop {
|
||||
screen: shell.targetScreen
|
||||
active: shell.scrimUp
|
||||
wlrLayer: shell.backdropLayer
|
||||
|
||||
// Collapsed, the scrim only backs the rail, so it needs the band the
|
||||
// rail occupies. contentHeight is the SETTLED height for the current
|
||||
// state — it jumps once per toggle rather than tracking the panels
|
||||
// frame by frame, so the backdrop animates the change itself instead of
|
||||
// chasing a value that is already being animated.
|
||||
barHeight: bar.contentHeight
|
||||
}
|
||||
|
||||
// The same scrim on every other output, up only while a prompt is. These
|
||||
// have no rail to back, so barHeight stays 0 and revealHeight falls to
|
||||
// nothing between prompts — the surfaces take themselves off screen rather
|
||||
// than lingering as a strip the way the rail's does.
|
||||
//
|
||||
// Deliberately NOT tied to `scrimUp`: expanding the rail dims the rail's
|
||||
// monitor only, which is the existing behaviour and the right one — the
|
||||
// rail is a thing on one screen. A prompt is the only event that concerns
|
||||
// every screen at once.
|
||||
//
|
||||
// TOP unconditionally: there is no bar on these outputs to keep one level
|
||||
// above the scrim, and BACKGROUND would put the dim under ordinary windows
|
||||
// where it would dim nothing. Inactive they are invisible, so the level
|
||||
// costs nothing between prompts.
|
||||
Variants {
|
||||
model: shell.otherScreens
|
||||
|
||||
ChromeBackdrop {
|
||||
required property var modelData
|
||||
|
||||
screen: modelData
|
||||
active: shell.modalOpen
|
||||
wlrLayer: WlrLayer.Top
|
||||
barHeight: 0
|
||||
}
|
||||
}
|
||||
|
||||
HyprChromeBar {
|
||||
id: bar
|
||||
|
||||
screen: shell.targetScreen
|
||||
// Set here, not from the window's own `screen`: reading that inside
|
||||
// `visible` is circular — a hidden window has no screen to report.
|
||||
visible: shell.targetScreen !== null
|
||||
expanded: shell.expanded
|
||||
wlrLayer: shell.barLayer
|
||||
|
||||
// ESC closes the rail — but only when it is the innermost thing open.
|
||||
// While a prompt is up the rail gives up the keyboard so ESC dismisses
|
||||
// the DIALOG; the prompt closing hands it back, and the next ESC closes
|
||||
// the rail. Withheld rather than left to the compositor to arbitrate
|
||||
// between two exclusive surfaces, which would decide by stacking and
|
||||
// silently swap the order the day the layers change.
|
||||
grabsKeyboard: shell.expanded && !shell.modalOpen
|
||||
|
||||
onDismissed: shell.expanded = false
|
||||
}
|
||||
|
||||
// Polkit authentication agent. It registers for this logind session on
|
||||
// creation, so it replaces hyprpolkitagent rather than coexisting with it —
|
||||
// only one agent may hold a session (see hosts/terra/home/hyprland.nix).
|
||||
//
|
||||
// It lives here rather than beside the launchers in shell.qml because its
|
||||
// state is shared: `prompting` raises the scrim and freezes the density,
|
||||
// which makes it shell state by the same rule as the screen and the layer
|
||||
// pair. It owns only its dialog; the scrim above is the rail's.
|
||||
//
|
||||
// Declared LAST on purpose. While a prompt is up the bar is on Overlay too,
|
||||
// and there is no layer above Overlay to escape to, so the dialog stays on
|
||||
// top by being the later surface. In practice it is later regardless — its
|
||||
// window only exists while a request is open, so it is always created after
|
||||
// the bar's — but the declaration order says so without relying on that.
|
||||
PolkitPrompt {
|
||||
id: polkit
|
||||
|
||||
screen: shell.focusedScreen
|
||||
}
|
||||
|
||||
// Primary application launcher — SUPER_L. Migrated out of
|
||||
// widgets/launcher/; the ten remaining variants are still evaluation copies
|
||||
// and stay in shell.qml. Declared after the bar for the same reason the
|
||||
// prompt is: while it is open the bar is on Overlay too, and there is no
|
||||
// layer above Overlay to escape to.
|
||||
AppLauncher {
|
||||
id: launcher
|
||||
|
||||
screen: shell.focusedScreen
|
||||
}
|
||||
|
||||
// GUI password prompt for `sudo -A`. Not the polkit agent — sudo cannot use
|
||||
// one — but it renders the same dialog. See the file for the flow.
|
||||
AskpassPrompt {
|
||||
id: askpass
|
||||
|
||||
screen: shell.focusedScreen
|
||||
}
|
||||
}
|
||||
+38
-14
@@ -4,18 +4,41 @@ import Quickshell
|
||||
import Quickshell.Hyprland
|
||||
import Quickshell.Wayland
|
||||
import QtQuick
|
||||
import qs.widgets.theme
|
||||
import qs.HyprChrome.Theme
|
||||
|
||||
// Primary application launcher (variant 8). The full-screen layer-shell adapter
|
||||
// owns focus, DesktopEntries and execution; ApplicationLauncherContent remains
|
||||
// an Item so the complete visual state can be rendered headlessly.
|
||||
// Primary application launcher — the one on SUPER_L.
|
||||
//
|
||||
// Migrated from widgets/launcher/ApplicationLauncher.qml. Two things changed in
|
||||
// the move, both because HyprChromeShell now owns the state its surfaces share:
|
||||
//
|
||||
// * no scrim of its own. The shell raises the single ChromeBackdrop for any
|
||||
// of its causes — expanded rail, polkit prompt, this — so opening the
|
||||
// launcher over an already-expanded rail reuses the scrim that is there
|
||||
// rather than laying a second dim on top of it.
|
||||
// * `active` is read by the shell, which uses it to raise that scrim, to
|
||||
// place this on the focused monitor, and to decide who gets the keyboard.
|
||||
//
|
||||
// The full-screen layer-shell adapter owns focus, DesktopEntries and execution;
|
||||
// AppLauncherContent stays an Item so the whole visual state can be rendered
|
||||
// headlessly (tests/AppLauncherHeadless.qml).
|
||||
Scope {
|
||||
id: root
|
||||
|
||||
property bool active: false
|
||||
|
||||
function toggle() { root.active = !root.active; }
|
||||
// Which output to appear on. Driven by the shell, which puts it on the
|
||||
// focused monitor — a launcher belongs where the user is looking, which is
|
||||
// not necessarily where the rail lives.
|
||||
property var screen: null
|
||||
|
||||
function toggle() { root.active = !root.active; }
|
||||
function close() { root.active = false; }
|
||||
|
||||
// The name is legacy: this was "variant 8" of eleven, and both SUPER_L (via
|
||||
// open_launcher.sh) and SUPER CTRL 8 still dispatch quickshell:launcher8.
|
||||
// Renaming it means editing hosts/terra/home/hyprland.nix AND the script
|
||||
// together, and neither takes effect until a deploy — so the shortcut would
|
||||
// be dead in the running session in between. Kept as-is deliberately.
|
||||
GlobalShortcut {
|
||||
name: "launcher8"
|
||||
description: "Toggle dense application command index"
|
||||
@@ -25,7 +48,9 @@ Scope {
|
||||
PanelWindow {
|
||||
id: win
|
||||
|
||||
screen: root.screen
|
||||
visible: root.active
|
||||
|
||||
WlrLayershell.layer: WlrLayer.Overlay
|
||||
WlrLayershell.keyboardFocus: WlrKeyboardFocus.Exclusive
|
||||
exclusionMode: ExclusionMode.Ignore
|
||||
@@ -71,19 +96,18 @@ Scope {
|
||||
search: content.query
|
||||
}
|
||||
|
||||
Rectangle {
|
||||
anchors.fill: parent
|
||||
color: Theme.surface
|
||||
opacity: 0.72
|
||||
|
||||
// Click-off dismissal. The scrim itself belongs to the shell and takes
|
||||
// no input (its mask is empty), so the catcher lives here: a
|
||||
// transparent full-surface MouseArea UNDER the content, which is what
|
||||
// keeps clicks on the launcher itself from closing it.
|
||||
MouseArea {
|
||||
anchors.fill: parent
|
||||
onClicked: root.active = false
|
||||
}
|
||||
onClicked: root.close()
|
||||
}
|
||||
|
||||
ApplicationLauncherContent {
|
||||
AppLauncherContent {
|
||||
id: content
|
||||
|
||||
anchors.centerIn: parent
|
||||
width: 1080
|
||||
height: 620
|
||||
@@ -95,7 +119,7 @@ Scope {
|
||||
onSelectionRequested: index => win.selectedIndex = win.clampSelection(index)
|
||||
onMoveRequested: delta => win.move(delta)
|
||||
onLaunchRequested: index => win.launch(index)
|
||||
onDismissRequested: root.active = false
|
||||
onDismissRequested: root.close()
|
||||
}
|
||||
}
|
||||
}
|
||||
+8
-9
@@ -5,12 +5,11 @@ import Quickshell.Widgets
|
||||
import QtQuick
|
||||
import QtQuick.Layouts
|
||||
import QtQuick.Shapes
|
||||
import qs.widgets.bar
|
||||
import qs.widgets.theme
|
||||
import qs.HyprChrome.Theme
|
||||
|
||||
// Headlessly renderable visual core for the primary application launcher.
|
||||
// Runtime concerns (DesktopEntries, layer shell, launching) stay in
|
||||
// ApplicationLauncher.qml; this component only renders state and emits intent.
|
||||
// Runtime concerns (DesktopEntries, layer shell, focus, launching) stay in
|
||||
// AppLauncher.qml; this component only renders state and emits intent.
|
||||
Item {
|
||||
id: root
|
||||
|
||||
@@ -70,7 +69,7 @@ Item {
|
||||
}
|
||||
}
|
||||
|
||||
StatusBarPanel {
|
||||
LauncherPanel {
|
||||
anchors.fill: parent
|
||||
panelId: "008"
|
||||
title: "APPLICATION COMMAND INDEX"
|
||||
@@ -78,7 +77,7 @@ Item {
|
||||
chamfer: 18
|
||||
|
||||
// Query module.
|
||||
StatusBarPanel {
|
||||
LauncherPanel {
|
||||
id: queryPanel
|
||||
x: 18
|
||||
y: 34
|
||||
@@ -184,7 +183,7 @@ Item {
|
||||
}
|
||||
|
||||
// Search result table.
|
||||
StatusBarPanel {
|
||||
LauncherPanel {
|
||||
id: resultPanel
|
||||
x: 18
|
||||
y: 118
|
||||
@@ -347,7 +346,7 @@ Item {
|
||||
}
|
||||
|
||||
// Selected application inspector.
|
||||
StatusBarPanel {
|
||||
LauncherPanel {
|
||||
id: inspector
|
||||
x: 700
|
||||
y: 34
|
||||
@@ -569,7 +568,7 @@ Item {
|
||||
}
|
||||
|
||||
// Dense command footer.
|
||||
StatusBarPanel {
|
||||
LauncherPanel {
|
||||
x: 18
|
||||
y: 550
|
||||
width: 1044
|
||||
@@ -0,0 +1,44 @@
|
||||
import Quickshell
|
||||
import QtQuick
|
||||
|
||||
// Non-visual, reusable app-search model shared by every launcher variant.
|
||||
// Set `search`; read `apps` (a ranked, filtered list of DesktopEntry).
|
||||
QtObject {
|
||||
id: root
|
||||
|
||||
property string search: ""
|
||||
|
||||
// `keywords`/`categories` come through as string lists, so coerce every
|
||||
// field to a string before matching (String([]) joins with commas).
|
||||
function haystack(a) {
|
||||
return (String(a.name || "") + " " + String(a.genericName || "") + " " + String(a.comment || "") + " " + String(a.keywords || "")).toLowerCase();
|
||||
}
|
||||
|
||||
readonly property var apps: {
|
||||
const all = DesktopEntries.applications.values.filter(a => !a.noDisplay);
|
||||
const q = root.search.trim().toLowerCase();
|
||||
|
||||
if (q.length === 0)
|
||||
return all.slice().sort((x, y) => String(x.name).localeCompare(String(y.name)));
|
||||
|
||||
const matches = all.filter(a => root.haystack(a).includes(q));
|
||||
|
||||
// Prefix matches on the visible name rank first, then alphabetical.
|
||||
return matches.slice().sort((x, y) => {
|
||||
const xs = String(x.name).toLowerCase().startsWith(q) ? 0 : 1;
|
||||
const ys = String(y.name).toLowerCase().startsWith(q) ? 0 : 1;
|
||||
if (xs !== ys)
|
||||
return xs - ys;
|
||||
return String(x.name).localeCompare(String(y.name));
|
||||
});
|
||||
}
|
||||
|
||||
function launch(index) {
|
||||
const list = root.apps;
|
||||
if (index >= 0 && index < list.length) {
|
||||
list[index].execute();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,136 @@
|
||||
pragma ComponentBehavior: Bound
|
||||
|
||||
import QtQuick
|
||||
import QtQuick.Shapes
|
||||
import qs.HyprChrome.Theme
|
||||
|
||||
// Chamfered panel chrome for the launcher: outline, corner accent lines, and
|
||||
// the optional header strip (id chip / title / meta / tick marks). Content is
|
||||
// supplied as children by the call site.
|
||||
//
|
||||
// A sibling of BarPanel rather than a use of it: BarPanel is almost entirely
|
||||
// density machinery (summary slot, animated height, state pair, transitions)
|
||||
// for a rail that expands and collapses, and the launcher has exactly one
|
||||
// density. Same reasoning as PolkitPanel — see that file.
|
||||
//
|
||||
// Carried over from widgets/bar/StatusBarPanel.qml, which the legacy launcher
|
||||
// variants still use. Restyle this one freely; it is read only by the launcher.
|
||||
Item {
|
||||
id: panel
|
||||
|
||||
property string panelId: ""
|
||||
property string title: ""
|
||||
property string meta: ""
|
||||
property bool showHeader: true
|
||||
property int chamfer: 13
|
||||
property int offsetY: 2
|
||||
property int accentLineThickness: 3
|
||||
|
||||
Shape {
|
||||
id: panelShape
|
||||
anchors.fill: parent
|
||||
preferredRendererType: Shape.CurveRenderer
|
||||
|
||||
ShapePath {
|
||||
fillColor: Theme.surface
|
||||
strokeColor: Theme.hair
|
||||
strokeWidth: 1
|
||||
startX: 0; startY: panel.offsetY
|
||||
PathLine { x: panelShape.width - panel.chamfer; y: panel.offsetY }
|
||||
PathLine { x: panelShape.width; y: panel.chamfer }
|
||||
PathLine { x: panelShape.width; y: panelShape.height }
|
||||
PathLine { x: panel.chamfer; y: panelShape.height }
|
||||
PathLine { x: 0; y: panelShape.height - panel.chamfer }
|
||||
PathLine { x: 0; y: panel.offsetY }
|
||||
}
|
||||
|
||||
// Upper left accent line
|
||||
ShapePath {
|
||||
fillColor: Theme.accent
|
||||
strokeWidth: 0
|
||||
startX: 0; startY: 0
|
||||
PathLine { x: Math.min(49, panelShape.width / 3); y: 0 }
|
||||
PathLine { x: Math.min(49, panelShape.width / 3); y: panel.accentLineThickness }
|
||||
PathLine { x: 0; y: panel.accentLineThickness }
|
||||
PathLine { x: 0; y: 0 }
|
||||
}
|
||||
|
||||
// Lower right accent line
|
||||
ShapePath {
|
||||
fillColor: Theme.accent
|
||||
strokeWidth: 0
|
||||
startX: panelShape.width; startY: panelShape.height
|
||||
PathLine { x: panelShape.width - Math.min(49, panelShape.width / 3); y: panelShape.height }
|
||||
PathLine { x: panelShape.width - Math.min(49, panelShape.width / 3); y: panelShape.height - panel.accentLineThickness }
|
||||
PathLine { x: panelShape.width; y: panelShape.height - panel.accentLineThickness }
|
||||
PathLine { x: panelShape.width; y: panelShape.height }
|
||||
}
|
||||
}
|
||||
|
||||
Rectangle {
|
||||
visible: panel.showHeader
|
||||
x: 1; y: 22
|
||||
width: parent.width - 2
|
||||
height: 1
|
||||
color: Theme.text
|
||||
opacity: 0.12
|
||||
}
|
||||
|
||||
Rectangle {
|
||||
visible: panel.showHeader
|
||||
x: 5; y: 7
|
||||
width: panel.panelId.length > 2 ? 29 : 24
|
||||
height: 11
|
||||
color: Theme.accent
|
||||
Text {
|
||||
anchors.centerIn: parent
|
||||
text: panel.panelId
|
||||
color: Theme.surface
|
||||
font.family: Theme.microFont
|
||||
font.pixelSize: 8
|
||||
font.bold: true
|
||||
}
|
||||
}
|
||||
|
||||
Text {
|
||||
visible: panel.showHeader
|
||||
x: 40; y: 7
|
||||
width: parent.width - 105
|
||||
text: panel.title
|
||||
color: Theme.text
|
||||
font.family: Theme.displayFont
|
||||
font.pixelSize: 9
|
||||
font.bold: true
|
||||
font.letterSpacing: 1.1
|
||||
elide: Text.ElideRight
|
||||
}
|
||||
|
||||
// Inlined rather than reusing DenseBarContent's MicroText, which is an
|
||||
// inline component and therefore not visible from another file.
|
||||
Text {
|
||||
visible: panel.showHeader && panel.meta.length > 0
|
||||
anchors.right: parent.right
|
||||
anchors.rightMargin: 12
|
||||
y: 6
|
||||
text: panel.meta
|
||||
width: Math.min(80, parent.width / 4)
|
||||
color: Theme.muted
|
||||
font.family: Theme.microFont
|
||||
font.pixelSize: 6
|
||||
font.letterSpacing: 0.7
|
||||
horizontalAlignment: Text.AlignRight
|
||||
elide: Text.ElideRight
|
||||
}
|
||||
|
||||
Row {
|
||||
visible: panel.showHeader
|
||||
anchors.right: parent.right
|
||||
anchors.rightMargin: 10
|
||||
y: 14
|
||||
spacing: 2
|
||||
Repeater {
|
||||
model: 5
|
||||
Rectangle { required property int index; width: 4; height: 2; color: Theme.accent }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,202 @@
|
||||
pragma ComponentBehavior: Bound
|
||||
|
||||
import QtQuick
|
||||
import QtQuick.Shapes
|
||||
import qs.HyprChrome.Theme
|
||||
|
||||
// Panel chrome for the authentication dialog.
|
||||
//
|
||||
// Deliberately NOT BarPanel. The rail's panel exists to carry two renderings of
|
||||
// the same data and cross-fade between them as the rail changes density, and
|
||||
// almost all of its size is that machinery: the summary slot, the animated
|
||||
// height, the state pair, the transitions. A modal has exactly one density and
|
||||
// never collapses, so inheriting all of that would mean carrying dead weight
|
||||
// and, worse, tying the dialog's look to a component whose real job is the rail
|
||||
// — every restyle here would have to be justified against the panels up there.
|
||||
//
|
||||
// What it does keep is the silhouette, because that is the shell's visual
|
||||
// signature rather than the rail's: two cut corners (top-right, bottom-left)
|
||||
// with detached accent caps outside them, an accent rule under the header slug,
|
||||
// its mirror at the lower right, and a header strip of slug / title / meta.
|
||||
//
|
||||
// This is the file to edit to restyle the prompt. Nothing else reads it.
|
||||
Item {
|
||||
id: panel
|
||||
|
||||
property string panelId: ""
|
||||
property string title: ""
|
||||
property string meta: ""
|
||||
|
||||
property int chamfer: 16
|
||||
property int padding: 14
|
||||
property int outlineWidth: 1
|
||||
property int accentLineThickness: 3
|
||||
|
||||
readonly property int headerHeight: 30
|
||||
|
||||
// Gap between the header rule and the body.
|
||||
property int headerGap: 10
|
||||
readonly property int headerPadding: 10
|
||||
|
||||
// Detached corner caps: the corner each chamfer removed, put back outside
|
||||
// the panel as an accent triangle whose hypotenuse faces the cut. capGap is
|
||||
// the perpendicular distance from the cut, so the per-axis shift is it over
|
||||
// root 2 — the cap moves along the cut's normal, not along an axis.
|
||||
property real capGap: 4
|
||||
readonly property real capOffset: panel.capGap / Math.SQRT2
|
||||
|
||||
// Never let the two cuts cross, which would turn the outline inside out on
|
||||
// a panel shorter than twice the chamfer.
|
||||
readonly property real activeChamfer: Math.max(2, Math.min(panel.chamfer, panel.height / 2 - 1))
|
||||
|
||||
// The accent rule under the slug is sized to the slug, not to the panel.
|
||||
readonly property real accentLineWidth: Math.min(panel.width, slugChip.width + panel.headerPadding * 2)
|
||||
|
||||
default property alias content: body.data
|
||||
|
||||
implicitHeight: Math.round(body.y + body.height + panel.padding)
|
||||
|
||||
Shape {
|
||||
id: panelShape
|
||||
|
||||
anchors.fill: parent
|
||||
preferredRendererType: Shape.CurveRenderer
|
||||
|
||||
// Outline: square except for the two cut corners.
|
||||
ShapePath {
|
||||
fillColor: Theme.surface
|
||||
strokeColor: Theme.hair
|
||||
strokeWidth: panel.outlineWidth
|
||||
|
||||
startX: 0; startY: 0
|
||||
PathLine { x: panelShape.width - panel.activeChamfer; y: 0 }
|
||||
PathLine { x: panelShape.width; y: panel.activeChamfer }
|
||||
PathLine { x: panelShape.width; y: panelShape.height }
|
||||
PathLine { x: panel.activeChamfer; y: panelShape.height }
|
||||
PathLine { x: 0; y: panelShape.height - panel.activeChamfer }
|
||||
PathLine { x: 0; y: 0 }
|
||||
}
|
||||
|
||||
// Cap on the top-right cut.
|
||||
ShapePath {
|
||||
fillColor: Theme.accent
|
||||
strokeWidth: 0
|
||||
|
||||
startX: panelShape.width - panel.activeChamfer + panel.capOffset
|
||||
startY: -panel.capOffset
|
||||
PathLine { x: panelShape.width + panel.capOffset; y: panel.activeChamfer - panel.capOffset }
|
||||
PathLine { x: panelShape.width + panel.capOffset; y: -panel.capOffset }
|
||||
PathLine { x: panelShape.width - panel.activeChamfer + panel.capOffset; y: -panel.capOffset }
|
||||
}
|
||||
|
||||
// Cap on the bottom-left cut, the same triangle mirrored.
|
||||
ShapePath {
|
||||
fillColor: Theme.accent
|
||||
strokeWidth: 0
|
||||
|
||||
startX: panel.activeChamfer - panel.capOffset
|
||||
startY: panelShape.height + panel.capOffset
|
||||
PathLine { x: -panel.capOffset; y: panelShape.height - panel.activeChamfer + panel.capOffset }
|
||||
PathLine { x: -panel.capOffset; y: panelShape.height + panel.capOffset }
|
||||
PathLine { x: panel.activeChamfer - panel.capOffset; y: panelShape.height + panel.capOffset }
|
||||
}
|
||||
|
||||
// Accent rule under the slug.
|
||||
ShapePath {
|
||||
fillColor: Theme.accent
|
||||
strokeWidth: 0
|
||||
|
||||
startX: 0; startY: 0
|
||||
PathLine { x: panel.accentLineWidth; y: 0 }
|
||||
PathLine { x: panel.accentLineWidth; y: panel.accentLineThickness }
|
||||
PathLine { x: 0; y: panel.accentLineThickness }
|
||||
PathLine { x: 0; y: 0 }
|
||||
}
|
||||
|
||||
// Its mirror at the lower right.
|
||||
ShapePath {
|
||||
fillColor: Theme.accent
|
||||
strokeWidth: 0
|
||||
|
||||
startX: panelShape.width; startY: panelShape.height
|
||||
PathLine { x: panelShape.width - panel.accentLineWidth; y: panelShape.height }
|
||||
PathLine { x: panelShape.width - panel.accentLineWidth; y: panelShape.height - panel.accentLineThickness }
|
||||
PathLine { x: panelShape.width; y: panelShape.height - panel.accentLineThickness }
|
||||
PathLine { x: panelShape.width; y: panelShape.height }
|
||||
}
|
||||
}
|
||||
|
||||
// Header: slug chip, title, and the meta text pinned right.
|
||||
Row {
|
||||
id: headerRow
|
||||
|
||||
x: panel.headerPadding
|
||||
y: Math.round((panel.headerHeight - height) / 2)
|
||||
spacing: panel.headerPadding + 6
|
||||
|
||||
Rectangle {
|
||||
id: slugChip
|
||||
|
||||
width: slugText.implicitWidth + 8
|
||||
height: slugText.implicitHeight + 4
|
||||
color: Theme.accent
|
||||
|
||||
Text {
|
||||
id: slugText
|
||||
|
||||
anchors.centerIn: parent
|
||||
text: panel.panelId
|
||||
color: Theme.surface
|
||||
font.family: Theme.microFont
|
||||
font.pixelSize: 11
|
||||
font.bold: true
|
||||
}
|
||||
}
|
||||
|
||||
Text {
|
||||
anchors.verticalCenter: slugChip.verticalCenter
|
||||
text: panel.title
|
||||
color: Theme.text
|
||||
font.family: Theme.displayFont
|
||||
font.pixelSize: 12
|
||||
font.bold: true
|
||||
font.letterSpacing: 1.1
|
||||
elide: Text.ElideRight
|
||||
}
|
||||
}
|
||||
|
||||
Text {
|
||||
anchors.right: parent.right
|
||||
anchors.rightMargin: panel.headerPadding + 2
|
||||
y: Math.round((panel.headerHeight - implicitHeight) / 2)
|
||||
visible: panel.meta.length > 0
|
||||
text: panel.meta
|
||||
color: Theme.muted
|
||||
font.family: Theme.microFont
|
||||
font.pixelSize: 8
|
||||
font.letterSpacing: 0.7
|
||||
horizontalAlignment: Text.AlignRight
|
||||
elide: Text.ElideRight
|
||||
}
|
||||
|
||||
// Header rule.
|
||||
Rectangle {
|
||||
x: 1
|
||||
y: panel.headerHeight
|
||||
width: parent.width - 2
|
||||
height: 1
|
||||
color: Theme.text
|
||||
opacity: 0.12
|
||||
}
|
||||
|
||||
// Body. Measured by childrenRect, so a child must carry its own size and
|
||||
// must NOT anchor to this slot.
|
||||
Item {
|
||||
id: body
|
||||
|
||||
x: panel.padding
|
||||
y: panel.headerHeight + panel.headerGap
|
||||
width: Math.max(0, panel.width - panel.padding * 2)
|
||||
height: childrenRect.height
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,255 @@
|
||||
pragma ComponentBehavior: Bound
|
||||
|
||||
import QtQuick
|
||||
import Quickshell
|
||||
import Quickshell.Wayland
|
||||
import Quickshell.Services.Polkit
|
||||
import qs.HyprChrome.Theme
|
||||
|
||||
// Polkit authentication agent for the hyprchrome shell.
|
||||
//
|
||||
// Instantiating PolkitAgent IS the registration — it registers a listener for
|
||||
// this logind session in componentComplete(), so there is nothing to start and
|
||||
// nothing to call. Two consequences:
|
||||
//
|
||||
// * Only ONE agent may hold a session. hyprpolkitagent must not be running
|
||||
// (hosts/terra/home/hyprland.nix autostart), or registration fails and this
|
||||
// dialog silently never appears. `isRegistered` is the check.
|
||||
// * `path` is write-once — the binary refuses a later assignment with
|
||||
// "cannot change path after it has been set." Set it here or not at all.
|
||||
//
|
||||
// Concurrent requests SUPERSEDE each other — they do not queue. Verified
|
||||
// against a live trace of two simultaneous `pkexec` calls: both logged
|
||||
// "activating authentication request" back to back, each with its own cookie
|
||||
// and its own "setting up session", with no wait for the first to finish.
|
||||
// `agent.flow` simply becomes the newest request.
|
||||
//
|
||||
// The consequence is that the earlier request is ORPHANED: its PAM session is
|
||||
// live and polkit is still waiting on it, but nothing in QML can reach it any
|
||||
// more, so its caller hangs until it gives up and polkit cancels — which
|
||||
// surfaces as quickshell's "the cancelled request was not found in the queue".
|
||||
// This dialog therefore shows the newest request and loses the older one. See
|
||||
// the flow-change handler below; fixing it properly means holding superseded
|
||||
// flows in QML and re-presenting them, which is only worth doing if concurrent
|
||||
// authorization prompts turn out to happen in practice.
|
||||
//
|
||||
// Everything below re-latches per flow instead of caching it.
|
||||
//
|
||||
// The visual core lives in PolkitPromptContent so it can be rendered headlessly
|
||||
// and staged in DebugWindow; this file owns the agent, the surface and focus.
|
||||
Scope {
|
||||
id: root
|
||||
|
||||
// Which output the dialog appears on. Driven by the shell, which puts it on
|
||||
// the focused monitor rather than on the rail's — a password prompt belongs
|
||||
// where the user is looking. Left unset it falls back to whatever screen
|
||||
// quickshell picks, which is right for a single-monitor session.
|
||||
property var screen: null
|
||||
|
||||
// Where the flow's identity list is currently pointed. Held here rather
|
||||
// than read back off the flow because the content addresses identities by
|
||||
// index and AuthFlow addresses them by object.
|
||||
readonly property var flow: agent.flow
|
||||
|
||||
// Whether this shell actually holds the session's agent. Exposed because
|
||||
// failure is invisible from the outside: an unregistered agent simply never
|
||||
// shows a dialog, which looks exactly like "no one asked for authorization".
|
||||
readonly property alias registered: agent.isRegistered
|
||||
|
||||
// Whether a request is being presented. Both surfaces read it, so it is
|
||||
// decided once here rather than each deriving it — the scrim and the dialog
|
||||
// must come and go on the same frame.
|
||||
//
|
||||
// isCompleted is checked as well as null: the flow reports its terminal
|
||||
// state before the agent drops it, and neither surface should linger for
|
||||
// those frames over a request that has already been decided.
|
||||
readonly property bool prompting: root.flow !== null && !root.flow.isCompleted
|
||||
|
||||
// Reset per REQUEST, not per window show.
|
||||
//
|
||||
// A second request supersedes the first by swapping `flow` while the dialog
|
||||
// is already up, so the window never hides in between. Keying the reset off
|
||||
// the surface's visibility therefore skips that swap entirely and the new
|
||||
// request inherits whatever was typed for the old one — a password entered
|
||||
// for one action left sitting in the box for a different action. The flow
|
||||
// object changing is the event that actually means "new request".
|
||||
// Do NOT cancel the superseded flow here. It is tempting — a superseded
|
||||
// request is unreachable but still live, so its caller hangs until killed,
|
||||
// and cancelling would at least fail it fast. Tried, and it makes things
|
||||
// strictly worse: cancelling a flow that is no longer the agent's active
|
||||
// one tears down state the CURRENT request still needs, and quickshell then
|
||||
// logs
|
||||
//
|
||||
// QObject::connect(AuthFlow, PolkitAgentImpl): invalid nullptr parameter
|
||||
//
|
||||
// leaving the live request with a broken agent and no dialog at all. So the
|
||||
// superseded request is dismissed and the one the user can actually see
|
||||
// never appears. Leaving it orphaned costs one hung caller; cancelling it
|
||||
// costs the prompt as well.
|
||||
onFlowChanged: {
|
||||
if (root.flow) {
|
||||
content.clearResponse();
|
||||
content.focusInput();
|
||||
}
|
||||
}
|
||||
|
||||
function identityIndex(flow) {
|
||||
if (!flow || !flow.selectedIdentity)
|
||||
return 0;
|
||||
for (let i = 0; i < flow.identities.length; i++) {
|
||||
if (flow.identities[i] === flow.selectedIdentity)
|
||||
return i;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
PolkitAgent {
|
||||
id: agent
|
||||
|
||||
// Default is /org/quickshell/PolkitAgent; named explicitly because it
|
||||
// cannot be changed after startup and a second shell would collide.
|
||||
path: "/org/quickshell/PolkitAgent"
|
||||
|
||||
onIsRegisteredChanged: {
|
||||
if (agent.isRegistered)
|
||||
console.info("polkit: agent registered at", agent.path);
|
||||
else
|
||||
console.warn("polkit: agent lost its registration — this session now has no polkit agent");
|
||||
}
|
||||
}
|
||||
|
||||
// Registration is ASYNCHRONOUS. It is started in the agent's
|
||||
// componentComplete but only lands a DBus round trip later — measured at
|
||||
// under 250ms here, still false at Component.onCompleted. So neither an
|
||||
// immediate check nor the change handler above can report a total failure:
|
||||
// an agent that never registers stays false from construction onward and
|
||||
// changes nothing, which is silence rather than an error. Hence a deadline.
|
||||
//
|
||||
// Hot reload is fine: quickshell hands the listener to the new generation
|
||||
// ("taking over listener from previous generation") and isRegistered goes
|
||||
// true again, verified on a live reload.
|
||||
//
|
||||
// Do NOT turn this into a rebuild-and-retry loop. Tried, with the agent in
|
||||
// a Loader so a fresh one could be constructed. It cannot work: the subject
|
||||
// polkit means is the SESSION, this process already holds a listener for
|
||||
// it, and so every rebuilt agent fails identically with
|
||||
//
|
||||
// ...PolicyKit1.Error.Failed:
|
||||
// An authentication agent already exists for the given subject
|
||||
//
|
||||
// Nothing QML can do releases that listener. The one time registration did
|
||||
// fail across a reload, the cause was upstream state already corrupted by
|
||||
// cancelling a superseded flow (see the flow handler above) — not the
|
||||
// reload itself, and not something a retry would have recovered.
|
||||
Timer {
|
||||
interval: 2000
|
||||
running: true
|
||||
|
||||
onTriggered: {
|
||||
if (!agent.isRegistered)
|
||||
console.warn("polkit: agent still unregistered after 2s — another agent (hyprpolkitagent, polkit-gnome, cosmic-osd) is probably holding this session");
|
||||
}
|
||||
}
|
||||
|
||||
// No scrim of its own. The shell owns the single ChromeBackdrop and raises
|
||||
// it for either cause — an expanded rail or an open prompt — so a prompt
|
||||
// arriving over an already-expanded rail reuses the scrim that is already
|
||||
// there instead of stacking a second one on top of it. `prompting` above is
|
||||
// what the shell reads to decide. See HyprChromeShell.
|
||||
PanelWindow {
|
||||
id: win
|
||||
|
||||
screen: root.screen
|
||||
visible: root.prompting
|
||||
|
||||
WlrLayershell.layer: WlrLayer.Overlay
|
||||
// A real modal — unlike the rest of the rail, this one must take the
|
||||
// keyboard, or the password goes to whatever window was focused.
|
||||
WlrLayershell.keyboardFocus: WlrKeyboardFocus.Exclusive
|
||||
exclusionMode: ExclusionMode.Ignore
|
||||
color: Theme.textAlpha(0)
|
||||
|
||||
anchors {
|
||||
top: true
|
||||
left: true
|
||||
right: true
|
||||
bottom: true
|
||||
}
|
||||
|
||||
// No scrim here — ChromeBackdrop above draws it. This surface stays
|
||||
// transparent but unmasked, so it still swallows clicks across the
|
||||
// whole output: a polkit request is answered or explicitly cancelled,
|
||||
// and losing one to a stray click on the wallpaper would leave the
|
||||
// caller waiting with no visible reason.
|
||||
|
||||
PolkitPromptContent {
|
||||
id: content
|
||||
|
||||
// A third of the way down rather than centred: a password prompt
|
||||
// reads better above the middle, and on a tall output dead-centre
|
||||
// puts it below the natural resting line of the eye.
|
||||
//
|
||||
// The panel's own CENTRE lands on the third, so the dialog grows
|
||||
// symmetrically about that line as the message wraps or a pam_info
|
||||
// line appears. Floored at the same margin the width leaves, so a
|
||||
// tall prompt on a short output cannot be pushed off the top.
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
y: Math.max(32, Math.round(parent.height / 3 - height / 2))
|
||||
width: 520
|
||||
|
||||
message: root.flow ? root.flow.message : ""
|
||||
actionId: root.flow ? root.flow.actionId : ""
|
||||
iconName: root.flow ? root.flow.iconName : ""
|
||||
identities: root.flow ? root.flow.identities : []
|
||||
selectedIdentity: root.identityIndex(root.flow)
|
||||
responseRequired: root.flow ? root.flow.isResponseRequired : false
|
||||
inputPrompt: root.flow ? root.flow.inputPrompt : ""
|
||||
responseVisible: root.flow ? root.flow.responseVisible : false
|
||||
supplementaryMessage: root.flow ? root.flow.supplementaryMessage : ""
|
||||
supplementaryIsError: root.flow ? root.flow.supplementaryIsError : false
|
||||
failed: root.flow ? root.flow.failed : false
|
||||
|
||||
onSubmitted: value => {
|
||||
if (root.flow)
|
||||
root.flow.submit(value);
|
||||
}
|
||||
|
||||
onCancelled: {
|
||||
if (root.flow)
|
||||
root.flow.cancelAuthenticationRequest();
|
||||
}
|
||||
|
||||
// AuthFlow refuses a null identity, so the index is bounds-checked
|
||||
// here rather than trusting the view.
|
||||
onIdentityRequested: index => {
|
||||
if (root.flow && index >= 0 && index < root.flow.identities.length)
|
||||
root.flow.selectedIdentity = root.flow.identities[index];
|
||||
}
|
||||
}
|
||||
|
||||
// Wipe the box on a rejected attempt. `failed` flags the attempt, not
|
||||
// the request — polkit lets PAM retry, and the flow stays live with a
|
||||
// fresh prompt, so the field has to be cleared without closing.
|
||||
Connections {
|
||||
target: root.flow
|
||||
enabled: root.flow !== null
|
||||
|
||||
function onFailedChanged() {
|
||||
if (root.flow.failed)
|
||||
content.clearResponse();
|
||||
}
|
||||
|
||||
// Re-focus when the conversation asks for something. This is load
|
||||
// bearing, not defensive: a flow arrives with isResponseRequired
|
||||
// FALSE and an empty inputPrompt — PAM has not asked yet — so the
|
||||
// window becomes visible while the field is still disabled, and the
|
||||
// focusInput() below it cannot land. The prompt shows up a moment
|
||||
// later, and that is the edge that must take the keyboard. The same
|
||||
// handler covers a second factor and a post-failure retry.
|
||||
function onIsResponseRequiredChanged() {
|
||||
if (root.flow.isResponseRequired)
|
||||
content.focusInput();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,257 @@
|
||||
pragma ComponentBehavior: Bound
|
||||
|
||||
import QtQuick
|
||||
import QtQuick.Layouts
|
||||
import Quickshell
|
||||
import Quickshell.Widgets
|
||||
import qs.HyprChrome.Theme
|
||||
|
||||
// Headlessly renderable visual core of the polkit authentication prompt.
|
||||
//
|
||||
// Nothing here imports Quickshell.Services.Polkit: every field an AuthFlow
|
||||
// exposes arrives as a plain property and every action leaves as a signal, so
|
||||
// the whole dialog can be rendered offscreen (tools/quickshell-preview) and
|
||||
// staged in DebugWindow without a real authorization request. PolkitPrompt.qml
|
||||
// owns the agent and does the mapping.
|
||||
//
|
||||
// `identities` is read structurally — each entry only needs `displayName` — so
|
||||
// the adapter can hand over the flow's QList<Identity*> unchanged while the
|
||||
// headless test passes plain JS objects.
|
||||
Item {
|
||||
id: root
|
||||
|
||||
// ---- flow state, mirrored ----
|
||||
property string message: ""
|
||||
property string actionId: ""
|
||||
property string iconName: ""
|
||||
property bool showIcon: true
|
||||
|
||||
// Who may authenticate. One entry is the common case and renders as a
|
||||
// plain line; the picker only appears when polkit actually offers a
|
||||
// choice (a user in several admin groups, or root plus wheel).
|
||||
property var identities: []
|
||||
property int selectedIdentity: 0
|
||||
|
||||
// PAM conversation. `responseVisible` is polkit's echo flag — it is NOT
|
||||
// always false: a smartcard PIN prompt or a security-question stack asks
|
||||
// for echoed input, and masking those makes the prompt unusable.
|
||||
property bool responseRequired: false
|
||||
property string inputPrompt: ""
|
||||
property bool responseVisible: false
|
||||
|
||||
// pam_info / pam_error text, and whether the last attempt was rejected.
|
||||
property string supplementaryMessage: ""
|
||||
property bool supplementaryIsError: false
|
||||
property bool failed: false
|
||||
|
||||
property alias response: responseInput.text
|
||||
|
||||
signal submitted(string value)
|
||||
signal cancelled
|
||||
signal identityRequested(int index)
|
||||
|
||||
function focusInput() { responseInput.forceActiveFocus(); }
|
||||
function clearResponse() { responseInput.text = ""; }
|
||||
|
||||
implicitWidth: 520
|
||||
implicitHeight: panel.implicitHeight
|
||||
|
||||
// Escape reaches here by propagating up the focus chain from the TextInput,
|
||||
// which does not consume it — so cancelling works whether or not the input
|
||||
// currently has focus.
|
||||
Keys.onEscapePressed: event => {
|
||||
root.cancelled();
|
||||
event.accepted = true;
|
||||
}
|
||||
|
||||
component MicroText: Text {
|
||||
color: Theme.muted
|
||||
font.family: Theme.microFont
|
||||
font.pixelSize: 8
|
||||
font.letterSpacing: 0.9
|
||||
elide: Text.ElideRight
|
||||
}
|
||||
|
||||
PolkitPanel {
|
||||
id: panel
|
||||
|
||||
width: root.width
|
||||
panelId: "PKT"
|
||||
title: "AUTHORIZATION REQUIRED"
|
||||
// The action id is the one piece that says WHAT is being authorized
|
||||
// independently of the (localizable, often vague) message.
|
||||
meta: root.actionId
|
||||
|
||||
// The body slot decides the width and the layout's implicitHeight
|
||||
// becomes its height, so a wrapped message or an extra pam_info line
|
||||
// grows the panel instead of being clipped.
|
||||
ColumnLayout {
|
||||
width: parent.width
|
||||
spacing: 10
|
||||
|
||||
// ---- what is being asked ----
|
||||
RowLayout {
|
||||
Layout.fillWidth: true
|
||||
spacing: 10
|
||||
|
||||
IconImage {
|
||||
visible: root.showIcon && root.iconName !== ""
|
||||
implicitSize: 32
|
||||
source: root.showIcon && root.iconName !== ""
|
||||
? Quickshell.iconPath(root.iconName, "dialog-password")
|
||||
: ""
|
||||
}
|
||||
|
||||
Text {
|
||||
Layout.fillWidth: true
|
||||
wrapMode: Text.Wrap
|
||||
text: root.message
|
||||
color: Theme.text
|
||||
font.family: Theme.displayFont
|
||||
font.pixelSize: 13
|
||||
font.letterSpacing: 0.6
|
||||
}
|
||||
}
|
||||
|
||||
// ---- identity ----
|
||||
// Single identity: stated, not offered. Several: chips, because a
|
||||
// combo box would be the only QtQuick.Controls widget in the rail.
|
||||
MicroText {
|
||||
Layout.fillWidth: true
|
||||
visible: root.identities.length === 1
|
||||
text: "AS " + (root.identities.length === 1
|
||||
? root.identities[0].displayName : "")
|
||||
}
|
||||
|
||||
Flow {
|
||||
Layout.fillWidth: true
|
||||
visible: root.identities.length > 1
|
||||
spacing: 6
|
||||
|
||||
Repeater {
|
||||
model: root.identities
|
||||
|
||||
Rectangle {
|
||||
id: chip
|
||||
|
||||
required property int index
|
||||
required property var modelData
|
||||
|
||||
readonly property bool current: chip.index === root.selectedIdentity
|
||||
|
||||
width: chipLabel.implicitWidth + 14
|
||||
height: chipLabel.implicitHeight + 8
|
||||
color: chip.current ? Theme.accent : "transparent"
|
||||
border.width: 1
|
||||
border.color: chip.current ? Theme.accent : Theme.disabled
|
||||
|
||||
Text {
|
||||
id: chipLabel
|
||||
anchors.centerIn: parent
|
||||
text: chip.modelData.displayName
|
||||
color: chip.current ? Theme.surface : Theme.muted
|
||||
font.family: Theme.microFont
|
||||
font.pixelSize: 9
|
||||
font.letterSpacing: 0.8
|
||||
}
|
||||
|
||||
MouseArea {
|
||||
anchors.fill: parent
|
||||
onClicked: root.identityRequested(chip.index)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ---- the conversation ----
|
||||
Rectangle {
|
||||
Layout.fillWidth: true
|
||||
implicitHeight: 34
|
||||
color: Theme.selection
|
||||
border.width: 1
|
||||
border.color: root.failed ? Theme.hot : Theme.hair
|
||||
|
||||
RowLayout {
|
||||
anchors.fill: parent
|
||||
anchors.leftMargin: 10
|
||||
anchors.rightMargin: 10
|
||||
spacing: 10
|
||||
|
||||
Text {
|
||||
text: ">_"
|
||||
color: root.responseRequired ? Theme.accent : Theme.disabled
|
||||
font.family: Theme.displayFont
|
||||
font.pixelSize: 15
|
||||
font.bold: true
|
||||
}
|
||||
|
||||
TextInput {
|
||||
id: responseInput
|
||||
|
||||
Layout.fillWidth: true
|
||||
Layout.fillHeight: true
|
||||
verticalAlignment: TextInput.AlignVCenter
|
||||
enabled: root.responseRequired
|
||||
color: Theme.text
|
||||
selectionColor: Theme.accent
|
||||
selectedTextColor: Theme.surface
|
||||
font.family: Theme.displayFont
|
||||
font.pixelSize: 14
|
||||
font.letterSpacing: 1
|
||||
clip: true
|
||||
|
||||
echoMode: root.responseVisible
|
||||
? TextInput.Normal : TextInput.Password
|
||||
passwordCharacter: "▪"
|
||||
// Qt reveals the last typed character for a moment by
|
||||
// default. On a screen-visible layer-shell overlay
|
||||
// that is a shoulder-surfing hole, so: never.
|
||||
passwordMaskDelay: 0
|
||||
|
||||
onAccepted: {
|
||||
if (root.responseRequired)
|
||||
root.submitted(responseInput.text);
|
||||
}
|
||||
|
||||
// Placeholder: TextInput has none of its own, and the
|
||||
// PAM prompt ("Password:", "PIN:") is the only label
|
||||
// this field gets.
|
||||
Text {
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
visible: responseInput.text.length === 0
|
||||
text: root.inputPrompt
|
||||
color: Theme.disabled
|
||||
font: responseInput.font
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ---- pam_info / pam_error ----
|
||||
Text {
|
||||
Layout.fillWidth: true
|
||||
visible: root.supplementaryMessage !== ""
|
||||
wrapMode: Text.Wrap
|
||||
text: root.supplementaryMessage
|
||||
color: root.supplementaryIsError ? Theme.hot : Theme.muted
|
||||
font.family: Theme.microFont
|
||||
font.pixelSize: 9
|
||||
font.letterSpacing: 0.7
|
||||
}
|
||||
|
||||
// ---- key hints ----
|
||||
RowLayout {
|
||||
Layout.fillWidth: true
|
||||
spacing: 14
|
||||
|
||||
MicroText { text: "ENTER AUTHENTICATE" }
|
||||
MicroText { text: "ESC CANCEL" }
|
||||
Item { Layout.fillWidth: true }
|
||||
MicroText {
|
||||
text: root.responseVisible ? "ECHO ON" : ""
|
||||
color: Theme.hot
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,163 +0,0 @@
|
||||
pragma ComponentBehavior: Bound
|
||||
|
||||
import Quickshell
|
||||
import Quickshell.Wayland
|
||||
import QtQuick
|
||||
import qs.hyprchrome.theme
|
||||
|
||||
// Full-screen scrim behind the bar: dims the desktop and lays the dense bar's
|
||||
// drafting grid over it while the rail is expanded.
|
||||
//
|
||||
// Sits on the TOP layer while the bar itself is on OVERLAY. Two surfaces on the
|
||||
// same layer stack by creation order, which is not something to rely on; one
|
||||
// layer apart is a guarantee — above ordinary windows, below the bar.
|
||||
//
|
||||
// It reserves nothing and takes no input: the mask is an empty Region, so
|
||||
// clicks land on whatever is underneath rather than on the scrim.
|
||||
PanelWindow {
|
||||
id: backdrop
|
||||
|
||||
property bool active: true
|
||||
property real dim: 0.55
|
||||
property int gridSpacing: 120
|
||||
|
||||
// The dense bar drew this grid at 0.018 against its own near-black panel.
|
||||
// Over a 55% scrim on top of lit windows that is invisible, so it is a
|
||||
// knob rather than a constant.
|
||||
property real gridOpacity: 0.1
|
||||
|
||||
// The accent with its saturation pulled back: warm enough to read as part
|
||||
// of the palette, not so loud that a full-screen grid competes with the
|
||||
// bar. Derived rather than a literal so it tracks a palette change.
|
||||
// Registration crosses sit on every other intersection of the grid.
|
||||
property color crossColor: Theme.muted
|
||||
property real crossOpacity: 0.35
|
||||
property int crossSize: 20
|
||||
|
||||
// Thickness in STEPS, not pixels: 1 -> 1px, 2 -> 3px, 3 -> 5px. Only odd
|
||||
// widths can straddle a 1px rule symmetrically, so an even pixel count
|
||||
// would push every mark half a pixel off the grid it registers against.
|
||||
property int crossThickness: 2
|
||||
readonly property int crossWeight: Math.max(1, backdrop.crossThickness) * 2 - 1
|
||||
|
||||
property color gridColor: Qt.hsla(Theme.accent.hslHue,
|
||||
Theme.accent.hslSaturation * 0.45,
|
||||
Theme.accent.hslLightness,
|
||||
1)
|
||||
|
||||
visible: scrim.opacity > 0
|
||||
|
||||
WlrLayershell.namespace: "hyprchrome-scrim"
|
||||
WlrLayershell.layer: WlrLayer.Top
|
||||
WlrLayershell.keyboardFocus: WlrKeyboardFocus.None
|
||||
exclusionMode: ExclusionMode.Ignore
|
||||
color: "transparent"
|
||||
|
||||
readonly property int crossColumns: Math.ceil(backdrop.width / (backdrop.gridSpacing * 2)) + 1
|
||||
readonly property int crossRows: Math.ceil(backdrop.height / (backdrop.gridSpacing * 2)) + 1
|
||||
|
||||
anchors {
|
||||
top: true
|
||||
left: true
|
||||
right: true
|
||||
bottom: true
|
||||
}
|
||||
|
||||
mask: Region {}
|
||||
|
||||
Item {
|
||||
id: scrim
|
||||
|
||||
anchors.fill: parent
|
||||
opacity: backdrop.active ? 1 : 0
|
||||
|
||||
// Matched to the bar's own collapse so the scrim and the panels resolve
|
||||
// together rather than one trailing the other.
|
||||
Behavior on opacity {
|
||||
NumberAnimation {
|
||||
duration: 200
|
||||
easing.type: Easing.OutCubic
|
||||
}
|
||||
}
|
||||
|
||||
Rectangle {
|
||||
anchors.fill: parent
|
||||
color: Theme.surface
|
||||
opacity: backdrop.dim
|
||||
}
|
||||
|
||||
// Faint drafting grid; no gradient and deliberately subordinate to
|
||||
// whatever is showing through it.
|
||||
Repeater {
|
||||
model: Math.ceil(scrim.width / backdrop.gridSpacing)
|
||||
|
||||
Rectangle {
|
||||
required property int index
|
||||
|
||||
x: index * backdrop.gridSpacing
|
||||
width: 1
|
||||
height: scrim.height
|
||||
color: backdrop.gridColor
|
||||
opacity: backdrop.gridOpacity
|
||||
}
|
||||
}
|
||||
|
||||
Repeater {
|
||||
model: Math.ceil(scrim.height / backdrop.gridSpacing)
|
||||
|
||||
Rectangle {
|
||||
required property int index
|
||||
|
||||
y: index * backdrop.gridSpacing
|
||||
width: scrim.width
|
||||
height: 1
|
||||
color: backdrop.gridColor
|
||||
opacity: backdrop.gridOpacity
|
||||
}
|
||||
}
|
||||
|
||||
// Register marks on every other line, so they land on a 2x grid rather
|
||||
// than on every crossing — sparse enough to read as drafting registration
|
||||
// rather than as texture.
|
||||
Repeater {
|
||||
model: backdrop.crossColumns * backdrop.crossRows
|
||||
|
||||
Item {
|
||||
required property int index
|
||||
|
||||
readonly property int column: index % backdrop.crossColumns
|
||||
readonly property int row: Math.floor(index / backdrop.crossColumns)
|
||||
|
||||
// Marks on every other rule in both directions, so they line up
|
||||
// in columns as well as rows. Both offsets are whole multiples of
|
||||
// gridSpacing, so every mark lands on a real intersection.
|
||||
//
|
||||
// Math.floor, not /2: the item offset and the bars inside it must
|
||||
// round the same way, or an even crossSize sits half a pixel off the
|
||||
// rule it marks.
|
||||
x: column * backdrop.gridSpacing * 2 - Math.floor(backdrop.crossSize / 2)
|
||||
y: row * backdrop.gridSpacing * 2 - Math.floor(backdrop.crossSize / 2)
|
||||
width: backdrop.crossSize
|
||||
height: backdrop.crossSize
|
||||
opacity: backdrop.crossOpacity
|
||||
|
||||
Rectangle {
|
||||
// Placed with the same Math.floor the item's own offset uses.
|
||||
// anchors.verticalCenter halves the height unfloored, so an even
|
||||
// crossSize put the 1px bar half a pixel off the rule it marks.
|
||||
y: Math.floor(backdrop.crossSize / 2) - Math.floor(backdrop.crossWeight / 2)
|
||||
width: parent.width
|
||||
height: backdrop.crossWeight
|
||||
color: backdrop.crossColor
|
||||
}
|
||||
|
||||
Rectangle {
|
||||
x: Math.floor(backdrop.crossSize / 2) - Math.floor(backdrop.crossWeight / 2)
|
||||
width: backdrop.crossWeight
|
||||
height: parent.height
|
||||
color: backdrop.crossColor
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,143 +0,0 @@
|
||||
import QtQuick
|
||||
import QtQuick.Shapes
|
||||
import QtQuick.Layouts
|
||||
import Quickshell
|
||||
import Quickshell.Hyprland
|
||||
import Quickshell.Wayland
|
||||
import qs.hyprchrome.widgets
|
||||
import qs.hyprchrome.widgets.host
|
||||
import qs.hyprchrome.widgets.vitals
|
||||
import qs.hyprchrome.widgets.tray
|
||||
|
||||
Scope {
|
||||
id: root
|
||||
|
||||
// Monitor the rail lives on. Falls back to the FIRST connected screen when
|
||||
// the name matches nothing, so the bar still appears on a single-monitor
|
||||
// session or after a cable swap (DebugWindow falls back to the last one
|
||||
// instead — it wants the secondary).
|
||||
property string screenName: "DP-2"
|
||||
|
||||
// Quickshell.screens is a QML list, not a JS array — no .find() on it.
|
||||
readonly property var targetScreen: {
|
||||
const screens = Quickshell.screens;
|
||||
if (screens.length === 0)
|
||||
return null;
|
||||
for (let i = 0; i < screens.length; i++) {
|
||||
if (screens[i].name === root.screenName)
|
||||
return screens[i];
|
||||
}
|
||||
return screens[0];
|
||||
}
|
||||
|
||||
// Density is a property of the BAR: every panel follows it, so the whole rail
|
||||
// expands and collapses as one. Panels keep their own animation; only the
|
||||
// decision is centralised here.
|
||||
property bool expanded: true
|
||||
|
||||
function toggle() {
|
||||
root.expanded = !root.expanded;
|
||||
}
|
||||
|
||||
// SUPER A — see hosts/terra/home/hyprland.nix.
|
||||
GlobalShortcut {
|
||||
name: "chrome"
|
||||
description: "Expand or collapse the hyprchrome bar"
|
||||
onPressed: root.toggle()
|
||||
}
|
||||
|
||||
// Scrim first: it is a layer below the bar, so stacking does not depend on
|
||||
// creation order, but keeping the declaration order the same as the visual
|
||||
// order costs nothing.
|
||||
ChromeBackdrop {
|
||||
screen: root.targetScreen
|
||||
active: root.expanded
|
||||
}
|
||||
|
||||
PanelWindow {
|
||||
id: window
|
||||
|
||||
screen: root.targetScreen
|
||||
visible: root.targetScreen !== null
|
||||
|
||||
// One layer above the scrim, so the stacking is guaranteed rather than
|
||||
// dependent on surface creation order. See ChromeBackdrop.
|
||||
// Own namespace so a layerrule can exempt the rail from Hyprland's layer
|
||||
// animation without also catching the launchers, which share the default
|
||||
// "quickshell" namespace and do want their fade.
|
||||
WlrLayershell.namespace: "hyprchrome-bar"
|
||||
WlrLayershell.layer: WlrLayer.Overlay
|
||||
|
||||
property int margin: 12
|
||||
|
||||
// The surface never resizes: it is always tall enough for the expanded
|
||||
// rail, and only the exclusive zone tracks the current state. Resizing a
|
||||
// layer surface makes Hyprland animate the change, which showed up as the
|
||||
// panels twitching a pixel or two the moment the collapse finished.
|
||||
//
|
||||
// The zone still follows the target height, so tiled windows reflow once
|
||||
// per toggle, at the start, and slide while the panels animate.
|
||||
readonly property real expandedContent: Math.max(hostPanel.expandedHeight, vitalsPanel.expandedHeight, trayPanel.expandedHeight) + window.margin * 2
|
||||
readonly property real contentHeight: Math.max(hostPanel.targetHeight, vitalsPanel.targetHeight, trayPanel.targetHeight) + window.margin * 2
|
||||
|
||||
implicitHeight: Math.round(window.expandedContent)
|
||||
|
||||
exclusionMode: ExclusionMode.Normal
|
||||
exclusiveZone: Math.round(window.contentHeight)
|
||||
|
||||
// Only the panels take input. Without this the surface would keep eating
|
||||
// clicks across its full height while the rail is collapsed.
|
||||
mask: Region {
|
||||
item: panelRow
|
||||
}
|
||||
|
||||
anchors { top: true; left: true; right: true; }
|
||||
|
||||
color: "transparent"
|
||||
|
||||
RowLayout {
|
||||
id: panelRow
|
||||
x: window.margin
|
||||
y: window.margin
|
||||
width: window.width - window.margin * 2
|
||||
spacing: 0
|
||||
|
||||
HostPanel {
|
||||
id: hostPanel
|
||||
|
||||
expanded: root.expanded
|
||||
// Vitals butts against its right edge; the left end of the row is free.
|
||||
rightChamfer: false
|
||||
|
||||
toggleOnClick: false
|
||||
Layout.preferredWidth: 350
|
||||
Layout.fillHeight: true
|
||||
}
|
||||
|
||||
VitalsPanel {
|
||||
id: vitalsPanel
|
||||
|
||||
expanded: root.expanded
|
||||
// Host on the left, the spacer on the right — and a spacer is not a
|
||||
// panel, so that edge keeps its cut.
|
||||
leftChamfer: false
|
||||
|
||||
toggleOnClick: false
|
||||
Layout.preferredWidth: 500
|
||||
Layout.fillHeight: true
|
||||
}
|
||||
|
||||
// Slack lives between the left group and the tray, so the tray sits
|
||||
// flush right whatever the other panels measure.
|
||||
Item { Layout.fillWidth: true }
|
||||
|
||||
TrayPanel {
|
||||
id: trayPanel
|
||||
|
||||
expanded: root.expanded
|
||||
toggleOnClick: false
|
||||
Layout.fillHeight: true
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -10,17 +10,21 @@ import qs.widgets.osd
|
||||
import qs.widgets.systray
|
||||
import qs.widgets.theme
|
||||
import qs.widgets.vitals
|
||||
import qs.hyprchrome
|
||||
import qs.hyprchrome.widgets
|
||||
import qs.hyprchrome.widgets.debug
|
||||
import qs.hyprchrome.widgets.host
|
||||
import qs.hyprchrome.widgets.vitals
|
||||
import qs.HyprChrome
|
||||
import qs.HyprChrome.Widgets
|
||||
import qs.HyprChrome.Widgets.Bar.Debug
|
||||
import qs.HyprChrome.Widgets.Bar.Host
|
||||
import qs.HyprChrome.Widgets.Bar.Vitals
|
||||
|
||||
Scope {
|
||||
// Dense multi-monitor status rail; visual core is headlessly renderable.
|
||||
HyprChromeBar {}
|
||||
HyprChromeShell {}
|
||||
|
||||
// App launcher variants — 1–11; variant 8 remains the primary HUD.
|
||||
// App launcher variants still under evaluation, on SUPER CTRL 1–11.
|
||||
// Variant 8 — the primary launcher on SUPER_L — has moved into
|
||||
// HyprChrome/Widgets/Launcher and is instantiated by HyprChromeShell,
|
||||
// because the shell owns the scrim, the focused monitor and the keyboard
|
||||
// arbitration it now shares with the polkit prompt.
|
||||
LauncherStack {} // 1 — left vertical list
|
||||
LauncherGrid {} // 2 — centered icon grid
|
||||
LauncherSpotlight {} // 3 — top-center command bar
|
||||
@@ -28,12 +32,12 @@ Scope {
|
||||
LauncherDock {} // 5 — deck rising from the bottom bar
|
||||
LauncherSlant {} // 6 — angular / sheared panel
|
||||
LauncherCorner {} // 7 — Slant (V6) copy + floating power panel (shutdown/reboot)
|
||||
ApplicationLauncher {} // 8 — dense HUD command index (primary)
|
||||
BladeLauncher {} // 9 — asymmetric blade matrix
|
||||
OrbitLauncher {} // 10 — radial targeting arena
|
||||
CyberDock {} // 11 — cyberpunk bottom cartridge dock
|
||||
|
||||
Notifications {}
|
||||
|
||||
VolumeOsd {}
|
||||
|
||||
// Host vitals HUD — toggle with SUPER CTRL V.
|
||||
|
||||
+2
-2
@@ -1,7 +1,7 @@
|
||||
import QtQuick
|
||||
import qs.widgets.launcher
|
||||
import qs.HyprChrome.Widgets.Launcher
|
||||
|
||||
ApplicationLauncherContent {
|
||||
AppLauncherContent {
|
||||
width: 1080
|
||||
height: 620
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
import QtQuick
|
||||
import qs.HyprChrome.Widgets.Polkit
|
||||
|
||||
// Offscreen render of the polkit prompt with a failed first attempt and two
|
||||
// eligible identities — the state that exercises every optional element at
|
||||
// once (picker, pam_error text, rejected-attempt border).
|
||||
//
|
||||
// ./tools/quickshell-preview/render.sh \
|
||||
// tests/PolkitPromptHeadless.qml \
|
||||
// .artifacts/quickshell-preview/polkit-prompt.png 560 320
|
||||
PolkitPromptContent {
|
||||
width: 520
|
||||
|
||||
message: "Authentication is required to install or remove software"
|
||||
actionId: "org.freedesktop.packagekit.package-install"
|
||||
iconName: "system-software-install"
|
||||
showIcon: false
|
||||
|
||||
identities: [
|
||||
{ id: "1000", displayName: "darman", isGroup: false },
|
||||
{ id: "0", displayName: "root", isGroup: false }
|
||||
]
|
||||
selectedIdentity: 0
|
||||
|
||||
responseRequired: true
|
||||
inputPrompt: "Password:"
|
||||
responseVisible: false
|
||||
response: "hunter2"
|
||||
|
||||
supplementaryMessage: "Authentication failure. 2 attempts remaining."
|
||||
supplementaryIsError: true
|
||||
failed: true
|
||||
}
|
||||
Generated
+40
-40
@@ -14,11 +14,11 @@
|
||||
"uv2nix": "uv2nix"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1787577519,
|
||||
"narHash": "sha256-YNAXQTgR26RJiX2vtYjk6OtBu2jMWeq4qUN6sUrt6Lc=",
|
||||
"lastModified": 1788820723,
|
||||
"narHash": "sha256-NIqHasKysUniYrJozavASUF4MqpsyBg7lZZNtM+WrwI=",
|
||||
"owner": "nix-community",
|
||||
"repo": "authentik-nix",
|
||||
"rev": "30c37930450d7a5fefa8ffec613f037fc75c3071",
|
||||
"rev": "fd34a5238314351ed92dd79d00f518b8a03e19cb",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
@@ -30,16 +30,16 @@
|
||||
"authentik-src": {
|
||||
"flake": false,
|
||||
"locked": {
|
||||
"lastModified": 1784731584,
|
||||
"narHash": "sha256-/HdXzjjvuSW7zjbCNJKm3Fj8gvIwfrDf8mOYev0yuIg=",
|
||||
"lastModified": 1788268887,
|
||||
"narHash": "sha256-069RXUkk4aSYVelezdmYM70TGIJM8KyTBrLW3Vv0XdM=",
|
||||
"owner": "goauthentik",
|
||||
"repo": "authentik",
|
||||
"rev": "0c67ea476be6319f1b2a41cb0f5ed128af37b99b",
|
||||
"rev": "b4de7336e903ef51febf42c0ff3b57c484866cdc",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "goauthentik",
|
||||
"ref": "version/2026.5.6",
|
||||
"ref": "version/2026.8.1",
|
||||
"repo": "authentik",
|
||||
"type": "github"
|
||||
}
|
||||
@@ -47,11 +47,11 @@
|
||||
"client-ts-generator-src": {
|
||||
"flake": false,
|
||||
"locked": {
|
||||
"lastModified": 1784638510,
|
||||
"narHash": "sha256-NfwEWQ/SRjgeUz+F/7uoWAMwk7OqdF2+686krhvJn2M=",
|
||||
"lastModified": 1787926240,
|
||||
"narHash": "sha256-CNazk55jeMBdP/5cf9scshRGCiKALdERny8Oues1zcY=",
|
||||
"owner": "goauthentik",
|
||||
"repo": "client-ts",
|
||||
"rev": "5850af5867bef6fd4291731797d21b704c7f189d",
|
||||
"rev": "26b3e23c928e22e4aa66223b5b996e9e68047f0f",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
@@ -101,11 +101,11 @@
|
||||
"nixpkgs-lib": "nixpkgs-lib"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1785627969,
|
||||
"narHash": "sha256-4dtXQk/NMePegK/nWp5NSeuZKLATItOq61lpEvmXqGw=",
|
||||
"lastModified": 1788450739,
|
||||
"narHash": "sha256-glZLQlzIn1fXH6PazR2iUmTo7kzzyYSshrWhLS9TqCU=",
|
||||
"owner": "hercules-ci",
|
||||
"repo": "flake-parts",
|
||||
"rev": "427bf4bd9435fdf21321c8cc628c24efc14c0f7a",
|
||||
"rev": "31729ca8cbdb4fa927b34e5f4353e6a83f39e993",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
@@ -142,11 +142,11 @@
|
||||
]
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1787377438,
|
||||
"narHash": "sha256-Sxu1NLTD/Ern6hFGLlZmtKCSct3YQXZI/lls8RE1XeM=",
|
||||
"lastModified": 1788642154,
|
||||
"narHash": "sha256-sPpQFVaFTDqO/4vvCAhuAhqTgqN/ygu+9eJcs5eB0js=",
|
||||
"owner": "nix-community",
|
||||
"repo": "home-manager",
|
||||
"rev": "65258d5c65a250189fde2e35f490d15e064c4c62",
|
||||
"rev": "fd0956c99c41ae3c13a73a638f1f7e963aebc4ab",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
@@ -270,11 +270,11 @@
|
||||
"treefmt-nix": "treefmt-nix"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1787728766,
|
||||
"narHash": "sha256-g2oZlrBU3AI2ubCiY/UyE9ALTIDueTcF//QP3vaY9IQ=",
|
||||
"lastModified": 1788938537,
|
||||
"narHash": "sha256-ooFA+3//Y9bpyFjVwTvPegsWngEoQ0pGj+2DJ5cVyJ0=",
|
||||
"owner": "nix-community",
|
||||
"repo": "nixos-anywhere",
|
||||
"rev": "6b77f26ec4538ced04bf1d02f374b0ec02e9c27e",
|
||||
"rev": "9df41112343713520ba071674cf8e45e91c25845",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
@@ -291,11 +291,11 @@
|
||||
"nixos-unstable": "nixos-unstable"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1787826771,
|
||||
"narHash": "sha256-gWkyr3I/cg4SHWGkAoUo24+BQaqoi+S0T2JxDjsA+pw=",
|
||||
"lastModified": 1789036642,
|
||||
"narHash": "sha256-ng2Ou1UrVCP98OAJiq8Mv6aDF/kjQWyaKm4PaxWtAu4=",
|
||||
"owner": "nix-community",
|
||||
"repo": "nixos-images",
|
||||
"rev": "f6714acc84ce92df7286c89a571ad1e946057a5b",
|
||||
"rev": "4fcaaefd02b5bc777f99afd620cb1a9aa1fb5b83",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
@@ -323,11 +323,11 @@
|
||||
},
|
||||
"nixpkgs": {
|
||||
"locked": {
|
||||
"lastModified": 1786862985,
|
||||
"narHash": "sha256-FBJRXmbGXiSUDvYEbfLYRkckayyZ6SK1UEqhCrIZ2Cs=",
|
||||
"lastModified": 1788316716,
|
||||
"narHash": "sha256-bc7rSpXIdn9QWGNqfWcPZWOhEVF8NoeAZkWq0XWnf/k=",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "e5bdc4a41d4c072fe1e3787eaa0320a384741d44",
|
||||
"rev": "3ed67ec0a4d3c7ab4ae1f04f8ee8df07bfa506a2",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
@@ -339,11 +339,11 @@
|
||||
},
|
||||
"nixpkgs-lib": {
|
||||
"locked": {
|
||||
"lastModified": 1785031560,
|
||||
"narHash": "sha256-OmshNvn2vupOFpYinLUu+1Dnpu4n7Q5N3ggGVNHpkUI=",
|
||||
"lastModified": 1788057806,
|
||||
"narHash": "sha256-DTQSMxzDWmT0zhguthvegnVkn7CFqGCv4IHCzk5ZUpM=",
|
||||
"owner": "nix-community",
|
||||
"repo": "nixpkgs.lib",
|
||||
"rev": "0e79af5e3d4dcfcd676ab5ba3f95d2e3352e078c",
|
||||
"rev": "596e2e3940e09b2abbeb03f75fa1828c57fcd72c",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
@@ -354,11 +354,11 @@
|
||||
},
|
||||
"nixpkgs-unstable": {
|
||||
"locked": {
|
||||
"lastModified": 1787814960,
|
||||
"narHash": "sha256-PYZq1qzCJXC2zGI0mH07vrZBsw6DRBAOX0jN1pPtqOQ=",
|
||||
"lastModified": 1789073787,
|
||||
"narHash": "sha256-xfX/toC2QV707s06GbP4II/TxYF0fNQj7s5/LClNDKc=",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "c27cdad491a991b11ed731760aa2ef8db0cb0410",
|
||||
"rev": "aff8a0b28396750446e5537a96461bc4facdb287",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
@@ -370,11 +370,11 @@
|
||||
},
|
||||
"nixpkgs_2": {
|
||||
"locked": {
|
||||
"lastModified": 1787753485,
|
||||
"narHash": "sha256-BZWCi9ZRJiARTuKTbbtvFTj7t1TK4G3UEckT3HyNfRg=",
|
||||
"lastModified": 1789009968,
|
||||
"narHash": "sha256-GB16oaxpsrnGNnGIE+0uYBqMRzB9X6FYDUvjvnJAYew=",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "062346a6d85bc4b49dfaa61c986e9c5be21217d1",
|
||||
"rev": "d58a46e3bc02d91ebe04667f8397752a749c0024",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
@@ -507,11 +507,11 @@
|
||||
]
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1786629091,
|
||||
"narHash": "sha256-gkig4nPi1CWc4Z50GBsjE4ygSE7hMpl/TwID2an2Cck=",
|
||||
"lastModified": 1788914643,
|
||||
"narHash": "sha256-4GuMPW90JSxXWDPUB9M+1m7fYbe3H0apOd86/zBQ2Kw=",
|
||||
"owner": "Mic92",
|
||||
"repo": "sops-nix",
|
||||
"rev": "a8627b21b9107c5711c96b84f32a9a4b3d45295f",
|
||||
"rev": "13616fff713a9f94055c66f15687ebdc17a335df",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
@@ -584,11 +584,11 @@
|
||||
]
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1786615403,
|
||||
"narHash": "sha256-U++y7nM/6xiEcWI7q4fQoPZjPvRaTwkSqzBOVoEBjUE=",
|
||||
"lastModified": 1788001239,
|
||||
"narHash": "sha256-AELmsXPI546MhbC/ZXC7WRUkCz7d4rqKTHUmliIgPpI=",
|
||||
"owner": "pyproject-nix",
|
||||
"repo": "uv2nix",
|
||||
"rev": "4b59abb2ae1896d2a0e1abfc47fbc9bf985ea730",
|
||||
"rev": "7f9c6b613d2e749e54854b1d60ab6a2192db889e",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
|
||||
@@ -111,8 +111,8 @@
|
||||
];
|
||||
};
|
||||
|
||||
# mars — on-site x86_64 box, single-purpose: Hermes Agent only.
|
||||
# See hosts/mars/*.
|
||||
# mars — on-site x86_64 box: Hermes Agent, plus the LAN web apps luna
|
||||
# hosts herself (hosts/mars/luna-sites.nix). See hosts/mars/*.
|
||||
mars = nixpkgs.lib.nixosSystem {
|
||||
inherit system;
|
||||
specialArgs = { inherit inputs; };
|
||||
@@ -420,7 +420,8 @@
|
||||
# After the jump the test driver's backdoor is gone with the old kernel,
|
||||
# so the installer is driven over a forwarded ssh port instead (the same
|
||||
# approach nixos-images uses in its own kexec test).
|
||||
checks.${system}.kexec-local =
|
||||
checks.${system} = {
|
||||
kexec-local =
|
||||
let
|
||||
pkgs = nixpkgs.legacyPackages.${system};
|
||||
tarball = self.nixosConfigurations.kexec.config.system.build.kexecInstallerTarball;
|
||||
@@ -553,6 +554,13 @@
|
||||
'';
|
||||
};
|
||||
|
||||
# VM test for hosts/mars/luna-sites.nix (header of luna-sites-test.nix):
|
||||
# nix build .#checks.x86_64-linux.luna-sites -L
|
||||
luna-sites = import ./hosts/mars/luna-sites-test.nix {
|
||||
pkgs = nixpkgs.legacyPackages.${system};
|
||||
};
|
||||
};
|
||||
|
||||
# `nix develop` — hot-reload loop for dotfiles/quickshell.
|
||||
#
|
||||
# hosts/terra/home.nix ships the shell via `xdg.configFile."quickshell"`,
|
||||
|
||||
@@ -1,13 +1,15 @@
|
||||
{ config, pkgs, ... }:
|
||||
|
||||
# mars — on-site x86_64 box, single-purpose: runs Hermes Agent only.
|
||||
# See hermes-agent.nix for what that is and why it moved here from jupiter.
|
||||
# mars — on-site x86_64 box for Hermes Agent (luna), plus the web apps she
|
||||
# hosts herself. See hermes-agent.nix for what Hermes is and why it moved here
|
||||
# from jupiter, and luna-sites.nix for the app hosting.
|
||||
{
|
||||
imports = [
|
||||
./hardware-configuration.nix
|
||||
./disk-config.nix # disko: OS-disk partitions + filesystems
|
||||
./secrets.nix # sops-nix: samba/tailscale/hermes secrets
|
||||
./hermes-agent.nix
|
||||
./luna-sites.nix # luna's LAN web apps: http://mars.sol/<name>/
|
||||
../../common.nix # shared base: user / ssh / nix / firewall
|
||||
../../services/containers.nix
|
||||
../../services/vpn/tailscale.nix
|
||||
|
||||
@@ -49,8 +49,8 @@
|
||||
# (no networking.firewall.allowedTCPPorts entry; tailscale0 is already a
|
||||
# trustedInterface, services/vpn/tailscale.nix). Public route: neptun's
|
||||
# hermes.mgaction.town vhost (hosts/neptun/configuration.nix) proxies to this
|
||||
# over the tailnet. mars runs no Caddy of its own (single-purpose box), so
|
||||
# there is no LAN vhost — reach the dashboard directly via mars's tailnet
|
||||
# over the tailnet. mars's own Caddy (luna-sites.nix) only serves luna's apps
|
||||
# and has no vhost for this — reach the dashboard directly via mars's tailnet
|
||||
# name (mars.orbit.sol:9119) or LAN IP:9119 for local debugging.
|
||||
#
|
||||
# Uses upstream's generic self-hosted OIDC plugin, same Authentik
|
||||
@@ -196,13 +196,31 @@ in
|
||||
# directly against the real instance during the first version of this
|
||||
# setup). Delete-then-add is idempotent either way and picks up a rotated
|
||||
# token for free.
|
||||
#
|
||||
# `tea logins add` is the ONLY step in here that touches the network, and
|
||||
# ordering is what makes it survivable. switch-to-configuration restarts
|
||||
# NetworkManager and starts this unit in the SAME pass: on 2026-09-11 the
|
||||
# two landed in the same second, tea's connect went out over an interface
|
||||
# that was still coming back, and the kernel spent 2m48s on SYN retries
|
||||
# before reporting "connection timed out". That failed this unit, which
|
||||
# podman-hermes-agent Requires=, so a five-second network blip took the
|
||||
# whole container down and returned 4 from the deploy. Hence
|
||||
# network-online.target below, the bounded reachability probe in the script,
|
||||
# and TimeoutStartSec as the backstop — no single blocking call in here may
|
||||
# outlive the deploy that started it.
|
||||
systemd.services.hermes-agent-prepare-dirs = {
|
||||
description = "Create Hermes state dirs + luna's git/tea access before the container starts";
|
||||
before = [ "podman-hermes-agent.service" ];
|
||||
wantedBy = [ "podman-hermes-agent.service" ];
|
||||
wants = [ "network-online.target" ];
|
||||
after = [ "network-online.target" ];
|
||||
unitConfig.RequiresMountsFor = [ "/mnt/jupiter" ];
|
||||
path = [ pkgs.git pkgs.tea ];
|
||||
path = [ pkgs.git pkgs.tea pkgs.curl pkgs.coreutils ];
|
||||
serviceConfig.Type = "oneshot";
|
||||
# Everything here is either local or bounded to ~30s by the probe loop, so
|
||||
# anything past two minutes is a hang, not slowness. Failing at that point
|
||||
# is strictly better than holding the deploy open.
|
||||
serviceConfig.TimeoutStartSec = "120";
|
||||
script = ''
|
||||
mkdir -p ${hermesHome}
|
||||
mkdir -p ${dropboxDir}
|
||||
@@ -231,9 +249,43 @@ in
|
||||
git config --global user.name "luna"
|
||||
git config --global user.email "luna@${giteaHost}"
|
||||
|
||||
# Probe before touching the login, with a hard per-attempt timeout: a
|
||||
# bare TCP connect to an interface that is still coming up hangs for
|
||||
# ~3 minutes on kernel SYN retries, and tea has no timeout flag of its
|
||||
# own. /api/v1/version is unauthenticated, so this says "is gitea
|
||||
# reachable", never "is the token good" — the token is the add's job.
|
||||
#
|
||||
# Probing FIRST (rather than retrying the add) is what protects the
|
||||
# login that is already there. delete-then-add is not atomic: an add
|
||||
# that fails because the network is down leaves luna with no login at
|
||||
# all, strictly worse than the stale-but-working one we started with.
|
||||
# Unreachable therefore means skip the refresh entirely and warn.
|
||||
gitea_up=0
|
||||
for attempt in 1 2 3; do
|
||||
if curl -fsS --max-time 5 -o /dev/null "https://${giteaHost}/api/v1/version"; then
|
||||
gitea_up=1
|
||||
break
|
||||
fi
|
||||
echo "${giteaHost} unreachable (attempt $attempt/3); retrying in 5s" >&2
|
||||
sleep 5
|
||||
done
|
||||
|
||||
if [ "$gitea_up" = 1 ]; then
|
||||
# Reachable but the add still fails == a real problem (revoked or
|
||||
# under-scoped token, gitea rejecting the login), and that stays
|
||||
# fatal: it is a config error, it will not fix itself on the next
|
||||
# boot, and it should be loud.
|
||||
tea logins delete luna 2>/dev/null || true
|
||||
GITEA_SERVER_TOKEN="$(cat "$token_file")" tea logins add \
|
||||
GITEA_SERVER_TOKEN="$(cat "$token_file")" timeout 60 tea logins add \
|
||||
--name luna --url "https://${giteaHost}" --no-version-check
|
||||
else
|
||||
# Deliberately not fatal. Every other thing this unit does is local,
|
||||
# and podman-hermes-agent Requires= it — failing here would take
|
||||
# Telegram and the dashboard down over a transient blip. luna keeps
|
||||
# git (the credential helper above needs no network to be written)
|
||||
# and loses only the tea CLI until the next start re-runs this.
|
||||
echo "WARNING: ${giteaHost} unreachable; left luna's tea login untouched." >&2
|
||||
fi
|
||||
|
||||
# Hand everything written above to the container's uid/gid. This does
|
||||
# NOT happen by itself: the image's cont-init only chowns hermesHome's
|
||||
|
||||
@@ -0,0 +1,94 @@
|
||||
# Hosting your web apps on mars
|
||||
|
||||
You can run web apps as containers and publish them on the home network at
|
||||
`http://mars.sol/<name>/`, without anyone changing mars's configuration.
|
||||
Everything below takes effect immediately — no restart, no redeploy.
|
||||
|
||||
This file is mounted read-only and is rewritten on every restart. Save what
|
||||
you need from it to your memory.
|
||||
|
||||
## How it fits together
|
||||
|
||||
- `podman` in your shell does not run containers next to you. It talks,
|
||||
through `$CONTAINER_HOST`, to a separate unprivileged account on mars
|
||||
(`luna-apps`). Containers there keep running when you restart, and come
|
||||
back after mars reboots if they were started with `--restart=always`.
|
||||
- Caddy on mars routes `http://mars.sol/<name>/` to the port you name in
|
||||
`/opt/data/sites/<name>.json`. A service on mars checks that file and
|
||||
writes the outcome to `/opt/data/sites-status.txt`.
|
||||
|
||||
## Publish an app
|
||||
|
||||
1. Put the source under `/opt/data/apps/<name>/` with a `Containerfile` (or
|
||||
`Dockerfile`), and build it. The directory is uploaded, so this works from
|
||||
where you are:
|
||||
|
||||
podman build -t localhost/<name> /opt/data/apps/<name>
|
||||
|
||||
2. Run it. Publish its port on `127.0.0.1` only, using a host port between
|
||||
@portMin@ and @portMax@ that no other app uses (`podman ps` shows the
|
||||
taken ones):
|
||||
|
||||
podman run -d --name <name> --restart=always \
|
||||
-p 127.0.0.1:20001:8080 localhost/<name>
|
||||
|
||||
3. Register it:
|
||||
|
||||
echo '{"port": 20001}' > /opt/data/sites/<name>.json
|
||||
|
||||
4. Check that it took, then fetch it:
|
||||
|
||||
cat /opt/data/sites-status.txt
|
||||
curl -si http://127.0.0.1/<name>/
|
||||
|
||||
It is now at `http://mars.sol/<name>/` for anyone on the home network.
|
||||
|
||||
## Rules the registry enforces
|
||||
|
||||
- `<name>` is lowercase letters, digits and `-`, starts with a letter or
|
||||
digit, at most 32 characters. The file is `/opt/data/sites/<name>.json`.
|
||||
- The file holds exactly one JSON object, and only `port` is read.
|
||||
- `port` is an integer from @portMin@ to @portMax@. Anything else is rejected
|
||||
(that includes everything else already running on mars).
|
||||
- A rejected entry never affects the others. `sites-status.txt` says why.
|
||||
- If `sites-status.txt` starts with `ERROR`, that is a fault on mars's side,
|
||||
not in your entry — tell darman.
|
||||
|
||||
## Writing apps that work under /<name>/
|
||||
|
||||
Caddy strips `/<name>` before the request reaches your app, so the app itself
|
||||
sees `/`, `/style.css`, `/api/items`. The browser, however, is at
|
||||
`http://mars.sol/<name>/`, so every link, asset URL and fetch() in the page must
|
||||
keep that prefix:
|
||||
|
||||
- Prefer relative URLs: `style.css`, `./api/items` — not `/style.css`.
|
||||
- Or set the framework's public base URL to `/<name>/` (e.g. Vite's `base`).
|
||||
Avoid settings that ALSO expect the prefix on incoming requests (Next.js
|
||||
`basePath`); the prefix has already been removed by then.
|
||||
- The original prefix arrives in the `X-Forwarded-Prefix` header.
|
||||
- `http://mars.sol/<name>` redirects to `http://mars.sol/<name>/`.
|
||||
|
||||
## Files and data
|
||||
|
||||
- `-v /opt/data/...:/somewhere` does not work: those paths exist only inside
|
||||
your container, and `luna-apps` cannot see your files. Copy code into the
|
||||
image in the `Containerfile`.
|
||||
- Keep an app's state in a named volume: `-v <name>-data:/data`.
|
||||
- Pulling public images works (`podman pull docker.io/library/nginx`).
|
||||
- Do not copy tokens or anything else from `/opt/data` into an app. The apps
|
||||
cannot read your files; keep it that way.
|
||||
|
||||
## Update, inspect, remove
|
||||
|
||||
- Update: rebuild, `podman rm -f <name>`, run it again on the same port. The
|
||||
JSON file stays as it is.
|
||||
- Inspect: `podman ps -a`, `podman logs <name>`, `cat /opt/data/sites-status.txt`.
|
||||
- Remove: `rm /opt/data/sites/<name>.json`, then `podman rm -f <name>`, and
|
||||
optionally `podman rmi localhost/<name>` and `podman volume rm <name>-data`.
|
||||
|
||||
## Limits
|
||||
|
||||
- Home network only: plain `http://`, not reachable from the internet, not on
|
||||
mgaction.town.
|
||||
- There is no login in front of these apps. Anyone on the home network can
|
||||
use them, so do not publish anything that would be a problem to expose there.
|
||||
@@ -0,0 +1,186 @@
|
||||
# VM test for luna-sites.nix. Run:
|
||||
# nix build .#checks.x86_64-linux.luna-sites -L
|
||||
#
|
||||
# mars has no VM target, and nearly everything luna-sites does only exists at
|
||||
# runtime: a rootless podman socket reached through a proxy from another
|
||||
# container's uid, a path unit, a caddy reload, linger + podman-restart after
|
||||
# a reboot. So this drives it the way luna does — every podman and registry
|
||||
# command runs inside a stand-in for the Hermes container, as uid 986 — and
|
||||
# checks that bad entries are refused without taking good ones down.
|
||||
{ pkgs }:
|
||||
let
|
||||
# `contents` is symlinked into the image root and its closure ships as
|
||||
# layers, so the app image is self-contained under luna-apps. The stand-in
|
||||
# is NOT: hermes-agent mounts the host's /nix/store over the image's own,
|
||||
# which is why the node adds busybox to the VM's store below.
|
||||
busyboxImage = { name, extraCommands ? "", cmd }: pkgs.dockerTools.buildLayeredImage {
|
||||
inherit name;
|
||||
tag = "latest";
|
||||
contents = [ pkgs.busybox ];
|
||||
extraCommands = "mkdir -p tmp && chmod 1777 tmp\n" + extraCommands;
|
||||
config.Cmd = cmd;
|
||||
};
|
||||
|
||||
# Stand-in for docker.io/nousresearch/hermes-agent: a shell and nothing else.
|
||||
# The podman client comes from the store, mounted by luna-sites.nix exactly
|
||||
# as on mars.
|
||||
standin = busyboxImage {
|
||||
name = "hermes-standin";
|
||||
cmd = [ "/bin/sleep" "infinity" ];
|
||||
};
|
||||
|
||||
# The "app" luna builds on top of. No network in the VM, so it is loaded
|
||||
# from the store instead of pulled. Runs under luna-apps, which has no
|
||||
# /nix/store mount — hence the closure inside the image.
|
||||
app = busyboxImage {
|
||||
name = "testapp";
|
||||
extraCommands = "mkdir -p www && echo hello > www/index.html";
|
||||
cmd = [ "/bin/httpd" "-f" "-p" "8080" "-h" "/www" ];
|
||||
};
|
||||
in
|
||||
pkgs.testers.runNixOSTest {
|
||||
name = "luna-sites";
|
||||
|
||||
nodes.mars = {
|
||||
imports = [ ./luna-sites.nix ];
|
||||
|
||||
virtualisation.memorySize = 2048;
|
||||
virtualisation.diskSize = 4096;
|
||||
environment.systemPackages = [ pkgs.curl ];
|
||||
# The stand-in's /bin symlinks point into /nix/store, and the /nix/store
|
||||
# mount below replaces the image's copy with the VM's, which only holds
|
||||
# the system closure. Without this: "executable file `/bin/sleep` not
|
||||
# found". (The real Hermes image is not nix-built, so mars never hits it.)
|
||||
system.extraDependencies = [ pkgs.busybox ];
|
||||
|
||||
# What hermes-agent.nix provides, minus Hermes itself: same uid/gid, host
|
||||
# networking, hermesHome at /opt/data, /nix/store read-only.
|
||||
users.groups.hermes.gid = 983;
|
||||
systemd.tmpfiles.rules = [
|
||||
"d /var/lib/hermes 0750 root hermes -"
|
||||
"d /var/lib/hermes/.hermes 0750 986 983 -"
|
||||
];
|
||||
virtualisation.oci-containers.containers.hermes-agent = {
|
||||
image = "hermes-standin:latest";
|
||||
imageFile = standin;
|
||||
extraOptions = [ "--network=host" "--user=986:983" ];
|
||||
volumes = [
|
||||
"/var/lib/hermes/.hermes:/opt/data"
|
||||
"/nix/store:/nix/store:ro"
|
||||
];
|
||||
environment = {
|
||||
HERMES_UID = "986";
|
||||
HERMES_GID = "983";
|
||||
HOME = "/opt/data";
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
testScript = /* python */ ''
|
||||
import shlex
|
||||
|
||||
status_file = "/var/lib/hermes/.hermes/sites-status.txt"
|
||||
|
||||
def luna(cmd):
|
||||
"""Run cmd the way luna would: inside her container, as uid 986."""
|
||||
return mars.succeed("podman exec hermes-agent sh -c " + shlex.quote(cmd))
|
||||
|
||||
def code(path):
|
||||
return mars.succeed(
|
||||
f"curl -s -o /dev/null -w '%{{http_code}}' http://127.0.0.1{path}"
|
||||
).strip()
|
||||
|
||||
def status_line(entry):
|
||||
lines = mars.succeed(f"cat {status_file}").splitlines()
|
||||
found = [l for l in lines if l.split(" ", 1)[0] == entry]
|
||||
assert len(found) == 1, f"no single status line for {entry}:\n" + "\n".join(lines)
|
||||
return found[0]
|
||||
|
||||
start_all()
|
||||
mars.wait_for_unit("caddy.service")
|
||||
mars.wait_for_unit("podman-hermes-agent.service")
|
||||
|
||||
with subtest("caddy starts with nothing registered"):
|
||||
# The import glob matches no file on a fresh box; caddy must still run.
|
||||
assert code("/") == "404"
|
||||
|
||||
with subtest("luna's podman is luna-apps's rootless podman"):
|
||||
assert luna("id -u").strip() == "986"
|
||||
assert luna("podman info --format '{{.Host.Security.Rootless}}'").strip() == "true"
|
||||
readme = luna("cat /opt/data/sites-README.md")
|
||||
assert "20000" in readme and "@port" not in readme, "README placeholders not substituted"
|
||||
|
||||
with subtest("build and run an app, as luna would"):
|
||||
luna("podman load -i ${app}")
|
||||
luna(
|
||||
"mkdir -p /opt/data/apps/notes && "
|
||||
"printf 'FROM localhost/testapp:latest\\nRUN echo built > /www/built.txt\\n' "
|
||||
"> /opt/data/apps/notes/Containerfile"
|
||||
)
|
||||
luna("podman build -t localhost/notes /opt/data/apps/notes")
|
||||
luna("podman run -d --name notes --restart=always -p 127.0.0.1:20001:8080 localhost/notes")
|
||||
mars.wait_until_succeeds("curl -sf http://127.0.0.1:20001/built.txt")
|
||||
# Container root maps to luna-apps on the host: not root, not uid 986.
|
||||
mars.succeed("pgrep -u luna-apps -f 'httpd -f -p 8080'")
|
||||
|
||||
with subtest("registering routes /notes/ to it"):
|
||||
luna("""echo '{"port": 20001}' > /opt/data/sites/notes.json""")
|
||||
mars.wait_until_succeeds("curl -sf http://127.0.0.1/notes/built.txt | grep -qx built")
|
||||
# httpd has no /www/notes/, so the 200 above also proves the prefix is stripped.
|
||||
assert " ok " in status_line("notes.json")
|
||||
out = mars.succeed(
|
||||
"curl -s -o /dev/null -w '%{http_code} %{redirect_url}' http://127.0.0.1/notes"
|
||||
)
|
||||
assert out.startswith("308 ") and out.endswith("/notes/"), out
|
||||
mars.succeed("stat -c %U:%a /var/lib/luna-sites/live/notes.caddy | grep -qx root:644")
|
||||
|
||||
with subtest("bad entries are rejected one by one"):
|
||||
luna("""echo '{"port": 9119}' > /opt/data/sites/dash.json""")
|
||||
luna("echo nope > /opt/data/sites/broken.json")
|
||||
luna(": > /opt/data/sites/empty.json")
|
||||
luna("""echo '{"port": 20002}{"port": 20003}' > /opt/data/sites/two.json""")
|
||||
luna("""echo '{"port": 20003.5}' > /opt/data/sites/frac.json""")
|
||||
luna("""echo '{"port": "20004"}' > /opt/data/sites/str.json""")
|
||||
luna("""echo '{"port": 20005}' > /opt/data/sites/Bad_Name.json""")
|
||||
luna("ln -s /etc/shadow /opt/data/sites/link.json")
|
||||
mars.wait_until_succeeds(f"grep -q '^link.json ' {status_file}")
|
||||
for entry, why in [
|
||||
("dash.json", "port 9119 is outside 20000-20999"),
|
||||
("broken.json", "not valid JSON"),
|
||||
("empty.json", "expected exactly one JSON object"),
|
||||
("two.json", "expected exactly one JSON object"),
|
||||
("frac.json", "port must be an integer"),
|
||||
("str.json", "port must be an integer"),
|
||||
("Bad_Name.json", "name must match"),
|
||||
("link.json", "not a regular file"),
|
||||
]:
|
||||
line = status_line(entry)
|
||||
assert " rejected " in line and why in line, line
|
||||
assert " ok " in status_line("notes.json")
|
||||
# A burst like the one above used to trip systemd's start limit, which
|
||||
# fails the path unit for good and silently ignores every later entry.
|
||||
mars.succeed("systemctl is-active luna-sites.path")
|
||||
assert code("/notes/built.txt") == "200"
|
||||
assert code("/dash/") == "404"
|
||||
mars.succeed("test \"$(ls /var/lib/luna-sites/live)\" = notes.caddy")
|
||||
# The status file is hers, and nothing root-written is left in her tree
|
||||
# (bar the README's mountpoint, which podman itself creates).
|
||||
mars.succeed(f"stat -c %u {status_file} | grep -qx 986")
|
||||
mars.fail("find /var/lib/hermes/.hermes -user root ! -name sites-README.md | grep .")
|
||||
|
||||
with subtest("removing the entry removes the route"):
|
||||
luna("rm /opt/data/sites/notes.json")
|
||||
mars.wait_until_succeeds("test \"$(curl -s -o /dev/null -w '%{http_code}' http://127.0.0.1/notes/built.txt)\" = 404")
|
||||
|
||||
with subtest("apps and routes come back after a reboot"):
|
||||
luna("""echo '{"port": 20001}' > /opt/data/sites/notes.json""")
|
||||
mars.wait_until_succeeds("curl -sf http://127.0.0.1/notes/built.txt")
|
||||
mars.shutdown()
|
||||
mars.start()
|
||||
mars.wait_for_unit("caddy.service")
|
||||
# Nobody logs in: linger starts luna-apps's manager, podman-restart the container.
|
||||
mars.wait_until_succeeds("curl -sf http://127.0.0.1/notes/built.txt | grep -qx built", timeout=180)
|
||||
mars.wait_for_unit("podman-hermes-agent.service")
|
||||
assert luna("podman ps --format '{{.Names}}'").split() == ["notes"]
|
||||
'';
|
||||
}
|
||||
@@ -0,0 +1,334 @@
|
||||
{ config, pkgs, ... }:
|
||||
|
||||
# luna-sites — luna (the Hermes agent, hermes-agent.nix) hosts her own web apps
|
||||
# on mars, LAN-only, at http://mars.sol/<name>/, with no nix edit per app.
|
||||
#
|
||||
# luna, inside hermes-agent (uid 986)
|
||||
# │ podman … → $CONTAINER_HOST = /run/luna-podman/podman.sock (luna-apps:hermes 0660)
|
||||
# ▼ systemd-socket-proxyd, running AS luna-apps
|
||||
# luna-apps's rootless podman (its linger'd user manager) — her app containers
|
||||
#
|
||||
# /opt/data/sites/<name>.json {"port": N} hermesHome/sites, hers to write
|
||||
# ▼ luna-sites.path → luna-sites.service (root): validate, caddy validate, reload
|
||||
# /var/lib/luna-sites/live/<name>.caddy root-owned, imported by caddy
|
||||
# /opt/data/sites-status.txt what was accepted, and why not
|
||||
#
|
||||
# Why a registry of {name, port} instead of letting her drop Caddyfile
|
||||
# snippets: a snippet can proxy to anything on this box (the dashboard on
|
||||
# 9119, the webhook listener on 8644, node-exporter) or file_server anything
|
||||
# caddy can read, and one syntax error keeps caddy from coming up on the next
|
||||
# boot. The generator only ever emits one fixed shape from a validated name
|
||||
# and a port inside portMin..portMax, so none of that is expressible.
|
||||
#
|
||||
# Why paths, not <name>.mars.sol: mars has no fixed DHCP lease, and a wildcard
|
||||
# needs one. `address=/…/` takes an IP, and pihole-FTL's dnsmasq skips
|
||||
# wildcard --cname entries outside authoritative zones (cache_reload():
|
||||
# `if (a->alias[1] != '*' …)`). Moving to subdomains later only changes the
|
||||
# fragment the generator writes; the registry format stays.
|
||||
#
|
||||
# Why a podman socket instead of ssh: what she needs is long-running processes
|
||||
# OUTSIDE her own container (anything started inside it dies with the
|
||||
# container, and sits next to her Telegram/gitea tokens). The socket gives
|
||||
# exactly that and no host shell. It is not a strong boundary on its own —
|
||||
# rootless podman socket access is code execution as luna-apps, which can read
|
||||
# whatever that user can — but luna-apps owns nothing and cannot enter
|
||||
# /var/lib/hermes (0750 root:hermes), so the apps cannot reach her tokens.
|
||||
#
|
||||
# She learns all this from a read-only README mounted at
|
||||
# /opt/data/sites-README.md (luna-sites-README.md). She self-manages her
|
||||
# memories, so nothing in this file reaches her otherwise — see the dropped
|
||||
# repo clone in hermes-agent.nix's header for what happens when it doesn't.
|
||||
#
|
||||
# VM test: nix build .#checks.x86_64-linux.luna-sites -L (luna-sites-test.nix)
|
||||
let
|
||||
user = "luna-apps";
|
||||
# Pinned so the user manager's socket path below is known at build time.
|
||||
uid = 1001;
|
||||
userSocket = "/run/user/${toString uid}/podman/podman.sock";
|
||||
|
||||
hermes = config.virtualisation.oci-containers.containers.hermes-agent;
|
||||
hermesUid = hermes.environment.HERMES_UID;
|
||||
hermesGid = hermes.environment.HERMES_GID;
|
||||
# hermes-agent.nix's hermesHome — the container sees it as /opt/data.
|
||||
hermesHome = "/var/lib/hermes/.hermes";
|
||||
sitesDir = "${hermesHome}/sites";
|
||||
statusFile = "${hermesHome}/sites-status.txt";
|
||||
|
||||
stateDir = "/var/lib/luna-sites";
|
||||
liveDir = "${stateDir}/live";
|
||||
socketDir = "/run/luna-podman";
|
||||
|
||||
portMin = 20000;
|
||||
portMax = 20999;
|
||||
|
||||
readme = pkgs.replaceVars ./luna-sites-README.md {
|
||||
portMin = toString portMin;
|
||||
portMax = toString portMax;
|
||||
};
|
||||
in
|
||||
{
|
||||
imports = [
|
||||
../../services/containers.nix
|
||||
../../services/network/caddy.nix
|
||||
];
|
||||
|
||||
# ---- luna-apps: the account her apps run as ----
|
||||
users.users.${user} = {
|
||||
isNormalUser = true;
|
||||
inherit uid;
|
||||
description = "luna's hosted web apps (rootless podman)";
|
||||
# Nothing ever logs in as this user. Only its systemd user manager runs,
|
||||
# kept up without a session by linger, which is what brings the podman
|
||||
# socket and podman-restart back after a reboot.
|
||||
linger = true;
|
||||
autoSubUidGidRange = true; # rootless podman's user namespace
|
||||
hashedPassword = "!";
|
||||
shell = "${pkgs.shadow}/bin/nologin";
|
||||
};
|
||||
|
||||
# `--restart=always` containers only come back after a reboot through this
|
||||
# unit — rootless podman has no daemon to remember them. The podman module
|
||||
# already enables podman.socket for every user's manager; this one is
|
||||
# scoped to luna-apps.
|
||||
systemd.user.services.podman-restart = {
|
||||
wantedBy = [ "default.target" ];
|
||||
unitConfig.ConditionUser = user;
|
||||
};
|
||||
|
||||
# ---- the socket luna's container talks to ----
|
||||
# luna-apps's own socket lives under /run/user/1001 (0700), which the
|
||||
# container's uid cannot enter. This re-exposes it to group hermes, and the
|
||||
# proxy behind it runs as luna-apps, so it holds no access beyond the socket
|
||||
# it forwards to.
|
||||
systemd.sockets.luna-apps-podman = {
|
||||
wantedBy = [ "sockets.target" ];
|
||||
listenStreams = [ "${socketDir}/podman.sock" ];
|
||||
socketConfig = {
|
||||
SocketUser = user;
|
||||
SocketGroup = "hermes";
|
||||
SocketMode = "0660";
|
||||
DirectoryMode = "0755";
|
||||
};
|
||||
};
|
||||
systemd.services.luna-apps-podman = {
|
||||
description = "Forward luna's podman socket to luna-apps's rootless podman";
|
||||
requires = [ "user@${toString uid}.service" ];
|
||||
after = [ "user@${toString uid}.service" ];
|
||||
serviceConfig = {
|
||||
User = user;
|
||||
ExecStart = "${config.systemd.package}/lib/systemd/systemd-socket-proxyd ${userSocket}";
|
||||
};
|
||||
};
|
||||
|
||||
# ---- luna's side ----
|
||||
# Merges into hermes-agent.nix's container definition.
|
||||
virtualisation.oci-containers.containers.hermes-agent = {
|
||||
volumes = [
|
||||
# The directory, not the socket file: the socket is created by systemd
|
||||
# at boot, and a file bind mount would pin whatever inode was there when
|
||||
# the container started. Read-only still permits connect().
|
||||
"${socketDir}:${socketDir}:ro"
|
||||
"${config.virtualisation.podman.package}/bin/podman:/usr/local/bin/podman:ro"
|
||||
"${readme}:/opt/data/sites-README.md:ro"
|
||||
];
|
||||
# Every podman command in there goes to luna-apps, never to the rootful
|
||||
# podman the container itself runs under.
|
||||
environment.CONTAINER_HOST = "unix://${socketDir}/podman.sock";
|
||||
};
|
||||
systemd.services.podman-hermes-agent = {
|
||||
wants = [ "luna-apps-podman.socket" ];
|
||||
after = [ "luna-apps-podman.socket" ];
|
||||
};
|
||||
|
||||
# ---- caddy ----
|
||||
# `:80` rather than http://mars.sol, so it answers whatever name the LAN
|
||||
# used to get here (mars, mars.sol, the IP). Until the generator's first run
|
||||
# the import glob matches nothing, which caddy only warns about.
|
||||
services.caddy.virtualHosts.":80".extraConfig = ''
|
||||
import ${liveDir}/*.caddy
|
||||
handle {
|
||||
respond "No app registered here. luna's apps live at /<name>/." 404
|
||||
}
|
||||
'';
|
||||
|
||||
# ---- registry → caddy ----
|
||||
# Fires on create/delete/rename/close-after-write of entries in sitesDir.
|
||||
# While sitesDir does not exist yet, systemd watches its parents instead.
|
||||
systemd.paths.luna-sites = {
|
||||
wantedBy = [ "multi-user.target" ];
|
||||
pathConfig.PathChanged = sitesDir;
|
||||
};
|
||||
|
||||
systemd.services.luna-sites = {
|
||||
description = "Turn luna's site registry into caddy routes";
|
||||
# Also runs once at boot, for edits made while nothing was watching.
|
||||
wantedBy = [ "multi-user.target" ];
|
||||
# After caddy, so the reload below never races caddy's own start. Nothing
|
||||
# orders caddy after THIS unit, which is what keeps the blocking
|
||||
# `systemctl reload caddy` from waiting on its own start job.
|
||||
after = [ "caddy.service" ];
|
||||
# No start rate limit. The default (5 starts in 10s) is hit by nothing
|
||||
# more than a handful of quick writes — the VM test does exactly that —
|
||||
# and when it is, systemd also fails luna-sites.path for good
|
||||
# (unit-start-limit-hit): every later registration is silently ignored
|
||||
# until someone runs reset-failed. Bursts are absorbed by the debounce at
|
||||
# the top of the script instead.
|
||||
startLimitIntervalSec = 0;
|
||||
path = [ pkgs.jq pkgs.util-linux pkgs.diffutils config.services.caddy.package ];
|
||||
# caddy validate wants somewhere to write its data/config dirs.
|
||||
environment = {
|
||||
HOME = "/tmp";
|
||||
XDG_DATA_HOME = "/tmp";
|
||||
XDG_CONFIG_HOME = "/tmp";
|
||||
};
|
||||
serviceConfig = {
|
||||
Type = "oneshot";
|
||||
StateDirectory = "luna-sites";
|
||||
StateDirectoryMode = "0755"; # caddy (User=caddy) reads live/
|
||||
ProtectSystem = "strict";
|
||||
ProtectHome = true;
|
||||
PrivateTmp = true;
|
||||
# "-": hermesHome does not exist on a box Hermes has never started on;
|
||||
# the script checks for that itself.
|
||||
ReadWritePaths = [ "-${hermesHome}" ];
|
||||
};
|
||||
script = ''
|
||||
set -euo pipefail
|
||||
|
||||
# Everything that touches luna's tree runs as the container's uid, never
|
||||
# as root: she controls every path under it, including swapping one for
|
||||
# a symlink into /etc between a check here and its use.
|
||||
as_luna() { setpriv --reuid=${hermesUid} --regid=${hermesGid} --clear-groups -- "$@"; }
|
||||
|
||||
if [ ! -d ${hermesHome} ]; then
|
||||
echo "${hermesHome} does not exist yet; nothing to do"
|
||||
exit 0
|
||||
fi
|
||||
# mkdir -p leaves an existing dir untouched, so this does not re-fire
|
||||
# the path unit on every run.
|
||||
as_luna mkdir -p ${sitesDir}
|
||||
rm -rf ${stateDir}/stage.*
|
||||
|
||||
report=$(mktemp)
|
||||
|
||||
reject() { printf '%-24s rejected %s\n' "$f" "$1" >> "$report"; }
|
||||
|
||||
# Written as her uid next to the target, then renamed into place, so
|
||||
# she never reads a half-written file.
|
||||
publish_report() {
|
||||
local tmp
|
||||
tmp=$(as_luna mktemp ${hermesHome}/.sites-status.XXXXXX)
|
||||
{
|
||||
printf '# luna-sites, %s. How this works: /opt/data/sites-README.md\n' "$(date -Is)"
|
||||
if [ -n "''${1:-}" ]; then printf '%s\n' "$1"; fi
|
||||
if [ -s "$report" ]; then cat "$report"; else echo "(no sites registered)"; fi
|
||||
} | as_luna tee "$tmp" >/dev/null
|
||||
as_luna mv -f "$tmp" ${statusFile}
|
||||
}
|
||||
|
||||
entries() {
|
||||
as_luna find ${sitesDir} -mindepth 1 -maxdepth 1 -name '*.json' -printf '%y %f %s %T@\n' | sort
|
||||
}
|
||||
|
||||
generate() {
|
||||
local stage entry type f name verdict port
|
||||
: > "$report"
|
||||
stage=$(mktemp -d ${stateDir}/stage.XXXXXX)
|
||||
chmod 0755 "$stage"
|
||||
|
||||
while IFS= read -r -d "" entry; do
|
||||
type=''${entry%% *}
|
||||
f=''${entry#* }
|
||||
name=''${f%.json}
|
||||
|
||||
if ! [[ $name =~ ^[a-z0-9][a-z0-9-]{0,31}$ ]]; then
|
||||
reject "name must match [a-z0-9][a-z0-9-]{0,31}"
|
||||
continue
|
||||
fi
|
||||
# Refused rather than followed. The read below happens as her uid
|
||||
# either way, so this is about clear feedback, not safety.
|
||||
if [ "$type" != f ]; then
|
||||
reject "not a regular file"
|
||||
continue
|
||||
fi
|
||||
|
||||
verdict=$(as_luna head -c 4096 -- ${sitesDir}/"$f" | jq -rs \
|
||||
--argjson min ${toString portMin} --argjson max ${toString portMax} '
|
||||
if length != 1 or (.[0] | type) != "object" then "expected exactly one JSON object"
|
||||
else .[0].port as $p
|
||||
| if ($p | type) != "number" or $p != ($p | floor) then "port must be an integer"
|
||||
elif $p < $min or $p > $max then "port \($p) is outside \($min)-\($max)"
|
||||
else "ok \($p | floor)" end
|
||||
end
|
||||
' 2>/dev/null) || verdict="not valid JSON"
|
||||
|
||||
case $verdict in
|
||||
"ok "*) port=''${verdict#ok } ;;
|
||||
*) reject "$verdict"; continue ;;
|
||||
esac
|
||||
if ! [[ $port =~ ^[0-9]+$ ]]; then
|
||||
reject "port must be an integer"
|
||||
continue
|
||||
fi
|
||||
|
||||
# The only shape that is ever generated. Stripping the prefix means
|
||||
# the app sees `/`; X-Forwarded-Prefix tells it where it really is.
|
||||
{
|
||||
printf '# %s\n' "${sitesDir}/$f"
|
||||
printf 'redir /%s /%s/ 308\n' "$name" "$name"
|
||||
printf 'handle_path /%s/* {\n' "$name"
|
||||
printf '\treverse_proxy 127.0.0.1:%s {\n' "$port"
|
||||
printf '\t\theader_up X-Forwarded-Prefix /%s\n' "$name"
|
||||
printf '\t}\n}\n'
|
||||
} > "$stage/$name.caddy"
|
||||
printf '%-24s ok http://mars.sol/%s/ -> 127.0.0.1:%s\n' "$f" "$name" "$port" >> "$report"
|
||||
done < <(as_luna find ${sitesDir} -mindepth 1 -maxdepth 1 -name '*.json' -printf '%y %f\0' | sort -z)
|
||||
|
||||
# Nothing she controls reaches these files except a validated name and
|
||||
# an integer, so a failure here is a bug in this unit, not her entry.
|
||||
printf ':80 {\n\timport %s/*.caddy\n}\n' "$stage" > "$stage.Caddyfile"
|
||||
if ! caddy validate --adapter caddyfile --config "$stage.Caddyfile"; then
|
||||
rm -rf "$stage" "$stage.Caddyfile"
|
||||
publish_report "ERROR: the generated routes failed caddy validate, so nothing changed. This is a bug in luna-sites, not in your entries - tell darman (journalctl -u luna-sites)."
|
||||
exit 1
|
||||
fi
|
||||
rm -f "$stage.Caddyfile"
|
||||
|
||||
if [ -d ${liveDir} ] && diff -r ${liveDir} "$stage" >/dev/null; then
|
||||
rm -rf "$stage"
|
||||
else
|
||||
rm -rf ${stateDir}/previous
|
||||
if [ -d ${liveDir} ]; then mv ${liveDir} ${stateDir}/previous; fi
|
||||
mv "$stage" ${liveDir}
|
||||
# caddy's reload is all-or-nothing: on failure it keeps serving the
|
||||
# old routes, so put the old files back to match what is live.
|
||||
if systemctl is-active --quiet caddy.service && ! systemctl reload caddy.service; then
|
||||
rm -rf ${liveDir}
|
||||
if [ -d ${stateDir}/previous ]; then mv ${stateDir}/previous ${liveDir}; fi
|
||||
publish_report "ERROR: caddy refused the new routes, so the previous ones are still live. This is a bug in luna-sites, not in your entries - tell darman (journalctl -u luna-sites)."
|
||||
exit 1
|
||||
fi
|
||||
rm -rf ${stateDir}/previous
|
||||
fi
|
||||
publish_report
|
||||
}
|
||||
|
||||
# Debounce: writes usually come in bursts (several files, or an editor's
|
||||
# write-then-rename), and every trigger that lands while this oneshot
|
||||
# is still activating merges into this same start job instead of
|
||||
# queuing another. One second collapses a burst into one run.
|
||||
sleep 1
|
||||
|
||||
# That merging also means an entry written mid-run would otherwise wait
|
||||
# for the next unrelated change. Compare the registry before and after,
|
||||
# and go again. Bounded, so a writer in a loop cannot pin the unit.
|
||||
for attempt in 1 2 3 4 5; do
|
||||
before=$(entries)
|
||||
generate
|
||||
if [ "$before" = "$(entries)" ]; then exit 0; fi
|
||||
echo "registry changed during run $attempt; regenerating"
|
||||
done
|
||||
echo "registry still changing after 5 runs; leaving the rest to the next trigger" >&2
|
||||
'';
|
||||
};
|
||||
}
|
||||
@@ -43,6 +43,51 @@ in
|
||||
# https://nix.dev/permalink/stub-ld ----
|
||||
programs.nix-ld.enable = true;
|
||||
|
||||
# The default set above is deliberately minimal and carries no X11,
|
||||
# freetype, wayland or xkbcommon, so a prebuilt *graphical* binary dies
|
||||
# before it draws anything. JetBrains IDEs installed through Toolbox are the
|
||||
# case that surfaced this: their bundled JBR aborts with `libX11.so.6:
|
||||
# cannot open shared object file` unless the Toolbox GUI — itself an FHS
|
||||
# wrapper — is what launches them, which makes them unusable from a terminal
|
||||
# or from a per-repo devShell. These are the libraries `ldd` reports missing
|
||||
# across a JBR's own .so files, plus the three it resolves by dlopen rather
|
||||
# than DT_NEEDED: fontconfig for font discovery, libGL, and libsecret for
|
||||
# the credential store. Definitions merge, so this adds to the module's base
|
||||
# list rather than replacing it (zlib is already there).
|
||||
programs.nix-ld.libraries = with pkgs; [
|
||||
freetype
|
||||
fontconfig
|
||||
libGL
|
||||
libxkbcommon
|
||||
wayland
|
||||
libsecret
|
||||
libx11
|
||||
libxext
|
||||
libxi
|
||||
libxrender
|
||||
libxtst
|
||||
libxcursor
|
||||
libxrandr
|
||||
libxinerama
|
||||
libxcb
|
||||
|
||||
# CLion Nova's C++ backend (the clion-radler plugin) is a .NET 10
|
||||
# application bundling its own runtime, and .NET refuses to start
|
||||
# without ICU: libSystem.Globalization.Native.so dlopens libicuuc.so
|
||||
# and libicui18n.so, and failing that the IDE reports "Couldn't find a
|
||||
# valid ICU package installed on the system" and comes up degraded.
|
||||
icu
|
||||
];
|
||||
|
||||
# ---- envfs: serves /bin and /usr/bin from the calling process's PATH ----
|
||||
# NixOS ships only /bin/sh, but plenty of third-party tooling writes scripts
|
||||
# with a hardcoded interpreter. JetBrains Toolbox is the standing example:
|
||||
# it generates ~/.local/share/JetBrains/Toolbox/scripts/{clion,rider,...}
|
||||
# with `#!/bin/bash`, so every one of those shims fails with `bad
|
||||
# interpreter` in any shell. envfs resolves such shebangs against PATH,
|
||||
# which fixes them all at once instead of per-IDE wrappers.
|
||||
services.envfs.enable = true;
|
||||
|
||||
# ---- home-manager (user-level config for darman) ----
|
||||
# Base settings (useGlobalPkgs/useUserPackages/backupFileExtension) and the
|
||||
# shared zsh baseline now live in common.nix + home/common.nix, applied to
|
||||
@@ -96,7 +141,15 @@ in
|
||||
# in VRAM alone, so ollama offloads the inactive experts to CPU RAM.
|
||||
# Sparse activation makes that far less painful than it'd be for a dense
|
||||
# model this size, but still expect it to run slower than the two above.
|
||||
loadModels = [ "gemma4:12b" "qwen3.6:35b-a3b" ];
|
||||
# VladimirGav/qwen3.8-27B-14GB-IQ4: dense 27B at IQ4, ~14GB of weights —
|
||||
# nominally fits the 6800 XT's 16G, but that leaves only ~2G for the KV
|
||||
# cache and the compositor, so expect partial CPU offload as context grows
|
||||
# (OLLAMA_CONTEXT_LENGTH below applies to every model on this server).
|
||||
loadModels = [
|
||||
"gemma4:12b"
|
||||
"qwen3.6:35b-a3b"
|
||||
"VladimirGav/qwen3.8-27B-14GB-IQ4"
|
||||
];
|
||||
# Ollama truncates context far below the model's real window unless
|
||||
# told otherwise (the OpenAI-compat /v1 route it's reached through has
|
||||
# no way to set this per-request). 131072 chosen as the practical
|
||||
|
||||
+55
-1
@@ -1,6 +1,53 @@
|
||||
{ pkgs, unstable, inputs, ... }:
|
||||
let
|
||||
tome = pkgs.callPackage ../../pkgs/tome.nix { src = inputs.tome; };
|
||||
|
||||
# SUDO_ASKPASS helper: renders sudo's password prompt in the quickshell
|
||||
# shell (HyprChrome/Widgets/Askpass) instead of on the terminal.
|
||||
#
|
||||
# sudo does NOT speak polkit — it is setuid + PAM reading the tty, and no
|
||||
# sudoers option bridges the two — so this is the askpass mechanism, a
|
||||
# separate path that happens to reuse the polkit dialog's look. `run0` is the
|
||||
# polkit-native alternative if you want the agent itself.
|
||||
#
|
||||
# A package rather than a file in dotfiles/quickshell because SUDO_ASKPASS
|
||||
# must point at something EXECUTABLE, and xdg.configFile copies keep their
|
||||
# store mode — which is why open_launcher.sh has to be invoked as
|
||||
# `bash <path>` rather than run directly.
|
||||
#
|
||||
# The secret comes back over a 0600 fifo, never in argv or the environment,
|
||||
# so it is not visible in /proc to anything. Cancelling closes the fifo
|
||||
# without writing: `cat` reads nothing, this exits non-zero, and sudo aborts
|
||||
# instead of burning a retry on an empty password.
|
||||
qs-askpass = pkgs.writeShellApplication {
|
||||
name = "qs-askpass";
|
||||
runtimeInputs = [ pkgs.quickshell pkgs.coreutils ];
|
||||
text = ''
|
||||
runtime="''${XDG_RUNTIME_DIR:-/run/user/$(id -u)}"
|
||||
fifo="$(mktemp -u "$runtime/qs-askpass.XXXXXXXX")"
|
||||
mkfifo -m 600 "$fifo"
|
||||
trap 'rm -f "$fifo"' EXIT
|
||||
|
||||
# Returns immediately; the dialog is asynchronous and we block on the
|
||||
# fifo, not on the IPC call.
|
||||
if ! qs ipc call askpass prompt "''${1:-Password:}" "$fifo" >/dev/null 2>&1; then
|
||||
echo "qs-askpass: quickshell is not running or has no askpass handler" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Bounded, so a prompt nobody answers fails instead of wedging sudo for
|
||||
# good. On timeout take the dialog down too, or it would sit there with
|
||||
# nothing listening.
|
||||
if ! secret="$(timeout 120 cat "$fifo")"; then
|
||||
qs ipc call askpass cancel >/dev/null 2>&1 || true
|
||||
echo "qs-askpass: timed out waiting for the prompt" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
[ -n "$secret" ] || exit 1
|
||||
printf '%s\n' "$secret"
|
||||
'';
|
||||
};
|
||||
in
|
||||
{
|
||||
# home.stateVersion, programs.home-manager.enable, programs.zsh.enable all
|
||||
@@ -34,6 +81,12 @@ in
|
||||
# it instead of the root /var/run/docker.sock.
|
||||
home.sessionVariables.DOCKER_HOST = "unix:///run/user/1000/podman/podman.sock";
|
||||
|
||||
# Only sets WHICH helper sudo uses; it still only calls it when asked with
|
||||
# `sudo -A` (or when there is no tty at all). Plain `sudo` keeps prompting on
|
||||
# the terminal, deliberately: aliasing it wholesale would break every sudo in
|
||||
# a TTY or over ssh, where there is no shell to draw the dialog.
|
||||
home.sessionVariables.SUDO_ASKPASS = "${qs-askpass}/bin/qs-askpass";
|
||||
|
||||
xdg.userDirs = {
|
||||
enable = true;
|
||||
};
|
||||
@@ -46,13 +99,14 @@ in
|
||||
(pkgs.writeTextDir "share/mime/packages/application-x-ms-sln.xml"
|
||||
(builtins.readFile ../../dotfiles/mime/application-x-ms-sln.xml))
|
||||
unstable.claude-code
|
||||
unstable.codex
|
||||
pkgs.opencode
|
||||
pkgs.quickshell
|
||||
qs-askpass
|
||||
pkgs.github-cli
|
||||
pkgs.tea
|
||||
pkgs.docker-compose
|
||||
pkgs.hyprcursor
|
||||
pkgs.bibata-cursors
|
||||
pkgs.papirus-icon-theme
|
||||
];
|
||||
|
||||
|
||||
@@ -31,12 +31,19 @@
|
||||
let
|
||||
lua = lib.generators.mkLuaInline;
|
||||
|
||||
# Cursor theme+size live in home.pointerCursor (theme.nix) so the name is
|
||||
# in one place; hyprland.lua is what actually gets them into the graphical
|
||||
# session's environment (hm-session-vars.sh is only sourced by login shells).
|
||||
cursorName = config.home.pointerCursor.name;
|
||||
cursorSize = toString config.home.pointerCursor.size;
|
||||
|
||||
# Wallpaper images aren't checked into this repo (binary blobs) — pulled
|
||||
# from the existing Wallhaven library on /mnt/hdd_01 instead. Picked once
|
||||
# here rather than at runtime, since hyprpaper has no built-in "random"
|
||||
# mode; re-pick and rebuild (or swap in real per-monitor selection) when
|
||||
# this stops being a placeholder.
|
||||
wallpaper = "/mnt/hdd_01/data/Pictures/Wallhaven/wallhaven-ym81rl.png";
|
||||
# wallpaper = "/mnt/hdd_01/data/Pictures/Wallhaven/wallhaven-ym81rl.png";
|
||||
wallpaper = "/mnt/hdd_01/data/Pictures/Wallhaven/wallhaven-mlwz78.png";
|
||||
|
||||
# Dispatchers → the new hl.dsp.* API (signatures verified against hyprland
|
||||
# 0.55's src/config/lua/bindings/LuaBindingsDispatchers.cpp).
|
||||
@@ -94,7 +101,7 @@ in
|
||||
settings = {
|
||||
# ---- colours (from colors.conf) ----
|
||||
fg_color = { _var = "rgba(eeeeeeff)"; };
|
||||
fg_accent = { _var = "rgba(ffd063ff)"; };
|
||||
fg_accent = { _var = "rgba(e8722aff)"; };
|
||||
fg_accent_alt = { _var = "rgba(ff9d42ff)"; };
|
||||
bg_color = { _var = "rgba(0f1012ff)"; };
|
||||
bg_accent = { _var = "rgba(963c38ff)"; };
|
||||
@@ -117,7 +124,7 @@ in
|
||||
debug.disable_logs = false;
|
||||
|
||||
general = {
|
||||
border_size = 0;
|
||||
border_size = 2;
|
||||
col = {
|
||||
inactive_border = lua "bg_accent";
|
||||
active_border = {
|
||||
@@ -182,10 +189,10 @@ in
|
||||
|
||||
# ---- environment (environment.conf) ----
|
||||
env = [
|
||||
{ _args = [ "HYPRCURSOR_THEME" "Bibata-Modern-Classic" ]; }
|
||||
{ _args = [ "HYPRCURSOR_SIZE" "24" ]; }
|
||||
{ _args = [ "XCURSOR_THEME" "Bibata-Modern-Classic" ]; }
|
||||
{ _args = [ "XCURSOR_SIZE" "24" ]; }
|
||||
{ _args = [ "HYPRCURSOR_THEME" cursorName ]; }
|
||||
{ _args = [ "HYPRCURSOR_SIZE" cursorSize ]; }
|
||||
{ _args = [ "XCURSOR_THEME" cursorName ]; }
|
||||
{ _args = [ "XCURSOR_SIZE" cursorSize ]; }
|
||||
{ _args = [ "GDK_BACKEND" "wayland,x11" ]; }
|
||||
{ _args = [ "SDL_VIDEODRIVER" "wayland" ]; }
|
||||
{ _args = [ "CLUTTER_BACKEND" "wayland" ]; }
|
||||
@@ -310,7 +317,11 @@ in
|
||||
"hyprland.start"
|
||||
(lua ''
|
||||
function()
|
||||
hl.exec_cmd("systemctl --user start hyprpolkitagent")
|
||||
-- No polkit agent is started here: quickshell registers one
|
||||
-- itself (HyprChrome/Widgets/Polkit), and a session admits only
|
||||
-- one. The hyprpolkitagent line this replaces had been dead for
|
||||
-- a while anyway — the unit was never installed, so the start
|
||||
-- failed silently and the session ran with no agent at all.
|
||||
hl.exec_cmd("cosmic-settings-daemon")
|
||||
hl.exec_cmd("quickshell")
|
||||
hl.exec_cmd("alacritty", { workspace = "special:terminal silent" })
|
||||
|
||||
@@ -23,6 +23,22 @@ in
|
||||
};
|
||||
};
|
||||
|
||||
# The cursor theme. XCURSOR_THEME alone is not enough for Steam: the client
|
||||
# UI (steamwebhelper) runs inside a pressure-vessel container that rebuilds
|
||||
# /etc, so the /etc/profiles/per-user/darman/share/icons entry of
|
||||
# XCURSOR_PATH does not exist in there and libXcursor finds no theme by
|
||||
# that name — it falls back to the built-in core X11 cursor. $HOME and
|
||||
# /nix are bind-mounted into the container, so the ~/.icons symlink that
|
||||
# `dotIcons` (on by default) drops does resolve. Same class of problem as
|
||||
# the ~/.themes/~/.icons flatpak workaround above.
|
||||
home.pointerCursor = {
|
||||
name = "Bibata-Modern-Classic";
|
||||
package = pkgs.bibata-cursors;
|
||||
size = 24;
|
||||
gtk.enable = true;
|
||||
hyprcursor.enable = true;
|
||||
};
|
||||
|
||||
# Flatpak apps are sandboxed and can't see XDG_DATA_DIRS/nix-store theme
|
||||
# paths, so the portal-reported GTK theme / icon theme names resolve to
|
||||
# nothing inside the sandbox and they fall back to Adwaita. Flatpak
|
||||
|
||||
@@ -36,7 +36,7 @@
|
||||
# at runtime with whatever's pulled (see loadModels in
|
||||
# hosts/terra/configuration.nix) — kept roughly in sync anyway
|
||||
# so the UI has sane names before the first fetch completes.
|
||||
default = [ "gemma4:12b" "qwen3.6:35b-a3b" ];
|
||||
default = [ "gemma4:12b" "qwen3.6:35b-a3b" "VladimirGav/qwen3.8-27B-14GB-IQ4:latest" ];
|
||||
fetch = true; # pull the model list from ollama at startup
|
||||
};
|
||||
titleConvo = true;
|
||||
|
||||
Reference in New Issue
Block a user