Watch
1
0
Fork
You've already forked souveraine
0

sessiond: double-tap-to-wake wakes, and the volume keys work again

Two things that worked under Hyprland and stopped when viewtop took the
session, both for the same reason: the binding lived in hyprland.lua and
the daemon was never in the path.

dt2w: note_input recorded the wake and returned Restore, which is
brightness. So a double tap reported to the machine and the screen stayed
dark. It now returns Unblank first — the brightness a panel comes back at
means nothing until the panel is back. Only for the deliberate wakes
(DoubleTapToWake, Squeeze) and only when the panel is actually dark. The
power button is excluded on purpose: apply_gesture already wakes on its
resolved tap, and emitting a second unblank here is precisely how the
wake loop happened in the compositor this afternoon.

Volume: Action::Volume through the executor table, per §12 — a small
daemon reading a signal and calling wpctl is the eighth blind actor. It
fires on the DOWN edge rather than from a recognised gesture, because
BUTTON_MULTI_TAP_WINDOW is 300ms and a volume key that lags a third of a
second behind the press feels broken. The recogniser still sees the
edges, so a future binding table gets volume hold-to-ramp without this
changing.

Shell: HyprlandData did a bare JSON.parse on hyprctl output, which throws
on every refresh when there is no hyprctl — six exceptions a pass, and
every consumer of monitorData.scale got undefined. That is why the region
selector rendered as a sliver: the geometry was not wrong, it was NaN.
Absence is now a latched state, and RegionSelection/OverviewWidget fall
back to screen.devicePixelRatio. Hyprland stays preferred where it exists.

105 tests.
This commit is contained in:
Fimeg 2026-08-02 18:28:49 -04:00
commit 266af98a99
6 changed files with 282 additions and 54 deletions

View file

