mirror of
https://github.com/deunix-educ/sourizz.git
synced 2026-11-25 04:39:43 +01:00
Add a sourizz-restart script and record the autostart field test
sourizz-restart stops the running daemon (if any), waits until it is gone and starts a new one detached from the terminal; extra arguments go to the new daemon and SOURIZZ_LOG keeps its output. install.sh installs and removes it. The READMEs document it in both languages and now say that autostart was checked on KDE, GNOME, Xfce, Cinnamon and MATE. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
+5
-2
@@ -67,10 +67,13 @@ Prérequis à l'exécution :
|
||||
setsid -f sourizz # détaché du terminal : survit à sa fermeture
|
||||
sourizz status # tourne-t-il ?
|
||||
sourizz quit # l'arrêter
|
||||
sourizz-restart # l'arrêter s'il tourne, puis en lancer un nouveau (les arguments en plus vont au nouveau démon)
|
||||
sourizz autostart enable # le lancer à chaque ouverture de session (autostart disable pour annuler)
|
||||
```
|
||||
|
||||
`autostart enable` écrit `~/.config/autostart/sourizz.desktop` avec le chemin absolu de l'exécutable. KDE, GNOME, Xfce, Cinnamon et MATE exécutent ces entrées à l'ouverture de session (vérifié sur KDE uniquement). Hyprland et sway ne le font pas par défaut : ajoutez `exec-once = sourizz` à la configuration de Hyprland, ou `exec sourizz` à celle de sway. Lancez le démon depuis l'intérieur de la session graphique (autostart ou configuration du compositeur) pour qu'il hérite de `WAYLAND_DISPLAY` ou de `DISPLAY` ; un service systemd utilisateur ne les reçoit pas toujours, et aucun n'est fourni.
|
||||
`sourizz-restart` est un petit script shell installé à côté de `sourizz` ; `SOURIZZ_LOG=sourizz.log sourizz-restart -vv` relance le démon en gardant sa sortie de débogage dans ce fichier.
|
||||
|
||||
`autostart enable` écrit `~/.config/autostart/sourizz.desktop` avec le chemin absolu de l'exécutable. KDE, GNOME, Xfce, Cinnamon et MATE exécutent ces entrées à l'ouverture de session (vérifié sur les cinq). Hyprland et sway ne le font pas par défaut : ajoutez `exec-once = sourizz` à la configuration de Hyprland, ou `exec sourizz` à celle de sway. Lancez le démon depuis l'intérieur de la session graphique (autostart ou configuration du compositeur) pour qu'il hérite de `WAYLAND_DISPLAY` ou de `DISPLAY` ; un service systemd utilisateur ne les reçoit pas toujours, et aucun n'est fourni.
|
||||
|
||||
## Utilisation
|
||||
|
||||
@@ -176,7 +179,7 @@ Sourizz a un seul moteur de dessin et deux backends d'affichage ; il choisit le
|
||||
|
||||
Par défaut, Sourizz suit votre session : il utilise Wayland si `WAYLAND_DISPLAY` est défini et que `$XDG_SESSION_TYPE` n'est pas `x11`, et X11 sinon. `sourizz doctor` affiche la session et le backend qui sera utilisé (`echo $XDG_SESSION_TYPE` indique aussi dans quelle session vous êtes).
|
||||
|
||||
Pour en imposer un, utilisez `sourizz --backend x11` ou `--backend wayland`, ou écrivez `backend = "x11"` (`"wayland"`, `"auto"`) sous `[general]` dans le fichier de configuration — la fenêtre de réglages l'offre dans l'onglet *Général*. L'option de la ligne de commande l'emporte sur le fichier. Le backend est choisi au démarrage : **relancez le démon** après l'avoir changé. Imposer X11 dans une session Wayland est rarement utile : un programme X11 n'y voit généralement le pointeur que lorsqu'il est au-dessus d'autres fenêtres X11.
|
||||
Pour en imposer un, utilisez `sourizz --backend x11` ou `--backend wayland`, ou écrivez `backend = "x11"` (`"wayland"`, `"auto"`) sous `[general]` dans le fichier de configuration — la fenêtre de réglages l'offre dans l'onglet *Général*. L'option de la ligne de commande l'emporte sur le fichier. Le backend est choisi au démarrage : **relancez le démon** après l'avoir changé (`sourizz-restart` le fait). Imposer X11 dans une session Wayland est rarement utile : un programme X11 n'y voit généralement le pointeur que lorsqu'il est au-dessus d'autres fenêtres X11.
|
||||
|
||||
La session elle-même se choisit sur l'écran de connexion (par exemple « Plasma (X11) » ou « Plasma (Wayland) »).
|
||||
|
||||
|
||||
@@ -67,10 +67,13 @@ Run-time requirements:
|
||||
setsid -f sourizz # detached from the terminal: survives closing it
|
||||
sourizz status # is it running?
|
||||
sourizz quit # stop it
|
||||
sourizz-restart # stop it if it runs, then start a new one (extra arguments go to the new daemon)
|
||||
sourizz autostart enable # start it at every login (autostart disable to undo)
|
||||
```
|
||||
|
||||
`autostart enable` writes `~/.config/autostart/sourizz.desktop` with the absolute path of the executable. KDE, GNOME, Xfce, Cinnamon and MATE run such entries at login (checked on KDE only). Hyprland and sway do not run them by default: put `exec-once = sourizz` in the Hyprland configuration, or `exec sourizz` in sway's. Start the daemon from inside the graphical session (autostart or the compositor's configuration) so that it inherits `WAYLAND_DISPLAY` or `DISPLAY`; a systemd user service does not always receive them, and none is provided.
|
||||
`sourizz-restart` is a small shell script installed next to `sourizz`; `SOURIZZ_LOG=sourizz.log sourizz-restart -vv` restarts the daemon with debug output kept in that file.
|
||||
|
||||
`autostart enable` writes `~/.config/autostart/sourizz.desktop` with the absolute path of the executable. KDE, GNOME, Xfce, Cinnamon and MATE run such entries at login (checked on all five). Hyprland and sway do not run them by default: put `exec-once = sourizz` in the Hyprland configuration, or `exec sourizz` in sway's. Start the daemon from inside the graphical session (autostart or the compositor's configuration) so that it inherits `WAYLAND_DISPLAY` or `DISPLAY`; a systemd user service does not always receive them, and none is provided.
|
||||
|
||||
## Using it
|
||||
|
||||
@@ -176,7 +179,7 @@ Sourizz has one drawing engine and two display backends; it picks the right one
|
||||
|
||||
By default Sourizz follows your session: it uses Wayland when `WAYLAND_DISPLAY` is set and `$XDG_SESSION_TYPE` is not `x11`, and X11 otherwise. `sourizz doctor` prints the session and the backend that will be used (`echo $XDG_SESSION_TYPE` also tells you which session you are in).
|
||||
|
||||
To force one, use `sourizz --backend x11` or `--backend wayland`, or set `backend = "x11"` (`"wayland"`, `"auto"`) under `[general]` in the config file — the settings window has it in the *General* tab. The command-line flag wins over the file. The backend is chosen at start-up, so **restart the daemon** after changing it. Forcing X11 inside a Wayland session is rarely useful: an X11 program there generally only sees the pointer while it is over other X11 windows.
|
||||
To force one, use `sourizz --backend x11` or `--backend wayland`, or set `backend = "x11"` (`"wayland"`, `"auto"`) under `[general]` in the config file — the settings window has it in the *General* tab. The command-line flag wins over the file. The backend is chosen at start-up, so **restart the daemon** after changing it (`sourizz-restart` does it). Forcing X11 inside a Wayland session is rarely useful: an X11 program there generally only sees the pointer while it is over other X11 windows.
|
||||
|
||||
The session itself is chosen at the login screen (for example "Plasma (X11)" or "Plasma (Wayland)").
|
||||
|
||||
|
||||
+2
-1
@@ -78,7 +78,7 @@ ensure_rust() {
|
||||
}
|
||||
|
||||
if [[ $UNINSTALL -eq 1 ]]; then
|
||||
rm -fv "$BIN/sourizz" "$BIN/sourizz-settings" "$APPS/sourizz.desktop" "$APPS/sourizz-settings.desktop" "$ICONS/sourizz.svg" "$DOCS/LICENSE"
|
||||
rm -fv "$BIN/sourizz" "$BIN/sourizz-settings" "$BIN/sourizz-restart" "$APPS/sourizz.desktop" "$APPS/sourizz-settings.desktop" "$ICONS/sourizz.svg" "$DOCS/LICENSE"
|
||||
rmdir "$DOCS" 2>/dev/null || true
|
||||
rm -fv "${XDG_CONFIG_HOME:-$HOME/.config}/autostart/sourizz.desktop"
|
||||
echo "Uninstalled. Your settings in ${XDG_CONFIG_HOME:-$HOME/.config}/sourizz were kept."
|
||||
@@ -90,6 +90,7 @@ ensure_rust
|
||||
cargo build --release
|
||||
install -Dm755 target/release/sourizz "$BIN/sourizz"
|
||||
install -Dm755 target/release/sourizz-settings "$BIN/sourizz-settings"
|
||||
install -Dm755 packaging/sourizz-restart "$BIN/sourizz-restart"
|
||||
install -Dm644 packaging/sourizz.svg "$ICONS/sourizz.svg"
|
||||
install -Dm644 LICENSE "$DOCS/LICENSE"
|
||||
# Use absolute paths so the launchers work even when ~/.local/bin is not on the desktop's PATH.
|
||||
|
||||
Executable
+45
@@ -0,0 +1,45 @@
|
||||
#!/usr/bin/env bash
|
||||
# Restart the Sourizz daemon: stop the running one (if any), wait until it is gone, start a new one
|
||||
# detached from the terminal. Extra arguments go to the new daemon, e.g. `sourizz-restart --backend x11`.
|
||||
# Set SOURIZZ_LOG=<file> to keep its output (useful with -vv); it is discarded otherwise.
|
||||
# Run it from inside your graphical session so the daemon inherits DISPLAY / WAYLAND_DISPLAY.
|
||||
set -euo pipefail
|
||||
|
||||
here="$(dirname "$(readlink -f "$0")")"
|
||||
if [[ -x "$here/sourizz" ]]; then
|
||||
sourizz="$here/sourizz"
|
||||
elif sourizz="$(command -v sourizz)"; then
|
||||
:
|
||||
else
|
||||
echo "sourizz-restart: cannot find the sourizz executable." >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Poll `status` (it fails while no daemon answers) until it matches the wanted state, for about 5 s.
|
||||
wait_for() {
|
||||
local want_running=$1 i
|
||||
for ((i = 0; i < 50; i++)); do
|
||||
if "$sourizz" status >/dev/null 2>&1; then
|
||||
[[ $want_running -eq 1 ]] && return 0
|
||||
else
|
||||
[[ $want_running -eq 0 ]] && return 0
|
||||
fi
|
||||
sleep 0.1
|
||||
done
|
||||
return 1
|
||||
}
|
||||
|
||||
if "$sourizz" status >/dev/null 2>&1; then
|
||||
"$sourizz" quit >/dev/null 2>&1 || true
|
||||
wait_for 0 || { echo "sourizz-restart: the running daemon did not stop within 5 s." >&2; exit 1; }
|
||||
fi
|
||||
|
||||
log="${SOURIZZ_LOG:-/dev/null}"
|
||||
if command -v setsid >/dev/null; then
|
||||
setsid -f "$sourizz" "$@" >"$log" 2>&1 </dev/null
|
||||
else
|
||||
nohup "$sourizz" "$@" >"$log" 2>&1 </dev/null &
|
||||
fi
|
||||
|
||||
wait_for 1 || { echo "sourizz-restart: the new daemon did not come up; run 'sourizz -vv' in a terminal to see why." >&2; exit 1; }
|
||||
echo "Sourizz restarted."
|
||||
Reference in New Issue
Block a user