mirror of
https://github.com/kuhyx/testsAndMisc.git
synced 2026-11-18 23:14:22 +01:00
Start xfce4-notifyd only once X answers
Some checks are pending
dependency freshness / dependencies on newest stable (push) Waiting to run
md-naming / markdown naming convention (push) Waiting to run
Pre-commit checks / pre-commit (${{ matrix.group }}) (mypy, mypy) (push) Waiting to run
Pre-commit checks / pre-commit (${{ matrix.group }}) (pylint, pylint) (push) Waiting to run
Pre-commit checks / pre-commit (${{ matrix.group }}) (rest, ) (push) Waiting to run
Pre-commit checks / pre-commit (${{ matrix.group }}) (shellcheck, shellcheck) (push) Waiting to run
repo-contract / repo contract (push) Waiting to run
Shell tests / shell-tests (push) Waiting to run
Shell tests / lib-tests (push) Waiting to run
Shell tests / arch-tests (push) Waiting to run
Some checks are pending
dependency freshness / dependencies on newest stable (push) Waiting to run
md-naming / markdown naming convention (push) Waiting to run
Pre-commit checks / pre-commit (${{ matrix.group }}) (mypy, mypy) (push) Waiting to run
Pre-commit checks / pre-commit (${{ matrix.group }}) (pylint, pylint) (push) Waiting to run
Pre-commit checks / pre-commit (${{ matrix.group }}) (rest, ) (push) Waiting to run
Pre-commit checks / pre-commit (${{ matrix.group }}) (shellcheck, shellcheck) (push) Waiting to run
repo-contract / repo contract (push) Waiting to run
Shell tests / shell-tests (push) Waiting to run
Shell tests / lib-tests (push) Waiting to run
Shell tests / arch-tests (push) Waiting to run
notifyd is D-Bus-activated by a user manager that outlives X. Each activation during a night-lockdown X restart exited with 'cannot open display' until the start limit failed the bus name, so notify-send got NameHasNoOwner (2026-11-18). A drop-in waits up to 15 s for X and drops the start limit; i3 refreshes the activation environment. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WzxdWWLoUxxSPf1m8KUVo8
This commit is contained in:
parent
fb18a5f255
commit
6fecf148eb
32
docs/superpowers/evidence/notifyd-wait-for-x-2026-11-18.json
Normal file
32
docs/superpowers/evidence/notifyd-wait-for-x-2026-11-18.json
Normal file
@ -0,0 +1,32 @@
|
||||
{
|
||||
"intent": "xfce4-notifyd starts only once X answers, so a night-lockdown X restart no longer exhausts its start limit and leaves notify-send with NameHasNoOwner (2026-11-18).",
|
||||
"scope": [
|
||||
"linux_configuration/i3/{config,install.sh,wait_for_x.sh,check_notifyd_survives_x_restart.sh,systemd/xfce4-notifyd.service.d/wait-for-x.conf}",
|
||||
"Non-goal: no change to what notifyd shows or to the notification senders"
|
||||
],
|
||||
"changes": [
|
||||
"wait_for_x.sh: polls up to 15 s for the display before notifyd execs",
|
||||
"drop-in wait-for-x.conf: runs wait_for_x.sh as ExecStartPre and drops the start limit; install.sh copies it to ~/.config/systemd/user/",
|
||||
"i3 config: refreshes the D-Bus/systemd activation environment on start",
|
||||
"check_notifyd_survives_x_restart.sh: sandboxed repro that brings X up late and sends a notification"
|
||||
],
|
||||
"verification": [
|
||||
{
|
||||
"command": "bash linux_configuration/i3/check_notifyd_survives_x_restart.sh",
|
||||
"result": "pass",
|
||||
"evidence": "OK: notify-send succeeded while X came up late (exit 0)"
|
||||
},
|
||||
{
|
||||
"command": "shellcheck linux_configuration/i3/{check_notifyd_survives_x_restart,wait_for_x,install}.sh",
|
||||
"result": "pass",
|
||||
"evidence": "no findings"
|
||||
}
|
||||
],
|
||||
"risks": [
|
||||
"A running user manager needs daemon-reload to see the drop-in; install.sh runs it",
|
||||
"If X never comes up the unit fails after 15 s instead of looping"
|
||||
],
|
||||
"rollback": [
|
||||
"git revert the commit and delete ~/.config/systemd/user/xfce4-notifyd.service.d/wait-for-x.conf, then systemctl --user daemon-reload"
|
||||
]
|
||||
}
|
||||
@ -1,43 +0,0 @@
|
||||
{
|
||||
"intent": "screen-locker's workout poke (phone POSTs a finished workout to tcp/8773) can reach the PC from the home LAN, persisted across firewall re-applies, without exposing the port on WireGuard.",
|
||||
"scope": [
|
||||
"linux_configuration/features/lib/wg_firewall.sh: ALLOW_WORKOUT_POKE renders 'ip saddr ${LAN_SUBNET} tcp dport 8773 accept'; allow_workout_poke()",
|
||||
"linux_configuration/features/setup_wireguard_ssh.sh: default, save_config, require_root list, allow-workout-poke dispatch",
|
||||
"linux_configuration/features/lib/wg_sshd.sh: usage line",
|
||||
"linux_configuration/features/lib/tests/test_wg_firewall.sh: render + apply-path tests",
|
||||
"Non-goal: no wg0 rule for 8773; off the LAN the poke fails fast and the normal sync credits the workout"
|
||||
],
|
||||
"changes": [
|
||||
"New ALLOW_WORKOUT_POKE flag (default false) persisted in .wireguard_ssh.conf like ALLOW_DOT",
|
||||
"allow-workout-poke subcommand: export flag, save_config, render, verify-then-apply, install verify units"
|
||||
],
|
||||
"verification": [
|
||||
{
|
||||
"command": "bash linux_configuration/features/lib/tests/test_wg_firewall.sh",
|
||||
"result": "pass",
|
||||
"evidence": "18 passed, 0 failed: unset/false render no 8773 rule; true renders exactly one, LAN-only; allow_workout_poke saves the flag as true before applying and the applied ruleset carries the rule"
|
||||
},
|
||||
{
|
||||
"command": "shell_coverage_jail.sh --subject linux_configuration/features/lib/tests/run_all.sh <jail_args> --min 0 --fail-on-case-error",
|
||||
"result": "pass",
|
||||
"evidence": "jailed suite exit 0"
|
||||
},
|
||||
{
|
||||
"command": "sudo setup_wireguard_ssh.sh allow-workout-poke on the host (run by the user)",
|
||||
"result": "pass",
|
||||
"evidence": "nft list ruleset shows ip saddr <LAN> tcp dport 8773 accept in inet filter input"
|
||||
},
|
||||
{
|
||||
"command": "pre-commit run --files <the four files>",
|
||||
"result": "pass",
|
||||
"evidence": "all hooks passed"
|
||||
}
|
||||
],
|
||||
"risks": [
|
||||
"Any LAN host can reach tcp/8773; the poke server authenticates requests itself."
|
||||
],
|
||||
"rollback": [
|
||||
"git revert this commit, set ALLOW_WORKOUT_POKE=false in .wireguard_ssh.conf and re-run any allow-* to re-render",
|
||||
"After rollback: setup_wireguard_ssh.sh verify reports no drift and no 8773 rule"
|
||||
]
|
||||
}
|
||||
41
linux_configuration/i3/check_notifyd_survives_x_restart.sh
Executable file
41
linux_configuration/i3/check_notifyd_survives_x_restart.sh
Executable file
@ -0,0 +1,41 @@
|
||||
#!/bin/bash
|
||||
# Check: a D-Bus-activated xfce4-notifyd survives an X server that is still
|
||||
# coming up (night lockdown / lightdm restart). Never touches the live X: the
|
||||
# user manager's DISPLAY is pointed at a private Xvfb that starts 3 s late,
|
||||
# and the original environment and notifier are restored on exit.
|
||||
# Exit 0 = notify-send worked; non-zero = the 2026-11-18 failure reproduced.
|
||||
set -euo pipefail
|
||||
|
||||
readonly TEST_DISPLAY=":98"
|
||||
readonly UNIT="xfce4-notifyd.service"
|
||||
orig_display="$(systemctl --user show-environment | sed -n 's/^DISPLAY=//p')"
|
||||
orig_xauth="$(systemctl --user show-environment | sed -n 's/^XAUTHORITY=//p')"
|
||||
xvfb_pid=""
|
||||
|
||||
cleanup() {
|
||||
if [[ -n "$xvfb_pid" ]]; then kill "$xvfb_pid" 2>/dev/null || true; fi
|
||||
systemctl --user stop "$UNIT" 2>/dev/null || true
|
||||
systemctl --user reset-failed "$UNIT" 2>/dev/null || true
|
||||
if [[ -n "$orig_display" ]]; then systemctl --user set-environment "DISPLAY=$orig_display"; fi
|
||||
if [[ -n "$orig_xauth" ]]; then systemctl --user set-environment "XAUTHORITY=$orig_xauth"; fi
|
||||
# Bring the live notifier back (starting it shows no toast).
|
||||
systemctl --user start "$UNIT" || echo "WARN: live $UNIT did not restart" >&2
|
||||
}
|
||||
trap cleanup EXIT
|
||||
|
||||
[[ ! -e /tmp/.X11-unix/X98 ]] || {
|
||||
echo "X98 already in use" >&2
|
||||
exit 2
|
||||
}
|
||||
systemctl --user stop "$UNIT" 2>/dev/null || true
|
||||
systemctl --user reset-failed "$UNIT" 2>/dev/null || true
|
||||
systemctl --user set-environment "DISPLAY=$TEST_DISPLAY"
|
||||
systemctl --user unset-environment XAUTHORITY
|
||||
|
||||
# X "restarts" 3 s after the notification request.
|
||||
(sleep 3 && exec Xvfb "$TEST_DISPLAY" -nolisten tcp -screen 0 640x480x24) >/dev/null 2>&1 &
|
||||
xvfb_pid=$!
|
||||
|
||||
# The summary is the display name: the toast only ever lands on the private Xvfb.
|
||||
systemd-run --user --wait --collect --quiet notify-send -t 1 -- "$TEST_DISPLAY"
|
||||
echo "OK: notify-send succeeded while X came up late"
|
||||
@ -22,6 +22,9 @@ font pango:System San Francisco Display, FontAwesome 8
|
||||
# Start XDG autostart .desktop files using dex. See also
|
||||
# https://wiki.archlinux.org/index.php/XDG_Autostart
|
||||
exec --no-startup-id dex --autostart --environment i3
|
||||
# Refresh the DISPLAY/XAUTHORITY the systemd --user manager and D-Bus activation
|
||||
# hand to units (e.g. xfce4-notifyd) on every i3 start.
|
||||
exec --no-startup-id dbus-update-activation-environment --systemd DISPLAY XAUTHORITY
|
||||
|
||||
# OpenTabletDriver daemon (Huion HS64 -> DP-0 mapping). Started here because i3
|
||||
# does not reliably activate graphical-session.target, which the packaged
|
||||
|
||||
@ -2,7 +2,10 @@
|
||||
|
||||
# Resolve the directory this script lives in and work from there, so every
|
||||
# relative path below (i3blocks/, i3/) resolves no matter where it is invoked.
|
||||
SCRIPT_DIR=$(unset CDPATH; cd -- "$(dirname -- "$0")" && pwd)
|
||||
SCRIPT_DIR=$(
|
||||
unset CDPATH
|
||||
cd -- "$(dirname -- "$0")" && pwd
|
||||
)
|
||||
cd "$SCRIPT_DIR" || exit 1
|
||||
|
||||
# Function to detect if the system is Ubuntu
|
||||
@ -66,6 +69,13 @@ for src in "$SCRIPT_DIR"/i3blocks/*; do
|
||||
ln -sfn "$src" "$HOME/.config/i3blocks/$(basename "$src")"
|
||||
done
|
||||
|
||||
# The notification daemon is D-Bus activated and the systemd --user manager
|
||||
# outlives X sessions: this drop-in makes it wait for X instead of failing
|
||||
# (see wait_for_x.sh).
|
||||
mkdir -p "$HOME/.config/systemd/user/xfce4-notifyd.service.d"
|
||||
cp "$SCRIPT_DIR"/systemd/xfce4-notifyd.service.d/*.conf "$HOME/.config/systemd/user/xfce4-notifyd.service.d/"
|
||||
systemctl --user daemon-reload
|
||||
|
||||
# i3 config is copied (not symlinked) because it needs a per-machine font-size
|
||||
# mutation applied below; symlinking would write that change back into the repo.
|
||||
cp -r i3 ~/.config/
|
||||
|
||||
@ -0,0 +1,7 @@
|
||||
# Source: i3/systemd/. Installed to ~/.config/systemd/user/xfce4-notifyd.service.d/ by i3/install.sh.
|
||||
# See wait_for_x.sh for why the start waits for X and why the start limit is off.
|
||||
[Unit]
|
||||
StartLimitIntervalSec=0
|
||||
|
||||
[Service]
|
||||
ExecStartPre=%h/src/testsAndMisc/linux_configuration/i3/wait_for_x.sh
|
||||
17
linux_configuration/i3/wait_for_x.sh
Executable file
17
linux_configuration/i3/wait_for_x.sh
Executable file
@ -0,0 +1,17 @@
|
||||
#!/bin/bash
|
||||
# ExecStartPre for xfce4-notifyd.service: hold the start until $DISPLAY
|
||||
# answers, up to WAIT_FOR_X_SECS (default 15). The notifier is D-Bus
|
||||
# activated and the systemd --user manager outlives X sessions, so a request
|
||||
# that lands while X restarts (night lockdown, lightdm) used to fail five
|
||||
# times at once, hit the start limit and fail the activation. Waiting turns
|
||||
# that into one start that succeeds as soon as X is back.
|
||||
set -euo pipefail
|
||||
|
||||
readonly deadline=$((SECONDS + ${WAIT_FOR_X_SECS:-15}))
|
||||
until xset q >/dev/null 2>&1; do
|
||||
if ((SECONDS >= deadline)); then
|
||||
echo "wait_for_x: DISPLAY=${DISPLAY:-unset} not answering after ${WAIT_FOR_X_SECS:-15}s" >&2
|
||||
exit 1
|
||||
fi
|
||||
sleep 0.25
|
||||
done
|
||||
Loading…
Reference in New Issue
Block a user