@ -336,6 +336,24 @@ pub enum Action {
Restore,
/// Blank the panel through the DPMS executor.
Blank,
/// One step of output volume, up or down.
///
/// Under Hyprland these were `wpctl` calls bound to `XF86AudioRaiseVolume`
/// / `LowerVolume` in `hyprland.lua`, with key repeat. viewtop consumes
/// the volume keys as device buttons — they must not be interceptable by a
/// fullscreen client any more than the power button is — so the binding
/// had to come somewhere, and §12 is explicit that the somewhere is an
/// `Action` through this table rather than a small daemon that reads a
/// signal and calls a tool. A second writer to the sink is the eighth
/// blind actor.
///
/// Emitted on the **down edge**, not from a recognised gesture:
/// `BUTTON_MULTI_TAP_WINDOW` is 300 ms, so a tap-driven volume key would
/// lag a third of a second behind the press and feel broken. Volume is one
/// of the two controls whose whole quality is immediacy.
Volume {
up: bool,
},
/// Light the panel through the same executor.
///
/// The machine could turn the screen off and had no way to turn it back
@ -1503,6 +1521,23 @@ impl DeviceStateMachine {
ButtonEdge::Up => rec.up(now),
};
let mut actions = Vec::new();
// Volume acts on the press, not on a recognised gesture. See
// `Action::Volume`: the multi-tap window would otherwise put 300 ms
// between the press and the sound changing.
//
// The gesture recogniser still sees these edges and still resolves
// taps and holds from them — that is how a future binding table gets
// volume double-tap or hold-to-ramp without this changing. It simply
// is not what produces the step today.
if edge == ButtonEdge::Down
&& matches!(button, Button::VolumeUp | Button::VolumeDown)
{
actions.push(Action::Volume {
up: button == Button::VolumeUp,
});
}
if edge == ButtonEdge::Down {
// A hardware button is intent — §4's table says of the power button
// "can it lie? no — hardware signal" — so it is never subject to the
@ -2120,6 +2155,44 @@ impl DeviceStateMachine {
InputTrigger::Unknown => WakeTrigger::Unknown,
};
self.record_wake(wake, &format!("input: {:?}", trigger));
// A deliberate wake on a dark panel has to actually light it.
//
// This function recorded the wake and returned `Restore` — which is
// *brightness* — so double-tap-to-wake reported to the machine and the
// screen stayed off. It was invisible for as long as the wake never
// came through the daemon: `hyprland.lua` bound `XF86WakeUp` straight
// to `blueline-screen-toggle on`, so the compositor lit the panel and
// sessiond only heard about it afterwards. viewtop consumes that key,
// and dt2w stopped working.
//
// Only the *deliberate* wakes, and only when the panel is actually
// dark. `Touch`/`Key`/`Unknown` are excluded because they are not wake
// gestures — the touch controller is in gesture mode while the panel is
// off, so a raw touch arriving there is not a request to wake.
//
// `PowerButton` is excluded for a different reason: it already has a
// wake, from `apply_gesture` resolving the tap. Emitting one here too
// would put two unblanks in flight for one press, and the second would
// land against a panel the first had already lit — which is how the
// wake loop happened in the compositor earlier today.
//
// Proximity has already had its say: this is reached through
// `note_input_gated`, whose veto is the pocket check. A power button is
// never vetoed and a double tap always is, because a pocket can produce
// the second and not the first (§4).
if !self.panel_on
&& matches!(
trigger,
InputTrigger::DoubleTapToWake | InputTrigger::Squeeze
)
{
info!("[device-state] {:?} on a dark panel — waking", trigger);
self.blank_requested = false;
// Before any `Restore`: the brightness a panel comes back at means
// nothing until the panel is back.
actions.insert(0, Action::Unblank);
}
actions
}
@ -2869,6 +2942,72 @@ mod tests {
assert!(!sm.blank_requested, "the panel must not be dark yet");
}
#[test]
fn double_tap_to_wake_actually_wakes_the_panel() {
// The regression that made viewtop feel worse than Hyprland. This
// function recorded the wake and returned `Restore`, which is
// brightness — so dt2w reported to the machine and the screen stayed
// dark. It only ever worked because hyprland.lua bound XF86WakeUp
// straight to the DPMS toggle and the daemon was never consulted.
let (mut sm, _t0) = unlocked_and_lit();
sm.set_panel(false);
let actions = sm.note_input(InputTrigger::DoubleTapToWake);
assert!(
actions.contains(&Action::Unblank),
"a double tap on a dark panel must light it: {actions:?}"
);
}
#[test]
fn a_wake_on_a_lit_panel_does_not_unblank_it() {
let (mut sm, _t0) = unlocked_and_lit();
assert!(sm.panel_on());
let actions = sm.note_input(InputTrigger::DoubleTapToWake);
assert!(!actions.contains(&Action::Unblank));
}
#[test]
fn the_power_button_does_not_unblank_twice() {
// `apply_gesture` already wakes on a resolved tap. If `note_input`
// also woke on the down edge there would be two unblanks in flight for
// one press, and the second would land against a panel the first had
// lit — which is exactly how the wake loop happened in the compositor.
let (mut sm, _t0) = unlocked_and_lit();
sm.set_panel(false);
let actions = sm.note_input(InputTrigger::PowerButton);
assert!(
!actions.contains(&Action::Unblank),
"the power button's wake belongs to apply_gesture: {actions:?}"
);
}
#[test]
fn a_volume_press_changes_volume_immediately() {
// On the DOWN edge, not on a resolved gesture: BUTTON_MULTI_TAP_WINDOW
// is 300ms and a volume key that lags a third of a second behind the
// press feels broken.
let (mut sm, t0) = unlocked_and_lit();
let up = sm.button_edge_at(Button::VolumeUp, ButtonEdge::Down, t0);
assert!(up.contains(&Action::Volume { up: true }), "{up:?}");
let down = sm.button_edge_at(Button::VolumeDown, ButtonEdge::Down, t0);
assert!(down.contains(&Action::Volume { up: false }), "{down:?}");
}
#[test]
fn releasing_a_volume_key_does_not_change_volume_again() {
let (mut sm, t0) = unlocked_and_lit();
sm.button_edge_at(Button::VolumeUp, ButtonEdge::Down, t0);
let up = sm.button_edge_at(
Button::VolumeUp,
ButtonEdge::Up,
t0 + Duration::from_millis(60),
);
assert!(
!up.iter().any(|a| matches!(a, Action::Volume { .. })),
"one press is one step: {up:?}"
);
}
#[test]
fn the_screen_verb_wakes_a_dark_panel() {
// The direction the machine did not have. Before `Action::Unblank`

View file

@ -357,6 +357,21 @@ fn execute(shared: &Arc<Shared>, action: Action) {
// signal", which is why the one wake a pocket can produce by itself
// (tap-to-wake) is gated at the toggle and this is not.
Action::Unblank => (DPMS_EXECUTOR, vec!["on"], "panel-on"),
// One step of output volume. `wpctl` is the same call `hyprland.lua`
// made; what changed is that the machine makes it, so the volume keys
// are not a keybinding a compositor swap can delete — which is exactly
// how they stopped working. `-l 1` caps at 100% on the way up; the
// down direction needs no cap.
Action::Volume { up: true } => (
"wpctl",
vec!["set-volume", "-l", "1", "@DEFAULT_AUDIO_SINK@", "5%+"],
"volume-up",
),
Action::Volume { up: false } => (
"wpctl",
vec!["set-volume", "@DEFAULT_AUDIO_SINK@", "5%-"],
"volume-down",
),
Action::Blank => {
// The invariant, enforced where it cannot be reasoned around: the
// panel does not go dark unless logind says this session is

View file

@ -38,7 +38,8 @@ Item {
property real smallWorkspaceRadius: Appearance.rounding.verysmall
property real workspaceNumberMargin: 80
property real workspaceNumberSize: 250 * monitor.scale
property real monitorScale: (monitor?.scale ?? 0) > 0 ? monitor.scale : (screen?.devicePixelRatio ?? 1)
property real workspaceNumberSize: 250 * monitorScale
property int workspaceZ: 0
property int windowZ: 1
property int windowDraggingZ: 99999

View file

@ -77,11 +77,27 @@ PanelWindow {
readonly property real falsePositivePreventionRatio: 0.5
// Screen & interaction vars
// Monitor geometry, from Wayland when Hyprland is not the compositor.
//
// `Hyprland.monitorFor()` returns null under viewtop — there is no
// Hyprland IPC to ask — so `monitorScale` was `undefined` and every region
// below multiplies by it. `undefined * n` is NaN, which is why the
// selector rendered as a sliver of pixels rather than a rectangle:
// the geometry was not wrong, it was not a number.
//
// `screen` is quickshell's own `ShellScreen` and is always there, on any
// compositor. Hyprland stays the preferred source where it exists (the
// laptop), because it also carries workspace and multi-monitor offsets
// that Wayland does not hand a client — but it is no longer the only one.
// SHELL-SURFACES.md's rule: a feature defined against a substrate dies
// with that substrate; one defined against a contract survives.
readonly property HyprlandMonitor hyprlandMonitor: Hyprland.monitorFor(screen)
readonly property real monitorScale: hyprlandMonitor.scale
readonly property real monitorOffsetX: hyprlandMonitor.x
readonly property real monitorOffsetY: hyprlandMonitor.y
property int activeWorkspaceId: hyprlandMonitor.activeWorkspace?.id ?? 0
readonly property real monitorScale: (hyprlandMonitor?.scale ?? 0) > 0
? hyprlandMonitor.scale
: (screen?.devicePixelRatio ?? 1)
readonly property real monitorOffsetX: hyprlandMonitor?.x ?? screen?.x ?? 0
readonly property real monitorOffsetY: hyprlandMonitor?.y ?? screen?.y ?? 0
property int activeWorkspaceId: hyprlandMonitor?.activeWorkspace?.id ?? 0
property string screenshotPath: `${root.screenshotDir}/image-${screen.name}`
property real dragStartX: 0
property real dragStartY: 0

View file

@ -21,6 +21,53 @@ Singleton {
property var activeWorkspace: null
property var activeWindow: null
property var monitors: []
// Parse hyprctl's JSON, or keep what we had.
//
// Every collector below did a bare `JSON.parse()` on the process output.
// That is fine while Hyprland is the compositor and a hard error the
// moment it is not: under viewtop there is no `hyprctl`, the output is
// empty, and each collector threw a SyntaxError on every refresh — six
// exceptions per pass, forever, drowning the log the shell is diagnosed
// from.
//
// Absence is a state, not a failure. `HYPRLAND_INSTANCE_SIGNATURE` unset
// means "another compositor", and the honest answer is to keep the last
// known value and say so once — the same distinction
// DEVICE-STATE-MACHINE.md §10 draws between "no evidence" and "evidence
// says nothing".
property bool available: true
function parseOrKeep(text, fallback, what) {
if (!text || text.trim().length === 0) {
if (root.available) {
root.available = false;
console.log("[HyprlandData] no hyprctl output for", what,
"— assuming another compositor; monitor geometry comes from `screen`");
}
return fallback;
}
try {
const parsed = JSON.parse(text);
if (!root.available) {
root.available = true;
console.log("[HyprlandData] hyprctl is answering again");
}
return parsed;
} catch (e) {
// Latched like the empty case: `hyprctl` missing does not always
// mean *empty* output — a shell that prints an error to stdout
// lands here instead, and it lands here on every refresh. One line
// per edge, not four per pass. Same rule §10 applies to a sensor
// that has gone quiet: say it when it changes, not when it repeats.
if (root.available) {
root.available = false;
console.log("[HyprlandData]", what, "is unparseable —",
"assuming another compositor; monitor geometry comes from `screen`:", e);
}
return fallback;
}
}
property var layers: ({})
// Convenient stuff
@ -101,7 +148,7 @@ Singleton {
stdout: StdioCollector {
id: clientsCollector
onStreamFinished: {
root.windowList = JSON.parse(clientsCollector.text)
root.windowList = root.parseOrKeep(clientsCollector.text, [], "data")
let tempWinByAddress = {};
for (var i = 0; i < root.windowList.length; ++i) {
var win = root.windowList[i];
@ -119,7 +166,7 @@ Singleton {
stdout: StdioCollector {
id: activeWindowCollector
onStreamFinished: {
root.activeWindow = JSON.parse(activeWindowCollector.text)
root.activeWindow = root.parseOrKeep(activeWindowCollector.text, root.activeWindow, "activewindow")
}
}
}
@ -130,7 +177,7 @@ Singleton {
stdout: StdioCollector {
id: monitorsCollector
onStreamFinished: {
root.monitors = JSON.parse(monitorsCollector.text);
root.monitors = root.parseOrKeep(monitorsCollector.text, root.monitors, "monitors");
}
}
}
@ -141,7 +188,7 @@ Singleton {
stdout: StdioCollector {
id: layersCollector
onStreamFinished: {
root.layers = JSON.parse(layersCollector.text);
root.layers = root.parseOrKeep(layersCollector.text, root.layers, "layers");
}
}
}
@ -152,7 +199,7 @@ Singleton {
stdout: StdioCollector {
id: workspacesCollector
onStreamFinished: {
var rawWorkspaces = JSON.parse(workspacesCollector.text);
var rawWorkspaces = root.parseOrKeep(workspacesCollector.text, root.workspaces, "workspaces");
// Filter out invalid workspace ids (e.g. lock-screen temp workspace 2147483647 - N)
root.workspaces = rawWorkspaces.filter(ws => ws.id >= 1 && ws.id <= 100);
let tempWorkspaceById = {};
@ -172,7 +219,7 @@ Singleton {
stdout: StdioCollector {
id: activeWorkspaceCollector
onStreamFinished: {
root.activeWorkspace = JSON.parse(activeWorkspaceCollector.text);
root.activeWorkspace = root.parseOrKeep(activeWorkspaceCollector.text, root.activeWorkspace, "activeworkspace");
}
}
}

View file

@ -114,6 +114,43 @@ Singleton {
if (root.hasLoginctl)
lockedHintProc.report(root.locked);
}
// The seat's session object path, resolved once.
//
// `report()` used to resolve it on every call, which meant `sh` plus two
// busctl round trips before the hint could move. Measured 2026-08-02: the
// hint landed *after* sessiond's 2 s `LOCK_ACK_BUDGET`, so `request_blank()`
// timed out and blanked unlocked even though every other link in the chain
// was by then correct. Resolving once turns the lock report into a single
// call.
//
// Safe to cache for this shell's lifetime: the seat's session only changes
// when greetd restarts, and that restarts the shell with it.
property string seatSessionPath: ""
Process {
id: seatPathProbe
running: true
command: ["sh", "-c",
"busctl get-property org.freedesktop.login1 " +
"/org/freedesktop/login1/seat/seat0 " +
"org.freedesktop.login1.Seat ActiveSession " +
"| grep -o '/org/freedesktop/login1/session/[^\"]*' " +
"|| busctl get-property org.freedesktop.login1 " +
"/org/freedesktop/login1/user/_$(id -u) " +
"org.freedesktop.login1.User Display " +
"| grep -o '/org/freedesktop/login1/session/[^\"]*'"]
stdout: StdioCollector {
onStreamFinished: {
root.seatSessionPath = text.trim();
console.log("[session] seat session path:", root.seatSessionPath);
// Replay: the lock may already be secure by the time this
// lands, and the edge that would have reported it is gone.
// Same fault `onHasLoginctlChanged` above exists to fix.
if (root.seatSessionPath !== "" && root.hasLoginctl)
lockedHintProc.report(root.locked);
}
}
}
Process {
id: lockedHintProc
property bool pending: false
@ -125,49 +162,22 @@ Singleton {
pendingValue = value;
return;
}
// Resolve the session the way `lockhint.rs` does — the user's
// Display session — and never through the `/session/auto` alias.
//
// `auto` means *the caller's own* session, and the shell is not in
// the session that owns the seat. Measured 2026-08-02: viewtop in
// logind session 66 (seat0, tty1, the one `User.Display` names and
// the one sessiond watches), `qs -c souveraine` in session 70. So
// this call was setting the hint on a session nobody reads, while
// the graphical session's `LockedHint` stayed `no` forever.
//
// The consequence was not cosmetic. sessiond takes `locked` from
// `LockedHint` (doctrine §4), so `locked` was permanently false;
// `request_blank()` therefore timed out its `LOCK_ACK_BUDGET` on
// every single blank and took the fail-open branch, darkening the
// panel on a session it could not confirm was locked and writing
// `blank-without-lock` each time. LOCK-DPMS-LESSONS §1's ordering
// held in the code and not on the device.
//
// One shell round trip rather than two Processes: the path has to
// be resolved at report time, because the session id changes across
// a greetd restart and a cached one would be stale exactly when it
// matters. `$(…)` is fine here — the value is a busctl-printed
// object path, not user input.
// The seat's active session — the one on the glass — with
// `User.Display` only as a fallback. `lockhint.rs` resolves the
// same way on the read side, and the two must agree or this writes
// a hint nobody reads. An ssh login is enough to make `Display`
// name a seatless remote session, which is exactly how this was
// found.
command = ["sh", "-c",
"p=$(busctl get-property org.freedesktop.login1 " +
"/org/freedesktop/login1/seat/seat0 " +
"org.freedesktop.login1.Seat ActiveSession " +
"| grep -o '/org/freedesktop/login1/session/[^\"]*'); " +
"[ -n \"$p\" ] || p=$(busctl get-property " +
"org.freedesktop.login1 " +
"/org/freedesktop/login1/user/_$(id -u) " +
"org.freedesktop.login1.User Display " +
"| grep -o '/org/freedesktop/login1/session/[^\"]*'); " +
"[ -n \"$p\" ] || exit 1; " +
"exec busctl call org.freedesktop.login1 \"$p\" " +
"org.freedesktop.login1.Session SetLockedHint b " +
(value ? "true" : "false")];
if (root.seatSessionPath === "") {
// The probe has not landed. Dropping here is safe only because
// the probe replays on completion — see its onStreamFinished.
return;
}
// Never `/session/auto`: that is the *caller's* session, and the
// shell is not in the one that owns the seat. Measured: viewtop in
// logind 66 (seat0/tty1), `qs` in 70 — the hint was being written to
// a session nobody reads while the graphical session stayed `no`
// forever. sessiond takes `locked` from `LockedHint` (doctrine §4),
// so that made `locked` permanently false and every blank went out
// on a session nobody could confirm was locked.
command = ["busctl", "call", "org.freedesktop.login1",
root.seatSessionPath,
"org.freedesktop.login1.Session",
"SetLockedHint", "b", value ? "true" : "false"];
running = true;
}
onExited: {