MAJ
This commit is contained in:
1 parent
6a65913c2c
commit
fb22fa8af7
143 files changed
+5657
-42
No files matched your search
Executable
+5
@@ -0,0 +1,5 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
exec xdg-open 'https://wiki.archlinux.org/title/Installation_guide'
|
||||
Executable
+29
@@ -0,0 +1,29 @@
|
||||
#!/bin/bash
|
||||
#
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
get_cmdline() {
|
||||
local param
|
||||
for param in $(</proc/cmdline); do
|
||||
case "${param}" in
|
||||
"${1}="*)
|
||||
echo "${param##*=}"
|
||||
return 0
|
||||
;;
|
||||
esac
|
||||
done
|
||||
}
|
||||
|
||||
mirror="$(get_cmdline mirror)"
|
||||
[[ "$mirror" == 'auto' ]] && mirror="$(get_cmdline archiso_http_srv)"
|
||||
[[ -n "$mirror" ]] || exit 0
|
||||
|
||||
mv /etc/pacman.d/mirrorlist /etc/pacman.d/mirrorlist.orig
|
||||
cat >/etc/pacman.d/mirrorlist <<EOF
|
||||
#
|
||||
# Arch Linux repository mirrorlist
|
||||
# Generated by archiso
|
||||
#
|
||||
|
||||
Server = ${mirror%%/}/\$repo/os/\$arch
|
||||
EOF
|
||||
Executable
+185
@@ -0,0 +1,185 @@
|
||||
#!/usr/bin/env python3
|
||||
# FWS — fenêtre « À propos » : deux onglets, « Le projet FWS » (ce qu'est FWS,
|
||||
# version, liens) et « Système » (matériel + logiciel détectés). Remplace le
|
||||
# « About Xfce » de libxfce4ui par une page de marque FWS. GTK3 (python-gobject
|
||||
# installé avec le bureau).
|
||||
|
||||
import os
|
||||
import re
|
||||
import subprocess
|
||||
|
||||
import gi
|
||||
|
||||
gi.require_version("Gtk", "3.0")
|
||||
gi.require_version("Gdk", "3.0") # sinon gi charge Gdk 4.0 (conflit avec Gtk3)
|
||||
from gi.repository import Gdk, GLib, Gtk # noqa: E402
|
||||
|
||||
GLib.set_prgname("fws-about")
|
||||
|
||||
|
||||
def _osrelease():
|
||||
data = {}
|
||||
for path in ("/etc/os-release", "/usr/lib/os-release"):
|
||||
try:
|
||||
with open(path) as fh:
|
||||
for line in fh:
|
||||
m = re.match(r'^([A-Z_]+)=(.*)$', line.strip())
|
||||
if m:
|
||||
data[m.group(1)] = m.group(2).strip('"')
|
||||
break
|
||||
except OSError:
|
||||
continue
|
||||
return data
|
||||
|
||||
|
||||
def _cmd(*argv):
|
||||
try:
|
||||
return subprocess.check_output(argv, text=True,
|
||||
stderr=subprocess.DEVNULL).strip()
|
||||
except (OSError, subprocess.CalledProcessError):
|
||||
return ""
|
||||
|
||||
|
||||
def _cpu():
|
||||
try:
|
||||
with open("/proc/cpuinfo") as fh:
|
||||
for line in fh:
|
||||
if line.startswith("model name"):
|
||||
return line.split(":", 1)[1].strip()
|
||||
except OSError:
|
||||
pass
|
||||
return "inconnu"
|
||||
|
||||
|
||||
def _mem():
|
||||
try:
|
||||
with open("/proc/meminfo") as fh:
|
||||
for line in fh:
|
||||
if line.startswith("MemTotal"):
|
||||
kib = int(line.split()[1])
|
||||
return f"{kib / 1048576:.1f} Gio"
|
||||
except OSError:
|
||||
pass
|
||||
return "inconnu"
|
||||
|
||||
|
||||
def _gpus():
|
||||
out = []
|
||||
for line in _cmd("lspci").splitlines():
|
||||
low = line.lower()
|
||||
if "vga" in low or "3d" in low or "display" in low:
|
||||
out.append(line.split(":", 2)[-1].strip())
|
||||
return out or ["inconnu"]
|
||||
|
||||
|
||||
def _desktop():
|
||||
if os.environ.get("HYPRLAND_INSTANCE_SIGNATURE"):
|
||||
return "Hyprland"
|
||||
env = os.environ.get("XDG_CURRENT_DESKTOP") \
|
||||
or os.environ.get("DESKTOP_SESSION") or ""
|
||||
return env or "inconnu"
|
||||
|
||||
|
||||
def _session_type():
|
||||
t = os.environ.get("XDG_SESSION_TYPE", "")
|
||||
return {"wayland": "Wayland", "x11": "X11"}.get(t, t or "inconnu")
|
||||
|
||||
|
||||
def _disks():
|
||||
out = []
|
||||
for line in _cmd("lsblk", "-dno", "NAME,SIZE,MODEL,TYPE").splitlines():
|
||||
f = line.split()
|
||||
if f and f[-1] == "disk":
|
||||
out.append(" ".join(f[:-1]))
|
||||
return out or ["inconnu"]
|
||||
|
||||
|
||||
def _grid(rows):
|
||||
grid = Gtk.Grid(column_spacing=18, row_spacing=8, margin=18)
|
||||
for i, (key, val) in enumerate(rows):
|
||||
k = Gtk.Label(xalign=1)
|
||||
k.set_markup(f"<b>{GLib.markup_escape_text(key)}</b>")
|
||||
k.get_style_context().add_class("dim-label")
|
||||
v = Gtk.Label(label=val, xalign=0, selectable=True)
|
||||
v.set_line_wrap(True)
|
||||
grid.attach(k, 0, i, 1, 1)
|
||||
grid.attach(v, 1, i, 1, 1)
|
||||
return grid
|
||||
|
||||
|
||||
def _project_tab(osr):
|
||||
box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=10, margin=20)
|
||||
title = Gtk.Label()
|
||||
name = osr.get("PRETTY_NAME") or osr.get("NAME") or "FWS Linux"
|
||||
title.set_markup(f"<span size='xx-large' weight='bold'>{name}</span>")
|
||||
box.pack_start(title, False, False, 0)
|
||||
|
||||
tag = Gtk.Label(label="Une distribution Linux pensée pour remplacer "
|
||||
"Windows : bureau prêt à l'emploi, jeux, VR et "
|
||||
"compatibilité applicative.")
|
||||
tag.set_line_wrap(True)
|
||||
tag.set_max_width_chars(52)
|
||||
box.pack_start(tag, False, False, 0)
|
||||
|
||||
feats = Gtk.Label()
|
||||
feats.set_markup(
|
||||
"<b>Inclus :</b> installateur graphique · plusieurs bureaux "
|
||||
"(GNOME, KDE, Hyprland, i3, XFCE) · Steam & Proton-GE · "
|
||||
"réalité virtuelle (SteamVR) · winboat (applications Windows) · "
|
||||
"pare-feu · réparation système intégrée.")
|
||||
feats.set_line_wrap(True)
|
||||
feats.set_max_width_chars(52)
|
||||
feats.set_xalign(0)
|
||||
box.pack_start(feats, False, False, 6)
|
||||
|
||||
home = osr.get("HOME_URL") or "https://gitea.nocode-var.tech/FWS/FWS-ISO"
|
||||
link = Gtk.LinkButton.new_with_label(home, "Site du projet")
|
||||
box.pack_start(link, False, False, 0)
|
||||
return box
|
||||
|
||||
|
||||
def _system_tab(osr):
|
||||
rows = [
|
||||
("Système", osr.get("PRETTY_NAME", "FWS Linux")),
|
||||
("Build", osr.get("BUILD_ID", "rolling")),
|
||||
("Noyau", _cmd("uname", "-r") or "inconnu"),
|
||||
("Bureau", _desktop()),
|
||||
("Affichage", _session_type()),
|
||||
("Nom de machine", _cmd("hostname") or os.uname().nodename),
|
||||
("Processeur", _cpu()),
|
||||
("Mémoire", _mem()),
|
||||
("Carte(s) graphique(s)", "\n".join(_gpus())),
|
||||
("Disque(s)", "\n".join(_disks())),
|
||||
]
|
||||
scroll = Gtk.ScrolledWindow()
|
||||
scroll.set_policy(Gtk.PolicyType.NEVER, Gtk.PolicyType.AUTOMATIC)
|
||||
scroll.add(_grid(rows))
|
||||
return scroll
|
||||
|
||||
|
||||
class AboutWindow(Gtk.Window):
|
||||
def __init__(self):
|
||||
super().__init__(title="À propos de FWS")
|
||||
self.set_default_size(520, 460)
|
||||
self.set_position(Gtk.WindowPosition.CENTER)
|
||||
self.set_type_hint(Gdk.WindowTypeHint.DIALOG)
|
||||
|
||||
osr = _osrelease()
|
||||
notebook = Gtk.Notebook()
|
||||
notebook.append_page(_project_tab(osr), Gtk.Label(label="Le projet FWS"))
|
||||
notebook.append_page(_system_tab(osr), Gtk.Label(label="Système"))
|
||||
self.add(notebook)
|
||||
self.connect("destroy", Gtk.main_quit)
|
||||
|
||||
|
||||
def main():
|
||||
if not Gtk.init_check()[0]:
|
||||
return 1
|
||||
win = AboutWindow()
|
||||
win.show_all()
|
||||
Gtk.main()
|
||||
return 0
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
raise SystemExit(main())
|
||||
Executable
+16
@@ -0,0 +1,16 @@
|
||||
#!/usr/bin/env bash
|
||||
# FWS — réglage de la luminosité avec un plancher à 10 % : on ne tombe
|
||||
# jamais dans le noir complet. Consommé par les touches Fn (Hyprland,
|
||||
# XF86MonBrightness*) et la molette du module backlight (waybar).
|
||||
# Pourquoi un script : --min-value de brightnessctl est en valeurs brutes
|
||||
# (10 % de la plage du matériel, pas un pourcentage), calculé ici.
|
||||
set -euo pipefail
|
||||
|
||||
# 10 % de la plage max du matériel, arrondi au-dessus (>= 10 % garanti).
|
||||
min=$(( ($(brightnessctl max) * 10 + 99) / 100 ))
|
||||
|
||||
case "${1:-}" in
|
||||
up) brightnessctl set +5% ;;
|
||||
down) brightnessctl --min-value="$min" set 5%- ;;
|
||||
*) echo "usage: fws-brightness up|down" >&2; exit 1 ;;
|
||||
esac
|
||||
Executable
+699
@@ -0,0 +1,699 @@
|
||||
#!/usr/bin/env python3
|
||||
# FWS — « Signaler un problème » : envoi OPTIONNEL et validé par l'utilisateur
|
||||
# de logs aux développeurs. Rien n'est collecté ni envoyé sans action
|
||||
# explicite : l'utilisateur remplit le formulaire, voit le payload JSON EXACT
|
||||
# qui partira (infos système + extrait du journal inclus si la case est
|
||||
# cochée), puis confirme l'envoi. Aucun daemon, aucune collecte en
|
||||
# arrière-plan, aucun envoi automatique.
|
||||
#
|
||||
# L'envoi passe par curl vers l'API bugs du projet — tout part par CE curl,
|
||||
# rien d'autre ne quitte la machine :
|
||||
# curl -X POST https://fws.laxacube.ch/api/bugs.php
|
||||
# -H "Content-Type: application/json"
|
||||
# -d '{"app":"FWS","version":"0.7.0","type":"bug","title":"…","description":"…"}'
|
||||
#
|
||||
# Usages :
|
||||
# fws-bugreport → fenêtre GTK (menu « Signaler un problème »)
|
||||
# fws-bugreport --file <chemin> → pré-remplit la description avec un fichier
|
||||
# de logs existant (écran de debug du live)
|
||||
# fws-bugreport --tui → assistant console (repli sans X / SSH)
|
||||
#
|
||||
# Vérifier qu'un envoi est bien parti : la réponse du serveur (code HTTP +
|
||||
# message, ex. « HTTP 201 — Signalement enregistré. Merci ! (id 13) ») est
|
||||
# affichée et tracée dans /tmp/fws-bugreport.log.
|
||||
#
|
||||
# GTK3 : présent sur tous les bureaux FWS et sur le live (via Anaconda) ;
|
||||
# sans GTK joignable, l'assistant console prend le relais automatiquement.
|
||||
|
||||
import json
|
||||
import os
|
||||
import re
|
||||
import subprocess
|
||||
import sys
|
||||
import time
|
||||
import traceback
|
||||
|
||||
# Trace locale de chaque tentative d'envoi (date, code HTTP, réponse du
|
||||
# serveur) — la façon de vérifier qu'un rapport est bien parti :
|
||||
# cat /tmp/fws-bugreport.log
|
||||
_LOG_PATH = "/tmp/fws-bugreport.log"
|
||||
|
||||
_URL = "https://fws.laxacube.ch/api/bugs.php"
|
||||
_APP = "FWS"
|
||||
|
||||
# (valeur envoyée au serveur, libellé affiché)
|
||||
_TYPES = [
|
||||
("bug", "Bug / panne"),
|
||||
("question", "Question"),
|
||||
("suggestion", "Suggestion"),
|
||||
("other", "Autre"),
|
||||
]
|
||||
|
||||
try:
|
||||
import gi
|
||||
|
||||
gi.require_version("Gtk", "3.0")
|
||||
gi.require_version("Gdk", "3.0") # sinon gi charge Gdk 4.0 (conflit Gtk3)
|
||||
from gi.repository import Gdk, GLib, Gtk # noqa: E402
|
||||
|
||||
_HAS_GTK = True
|
||||
except Exception: # noqa: BLE001 — pas de GTK (système CLI, live minimal…)
|
||||
_HAS_GTK = False
|
||||
|
||||
|
||||
# ── Informations système (mêmes sources que fws-about) ───────────────────────
|
||||
|
||||
def _osrelease():
|
||||
data = {}
|
||||
for path in ("/etc/os-release", "/usr/lib/os-release",
|
||||
"/usr/local/share/fws/os-release"):
|
||||
try:
|
||||
with open(path) as fh:
|
||||
for line in fh:
|
||||
m = re.match(r'^([A-Z_]+)=(.*)$', line.strip())
|
||||
if m:
|
||||
data[m.group(1)] = m.group(2).strip('"')
|
||||
if data:
|
||||
break
|
||||
except OSError:
|
||||
continue
|
||||
return data
|
||||
|
||||
|
||||
def _cmd(*argv):
|
||||
try:
|
||||
return subprocess.check_output(
|
||||
argv, text=True, errors="replace",
|
||||
stderr=subprocess.DEVNULL, timeout=10).strip()
|
||||
except (OSError, subprocess.CalledProcessError, subprocess.TimeoutExpired):
|
||||
return ""
|
||||
|
||||
|
||||
def _cpu():
|
||||
try:
|
||||
with open("/proc/cpuinfo") as fh:
|
||||
for line in fh:
|
||||
if line.startswith("model name"):
|
||||
return line.split(":", 1)[1].strip()
|
||||
except OSError:
|
||||
pass
|
||||
return "inconnu"
|
||||
|
||||
|
||||
def _mem():
|
||||
try:
|
||||
with open("/proc/meminfo") as fh:
|
||||
for line in fh:
|
||||
if line.startswith("MemTotal"):
|
||||
return f"{int(line.split()[1]) / 1048576:.1f} Gio"
|
||||
except OSError:
|
||||
pass
|
||||
return "inconnue"
|
||||
|
||||
|
||||
def _gpus():
|
||||
out = []
|
||||
for line in _cmd("lspci").splitlines():
|
||||
low = line.lower()
|
||||
if "vga" in low or "3d" in low or "display" in low:
|
||||
out.append(line.split(":", 2)[-1].strip())
|
||||
return out or ["inconnu"]
|
||||
|
||||
|
||||
def _disks():
|
||||
out = []
|
||||
for line in _cmd("lsblk", "-dno", "NAME,SIZE,MODEL,TYPE").splitlines():
|
||||
f = line.split()
|
||||
if f and f[-1] == "disk":
|
||||
out.append(" ".join(f[:-1]))
|
||||
return out or ["inconnu"]
|
||||
|
||||
|
||||
def _desktop():
|
||||
if os.environ.get("HYPRLAND_INSTANCE_SIGNATURE"):
|
||||
return "Hyprland"
|
||||
return (os.environ.get("XDG_CURRENT_DESKTOP")
|
||||
or os.environ.get("DESKTOP_SESSION") or "inconnu")
|
||||
|
||||
|
||||
def _session_type():
|
||||
t = os.environ.get("XDG_SESSION_TYPE", "")
|
||||
return {"wayland": "Wayland", "x11": "X11"}.get(t, t or "inconnu")
|
||||
|
||||
|
||||
def _tail(path, max_lines):
|
||||
try:
|
||||
with open(path, errors="replace") as fh:
|
||||
lines = fh.readlines()
|
||||
if len(lines) > max_lines:
|
||||
lines = lines[-max_lines:]
|
||||
return "".join(lines).rstrip()
|
||||
except OSError:
|
||||
return ""
|
||||
|
||||
|
||||
def _system_summary(osr):
|
||||
rows = [
|
||||
("Système", osr.get("PRETTY_NAME") or "FWS Linux"),
|
||||
("Version", osr.get("VERSION_ID") or "inconnue"),
|
||||
("Build", osr.get("BUILD_ID", "rolling")),
|
||||
("Noyau", _cmd("uname", "-r") or "inconnu"),
|
||||
("Bureau", _desktop()),
|
||||
("Affichage", _session_type()),
|
||||
("Processeur", _cpu()),
|
||||
("Mémoire", _mem()),
|
||||
("Carte(s) graphique(s)", " ; ".join(_gpus())),
|
||||
("Disque(s)", " ; ".join(_disks())),
|
||||
]
|
||||
return "\n".join(f"{k}: {v}" for k, v in rows)
|
||||
|
||||
|
||||
def _journal_excerpt(max_lines=200):
|
||||
"""Extrait du journal (avertissements/erreurs) du dernier démarrage.
|
||||
|
||||
Retourne (accessible, texte) : accessible=False si le journal n'a pas pu
|
||||
être lu ; sinon le texte filtré, éventuellement vide si le démarrage ne
|
||||
contenait aucun warning/erreur utile.
|
||||
"""
|
||||
try:
|
||||
out = subprocess.check_output(
|
||||
["journalctl", "-b", "-p", "warning", "--no-pager"],
|
||||
text=True, errors="replace",
|
||||
stderr=subprocess.DEVNULL, timeout=20).strip()
|
||||
except (OSError, subprocess.CalledProcessError, subprocess.TimeoutExpired):
|
||||
return False, ""
|
||||
lines = out.splitlines()
|
||||
# BRUIT DE L'INSTALLATEUR (vu en réel sur bare metal, 2 ISO successives) :
|
||||
# les modules D-Bus d'Anaconda journalisent leur debug SANS marqueur de
|
||||
# priorité exploitable — dumps parted (PedPartition 0x…), rapports JSON LVM,
|
||||
# listing des 42 tâches, sortie mkfs (« Superblock backups stored on… ») —
|
||||
# en INFO/DEBUG journald, donc journalctl -p warning les renvoie quand même,
|
||||
# et un filtre à marqueur INFO:/DEBUG: les laisse passer. Un filtre général
|
||||
# risquerait d'écraser de VRAIS problèmes d'autres services → on cible :
|
||||
# pour les unités org.fedoraproject.Anaconda.* on garde UNIQUEMENT les
|
||||
# messages marqués ERROR:/WARNING: — plus les lignes non marquées d'un
|
||||
# traceback Python toujours signifiantes (« Traceback (most recent call
|
||||
# last): », cadres « File "…", line … » et exception finale, ex.
|
||||
# « FileNotFoundError: [Errno 2] … ») — tout le reste du journal passe
|
||||
# sans toucher.
|
||||
def _jbody(line):
|
||||
m = re.search(r"\[\d+\]: ", line)
|
||||
return line[m.end():] if m else line
|
||||
|
||||
kept = []
|
||||
for ln in lines:
|
||||
if "org.fedoraproject.Anaconda." not in ln:
|
||||
kept.append(ln)
|
||||
continue
|
||||
body = _jbody(ln).lstrip()
|
||||
if (re.search(r"\b(?:ERROR|WARNING):", ln)
|
||||
or body.startswith("Traceback (most recent call last):")
|
||||
or body.startswith('File "')
|
||||
or re.match(r"^\w[\w.]*(?:Error|Exception)\b", body)):
|
||||
kept.append(ln)
|
||||
lines = kept
|
||||
|
||||
# « WARNING:py.warnings:… DeprecationWarning: … » : bruit de développement
|
||||
# de l'installateur (la même ligne est répétée par chacun des ~12 modules
|
||||
# D-Bus d'Anaconda), pas un problème machine — retiré, sauf côté noyau où
|
||||
# un warning resterait significatif.
|
||||
lines = [ln for ln in lines
|
||||
if "DeprecationWarning:" not in ln or re.search(r" kernel: ", ln)]
|
||||
|
||||
# « kernel: ntfs3… » : flot massif émis par le pilote ntfs3 quand
|
||||
# l'installateur SONDE la partition Windows (« Correct links count -> N »
|
||||
# pour des centaines d'inodes, « N callbacks suppressed »). C'est la
|
||||
# correction de liens du système de fichiers Windows pendant la détection
|
||||
# des disques — pas un problème FWS, inexploitable dans un rapport (vu en
|
||||
# réel sur bare metal : des dizaines de lignes). Retiré ; un vrai problème
|
||||
# de disque reste signalé ailleurs (kernel: ata/ahci/nvme…).
|
||||
lines = [ln for ln in lines if " kernel: ntfs3" not in ln]
|
||||
|
||||
# Reliques du build (checkout Windows → fichiers PLATS à la place des
|
||||
# symlinks systemd, corrigées à la source dans build.sh mais présentes
|
||||
# dans les anciennes ISO) : « Failed to preset all unit … already
|
||||
# exists » et « … is not a symlink, ignoring » — bruit sans valeur de
|
||||
# diagnostic.
|
||||
lines = [ln for ln in lines
|
||||
if ("Failed to preset all unit" not in ln
|
||||
and "is not a symlink, ignoring" not in ln
|
||||
and "Wants dependency dropin" not in ln)]
|
||||
|
||||
# « anaconda: kickstart: Command X will be parsed in DBus module. » :
|
||||
# trace de debug du parseur de kickstart, sans information.
|
||||
lines = [ln for ln in lines
|
||||
if "will be parsed in DBus module" not in ln]
|
||||
|
||||
# 1) DÉDUPLICATION GLOBALE (vu en réel sur bare metal) : un service en
|
||||
# échec boucle (xdg-desktop-portal-gtk sans session graphique) et les
|
||||
# modules D-Bus répètent les mêmes warnings — le rapport se noie sous les
|
||||
# doublons. Clé = ligne sans horodatage NI chiffres (« 125 »/« 11 » et
|
||||
# [pids] s'effacent) : les répétitions à variable numérique près se
|
||||
# fusionnent (ex. « fan_curve… (0x110024/25/32) failed » → 1 ligne [×3]),
|
||||
# la 1re occurrence garde sa place, marquée « [×N] » — rien n'est perdu,
|
||||
# le compte reste lisible.
|
||||
_stamp_re = re.compile(r"^[A-Z][a-z]{2} +\d+ +\d\d:\d\d:\d\d +")
|
||||
|
||||
seen = {}
|
||||
order = []
|
||||
out = []
|
||||
for ln in lines:
|
||||
m = _stamp_re.match(ln)
|
||||
key = re.sub(r"\d+", "#", (ln[m.end():] if m else ln).strip())
|
||||
if key in seen:
|
||||
seen[key] += 1
|
||||
continue
|
||||
seen[key] = 1
|
||||
order.append(key)
|
||||
out.append(ln)
|
||||
lines = [ln + (f" [×{seen[k]}]" if seen[k] > 1 else "")
|
||||
for ln, k in zip(out, order)]
|
||||
|
||||
# 2) PLAFOND PAR SOURCE : même uniques, les lignes d'une source en tempête
|
||||
# restent des dizaines (xdg-desktop-portal essaie chaque interface du
|
||||
# portail l'une après l'autre) — au-delà de 8 lignes de la même source, la
|
||||
# suite est omise avec une note explicite. Le noyau n'est pas concerné
|
||||
# (pas de [pid] journald dans ses lignes). L'identifiant journald peut
|
||||
# être un chemin (« /usr/lib/xdg-desktop-portal[856] ») → l'hostname et
|
||||
# l'ident sont séparés par une espace, d'où « \S+ +(.+?)\[pid\] ».
|
||||
def _src(line):
|
||||
m = re.match(r"^[A-Z][a-z]{2} +\d+ +\d\d:\d\d:\d\d +\S+ +(.+?)\[\d+\]: ", line)
|
||||
return m.group(1) if m else None
|
||||
|
||||
capped, counts, omitted = [], {}, {}
|
||||
|
||||
def _note(src, n):
|
||||
return (f" (… +{n} autres lignes de « {src} » omises — "
|
||||
"spam répétitif ; journal complet : journalctl -b -p warning)")
|
||||
|
||||
for ln in lines:
|
||||
src = _src(ln)
|
||||
if src is not None and counts.get(src, 0) >= 8:
|
||||
omitted[src] = omitted.get(src, 0) + 1
|
||||
continue
|
||||
if src is not None:
|
||||
counts[src] = counts.get(src, 0) + 1
|
||||
if omitted.get(src):
|
||||
capped.append(_note(src, omitted[src]))
|
||||
omitted[src] = 0
|
||||
capped.append(ln)
|
||||
for src, n in omitted.items():
|
||||
if n:
|
||||
capped.append(_note(src, n))
|
||||
lines = capped
|
||||
if len(lines) > max_lines:
|
||||
lines = lines[-max_lines:]
|
||||
return True, "\n".join(lines)
|
||||
|
||||
|
||||
def _collect_diagnostics(osr):
|
||||
parts = ["===== Informations système =====", _system_summary(osr)]
|
||||
post_log = "/var/log/fws-post.log"
|
||||
if os.path.isfile(post_log):
|
||||
tail = _tail(post_log, 100)
|
||||
if tail:
|
||||
parts += ["", "===== Log d'installation FWS (fin) =====", tail]
|
||||
journal_ok, journal = _journal_excerpt()
|
||||
if journal:
|
||||
parts += ["", "===== Journal du dernier démarrage "
|
||||
"(avertissements / erreurs) =====", journal]
|
||||
elif journal_ok:
|
||||
# Journal lisible mais rien d'utile après filtrage du bruit : mieux
|
||||
# vaut le dire que d'insinuer que le journal était inaccessible.
|
||||
parts += ["", "===== Journal du dernier démarrage "
|
||||
"(avertissements / erreurs) =====",
|
||||
"(aucune entrée warning/erreur utile dans le journal)"]
|
||||
else:
|
||||
parts += ["", "(journal du dernier démarrage inaccessible — "
|
||||
"lance fws-bugreport depuis un terminal avec sudo "
|
||||
"pour l'inclure)"]
|
||||
return "\n".join(parts)
|
||||
|
||||
|
||||
def _build_payload(osr, typ, title, description, include_diag):
|
||||
description = description.strip()
|
||||
if include_diag:
|
||||
diag = _collect_diagnostics(osr)
|
||||
description = f"{description}\n\n{diag}" if description else diag
|
||||
return {
|
||||
"app": _APP,
|
||||
"version": osr.get("VERSION_ID") or "unknown",
|
||||
"type": typ,
|
||||
"title": title,
|
||||
"description": description,
|
||||
}
|
||||
|
||||
|
||||
# ── Envoi (un seul curl, comme spécifié) ─────────────────────────────────────
|
||||
|
||||
def _trace(lines):
|
||||
try:
|
||||
with open(_LOG_PATH, "a",
|
||||
encoding="utf-8", errors="replace") as fh:
|
||||
fh.write("\n".join(lines) + "\n")
|
||||
except OSError:
|
||||
pass
|
||||
|
||||
|
||||
def _send(payload):
|
||||
data = json.dumps(payload, ensure_ascii=False).encode("utf-8", "replace")
|
||||
# Le corps passe par stdin (--data-binary @-) : pas de limite de taille
|
||||
# d'argument (le journal peut faire des centaines de Ko) et aucun souci
|
||||
# de quoting. -w ajoute le code HTTP en dernière ligne de stdout.
|
||||
try:
|
||||
proc = subprocess.run(
|
||||
["curl", "-sS", "--max-time", "30", "-X", "POST", _URL,
|
||||
"-H", "Content-Type: application/json",
|
||||
"--data-binary", "@-",
|
||||
"-w", "\n%{http_code}"],
|
||||
input=data, capture_output=True, timeout=45)
|
||||
except OSError as exc:
|
||||
_trace([f"[{time.strftime('%Y-%m-%d %H:%M:%S')}] ÉCHEC — "
|
||||
f"curl introuvable : {exc}"])
|
||||
return False, f"curl introuvable : {exc}"
|
||||
except subprocess.TimeoutExpired:
|
||||
_trace([f"[{time.strftime('%Y-%m-%d %H:%M:%S')}] ÉCHEC — délai "
|
||||
"dépassé (30 s)"])
|
||||
return False, "Délai dépassé (30 s) — vérifie ta connexion réseau."
|
||||
|
||||
out = proc.stdout.decode("utf-8", "replace")
|
||||
err = proc.stderr.decode("utf-8", "replace")
|
||||
parts = out.rsplit("\n", 1)
|
||||
body = parts[0] if len(parts) == 2 else out
|
||||
code = parts[-1].strip()
|
||||
|
||||
if proc.returncode != 0:
|
||||
detail = err.strip() or body.strip()
|
||||
_trace([f"[{time.strftime('%Y-%m-%d %H:%M:%S')}] ÉCHEC curl "
|
||||
f"(code {proc.returncode}) : {detail[:300]}"])
|
||||
return False, detail or f"curl a échoué (code {proc.returncode})."
|
||||
|
||||
# Le serveur répond en JSON : {"ok":true,"id":…,"message":…}. Un code
|
||||
# HTTP ≥ 400 ne fait PAS échouer curl — on le détecte ici, sinon l'utilisateur
|
||||
# verrait « envoyé ✔ » alors que rien n'a été enregistré.
|
||||
ok = code.startswith("2")
|
||||
msg = body.strip()
|
||||
rid = ""
|
||||
try:
|
||||
j = json.loads(body)
|
||||
if isinstance(j, dict):
|
||||
ok = bool(j.get("ok")) and code.startswith("2")
|
||||
if j.get("message"):
|
||||
msg = str(j["message"])
|
||||
if j.get("id"):
|
||||
rid = f" (id {j['id']})"
|
||||
except ValueError:
|
||||
pass
|
||||
|
||||
_trace([f"[{time.strftime('%Y-%m-%d %H:%M:%S')}] {_URL} "
|
||||
f"app={payload.get('app')} type={payload.get('type')} "
|
||||
f"titre={payload.get('title')!r} payload={len(data)} o "
|
||||
f"→ HTTP {code or '?'} ok={ok} {msg[:200]}{rid}"])
|
||||
|
||||
if ok:
|
||||
return True, f"HTTP {code or '?'} — {msg}{rid}"
|
||||
return False, (f"HTTP {code or '?'} — {msg or 'réponse vide'}. "
|
||||
"Le serveur a refusé le rapport.")
|
||||
|
||||
|
||||
# ── Assistant console (repli sans X) ─────────────────────────────────────────
|
||||
|
||||
def _tui(preload_path):
|
||||
# Robustesse locale : l'assistant console peut tourner dans une console
|
||||
# non-UTF-8 (Windows…). On force UTF-8 avec remplacement plutôt que de
|
||||
# crasher sur les caractères accentués/boîtes.
|
||||
try:
|
||||
sys.stdout.reconfigure(encoding="utf-8", errors="replace")
|
||||
sys.stdin.reconfigure(encoding="utf-8", errors="replace")
|
||||
except (AttributeError, ValueError, OSError):
|
||||
pass
|
||||
|
||||
def ask(prompt, default=""):
|
||||
try:
|
||||
return input(prompt).strip() or default
|
||||
except EOFError:
|
||||
return default
|
||||
|
||||
print("FWS — « Signaler un problème » (envoi optionnel de logs)")
|
||||
print("Rien ne sera envoyé sans ta confirmation.\n")
|
||||
|
||||
if preload_path:
|
||||
try:
|
||||
with open(preload_path, errors="replace") as fh:
|
||||
description = fh.read().strip()
|
||||
print(f"Logs chargés depuis {preload_path} "
|
||||
f"({len(description)} caractères).")
|
||||
except OSError as exc:
|
||||
print(f" ⚠ Impossible de lire {preload_path} : {exc}")
|
||||
description = ""
|
||||
else:
|
||||
description = ""
|
||||
|
||||
valid_types = [v for v, _l in _TYPES]
|
||||
if not description:
|
||||
print("Type (défaut : bug) : " + ", ".join(valid_types))
|
||||
typ = ask("> ", "bug")
|
||||
if typ not in valid_types:
|
||||
typ = "bug"
|
||||
title = ask("Titre : ")
|
||||
print("Description (ligne vide pour terminer) :")
|
||||
lines = []
|
||||
while True:
|
||||
line = ask("> ")
|
||||
if not line:
|
||||
break
|
||||
lines.append(line)
|
||||
description = "\n".join(lines)
|
||||
else:
|
||||
typ = ask("Type (défaut : bug) : ", "bug")
|
||||
if typ not in valid_types:
|
||||
typ = "bug"
|
||||
title = ask("Titre : ")
|
||||
|
||||
if not title:
|
||||
print(" ⚠ Titre obligatoire — envoi annulé.")
|
||||
return 1
|
||||
|
||||
osr = _osrelease()
|
||||
payload = _build_payload(osr, typ, title, description, include_diag=True)
|
||||
print("\n─── Aperçu de ce qui sera envoyé à", _URL, "───")
|
||||
print(json.dumps(payload, ensure_ascii=False, indent=2))
|
||||
if ask("\nEnvoyer ? [o/N] ", "n").lower() not in ("o", "oui", "y", "yes"):
|
||||
print("Envoi annulé.")
|
||||
return 0
|
||||
ok, msg = _send(payload)
|
||||
print(("✔ " if ok else "✖ ") + msg)
|
||||
if not ok:
|
||||
print(f"Détails : {_LOG_PATH}")
|
||||
return 0 if ok else 1
|
||||
|
||||
|
||||
# ── Fenêtre GTK (uniquement si GTK est disponible) ───────────────────────────
|
||||
|
||||
if _HAS_GTK:
|
||||
def _preview_dialog(parent, payload):
|
||||
dlg = Gtk.Dialog(title="Confirmer l'envoi", transient_for=parent,
|
||||
modal=True, destroy_with_parent=True)
|
||||
dlg.set_default_size(680, 520)
|
||||
dlg.set_position(Gtk.WindowPosition.CENTER)
|
||||
dlg.add_buttons("Annuler", Gtk.ResponseType.CANCEL,
|
||||
"Confirmer l'envoi", Gtk.ResponseType.OK)
|
||||
|
||||
box = dlg.get_content_area()
|
||||
box.set_spacing(10)
|
||||
box.set_border_width(14)
|
||||
|
||||
note = Gtk.Label()
|
||||
note.set_markup(
|
||||
"<b>Voici EXACTEMENT ce qui sera envoyé</b> à "
|
||||
"<span font_family='monospace'>https://fws.laxacube.ch/api/bugs.php</span> :")
|
||||
note.set_line_wrap(True)
|
||||
note.set_xalign(0)
|
||||
box.pack_start(note, False, False, 0)
|
||||
|
||||
scroll = Gtk.ScrolledWindow()
|
||||
scroll.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
|
||||
view = Gtk.TextView()
|
||||
view.set_editable(False)
|
||||
view.set_cursor_visible(False)
|
||||
view.set_monospace(True)
|
||||
view.get_buffer().set_text(
|
||||
json.dumps(payload, ensure_ascii=False, indent=2))
|
||||
scroll.add(view)
|
||||
box.pack_start(scroll, True, True, 0)
|
||||
|
||||
dlg.show_all()
|
||||
response = dlg.run()
|
||||
dlg.destroy()
|
||||
return response == Gtk.ResponseType.OK
|
||||
|
||||
def _message(parent, kind, title, text):
|
||||
msg_type = (Gtk.MessageType.ERROR if kind == "error"
|
||||
else Gtk.MessageType.INFO)
|
||||
dlg = Gtk.MessageDialog(transient_for=parent, modal=True,
|
||||
message_type=msg_type,
|
||||
buttons=Gtk.ButtonsType.CLOSE,
|
||||
text=title)
|
||||
if text:
|
||||
dlg.format_secondary_text(text)
|
||||
dlg.run()
|
||||
dlg.destroy()
|
||||
|
||||
class BugReportWindow(Gtk.Window):
|
||||
def __init__(self, preload_path=None):
|
||||
super().__init__(title="Signaler un problème — FWS")
|
||||
self.set_icon_name("fws-bugreport")
|
||||
self.set_default_size(580, -1)
|
||||
self.set_position(Gtk.WindowPosition.CENTER)
|
||||
self.set_border_width(18)
|
||||
# DIALOGUE : les tuileurs (i3/Hyprland) gardent les dialogues en
|
||||
# flottant → taille naturelle au lieu d'être étirée.
|
||||
self.set_type_hint(Gdk.WindowTypeHint.DIALOG)
|
||||
self.set_resizable(False)
|
||||
self.connect("destroy", Gtk.main_quit)
|
||||
|
||||
self._osr = _osrelease()
|
||||
|
||||
box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=10)
|
||||
self.add(box)
|
||||
|
||||
title = Gtk.Label()
|
||||
title.set_markup(
|
||||
"<span size='x-large' weight='bold'>Signaler un problème</span>")
|
||||
box.pack_start(title, False, False, 0)
|
||||
|
||||
subtitle = Gtk.Label(
|
||||
label="Un souci avec FWS ? Décris-le ci-dessous. Les informations "
|
||||
"système et les logs de diagnostic peuvent être joints pour "
|
||||
"aider les développeurs. Rien ne part sans ta confirmation.")
|
||||
subtitle.set_line_wrap(True)
|
||||
subtitle.set_xalign(0)
|
||||
box.pack_start(subtitle, False, False, 0)
|
||||
|
||||
grid = Gtk.Grid(column_spacing=10, row_spacing=8)
|
||||
grid.set_halign(Gtk.Align.FILL)
|
||||
|
||||
grid.attach(Gtk.Label(label="Type :", xalign=1), 0, 0, 1, 1)
|
||||
self._type = Gtk.ComboBoxText()
|
||||
for value, label in _TYPES:
|
||||
self._type.append(value, label)
|
||||
self._type.set_active(0)
|
||||
grid.attach(self._type, 1, 0, 1, 1)
|
||||
|
||||
grid.attach(Gtk.Label(label="Titre :", xalign=1), 0, 1, 1, 1)
|
||||
self._title = Gtk.Entry()
|
||||
self._title.set_placeholder_text("Résumé court du problème")
|
||||
grid.attach(self._title, 1, 1, 1, 1)
|
||||
|
||||
box.pack_start(grid, False, False, 0)
|
||||
|
||||
desc_label = Gtk.Label(label="Description :", xalign=0)
|
||||
box.pack_start(desc_label, False, False, 0)
|
||||
scroll = Gtk.ScrolledWindow()
|
||||
scroll.set_min_content_height(130)
|
||||
scroll.set_policy(Gtk.PolicyType.NEVER, Gtk.PolicyType.AUTOMATIC)
|
||||
self._description = Gtk.TextView()
|
||||
self._description.set_wrap_mode(Gtk.WrapMode.WORD)
|
||||
self._description.set_placeholder_text(
|
||||
"Ce qui s'est passé, ce que tu attendais, ce que tu as essayé…")
|
||||
scroll.add(self._description)
|
||||
box.pack_start(scroll, False, False, 0)
|
||||
|
||||
if preload_path:
|
||||
try:
|
||||
with open(preload_path, errors="replace") as fh:
|
||||
content = fh.read()
|
||||
self._description.get_buffer().set_text(content)
|
||||
loaded = Gtk.Label()
|
||||
loaded.set_markup(
|
||||
f"<span size='small' foreground='#89b4fa'>Logs chargés "
|
||||
f"depuis <span font_family='monospace'>{preload_path}"
|
||||
f"</span> — tu peux les compléter ou les retirer.</span>")
|
||||
loaded.set_line_wrap(True)
|
||||
loaded.set_xalign(0)
|
||||
box.pack_start(loaded, False, False, 0)
|
||||
except OSError as exc:
|
||||
_message(self, "error", "Fichier illisible",
|
||||
f"{preload_path} : {exc}")
|
||||
|
||||
self._include = Gtk.CheckButton(
|
||||
label="Joindre les informations système et les logs de diagnostic")
|
||||
self._include.set_active(True)
|
||||
self._include.set_tooltip_text(
|
||||
"Version FWS, matériel détecté, extrait du journal du dernier "
|
||||
"démarrage — à relire dans l'aperçu avant l'envoi")
|
||||
box.pack_start(self._include, False, False, 4)
|
||||
|
||||
footer = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL, spacing=8)
|
||||
cancel = Gtk.Button(label="Fermer")
|
||||
cancel.connect("clicked", lambda _b: self.close())
|
||||
send = Gtk.Button(label="Envoyer…")
|
||||
send.get_style_context().add_class("suggested-action")
|
||||
send.connect("clicked", self._on_send)
|
||||
footer.pack_end(send, False, False, 0)
|
||||
footer.pack_end(cancel, False, False, 0)
|
||||
box.pack_start(footer, False, False, 6)
|
||||
|
||||
self._title.connect("activate", self._on_send)
|
||||
|
||||
def _on_send(self, _widget=None):
|
||||
# Un crash ne doit JAMAIS mourir en silence (le lancement depuis
|
||||
# l'écran de debug du live redirige stderr vers /dev/null) : on
|
||||
# trace et on affiche.
|
||||
try:
|
||||
self._do_send()
|
||||
except Exception as exc: # noqa: BLE001
|
||||
_trace(["=== CRASH fws-bugreport ===",
|
||||
traceback.format_exc()])
|
||||
_message(self, "error", "Erreur inattendue",
|
||||
f"{exc}\n\nDétails : {_LOG_PATH}")
|
||||
|
||||
def _do_send(self):
|
||||
title = self._title.get_text().strip()
|
||||
buf = self._description.get_buffer()
|
||||
description = buf.get_text(buf.get_start_iter(),
|
||||
buf.get_end_iter(), True).strip()
|
||||
include = self._include.get_active()
|
||||
if not title:
|
||||
_message(self, "error", "Titre manquant",
|
||||
"Indique un titre court pour le problème.")
|
||||
return
|
||||
if not description and not include:
|
||||
_message(self, "error", "Rapport vide",
|
||||
"Écris une description ou coche la jointure des "
|
||||
"informations système et des logs.")
|
||||
return
|
||||
|
||||
typ = self._type.get_active_id() or "bug"
|
||||
payload = _build_payload(self._osr, typ, title, description, include)
|
||||
if not _preview_dialog(self, payload):
|
||||
return
|
||||
ok, msg = _send(payload)
|
||||
if ok:
|
||||
_message(self, "info", "Rapport envoyé ✔",
|
||||
f"{msg}\n\nMerci ! L'équipe FWS a reçu ton rapport.\n"
|
||||
f"(trace : {_LOG_PATH})")
|
||||
else:
|
||||
_message(self, "error", "Envoi impossible",
|
||||
f"{msg}\n\nTon rapport n'a pas été envoyé. Vérifie ta "
|
||||
f"connexion et réessaie.\nDétails : {_LOG_PATH}")
|
||||
|
||||
|
||||
def main():
|
||||
args = sys.argv[1:]
|
||||
preload = None
|
||||
if "--file" in args:
|
||||
i = args.index("--file")
|
||||
if i + 1 < len(args):
|
||||
preload = args[i + 1]
|
||||
if _HAS_GTK and "--tui" not in args and Gtk.init_check()[0]:
|
||||
GLib.set_prgname("fws-bugreport")
|
||||
win = BugReportWindow(preload)
|
||||
win.show_all()
|
||||
Gtk.main()
|
||||
return 0
|
||||
return _tui(preload)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
raise SystemExit(main())
|
||||
Executable
+42
@@ -0,0 +1,42 @@
|
||||
#!/bin/bash
|
||||
# Généré par l'installateur FWS — (ré)installe le bureau « hyprland ».
|
||||
# Usage : fws-desktop-retry [--auto] (--auto = relancé par le service au 1er démarrage)
|
||||
set -u
|
||||
[ "$(id -u)" -eq 0 ] || exec sudo "$0" "$@"
|
||||
AUTO=""
|
||||
[ "${1:-}" = "--auto" ] && AUTO=1
|
||||
if [ -n "$AUTO" ]; then
|
||||
wall "FWS : installation du bureau « hyprland » en cours… ne coupez pas l'alimentation." 2>/dev/null || true
|
||||
fi
|
||||
echo "==> Installation du bureau hyprland…"
|
||||
# Keyring pacman : s'il est périmé, -Sy échoue alors que le réseau va bien
|
||||
# (typique d'un système fraîchement installé depuis une image).
|
||||
pacman-key --init &>/dev/null || true
|
||||
pacman-key --populate archlinux &>/dev/null || true
|
||||
# Attente du réseau (DNS) : au 1er démarrage, NetworkManager peut mettre
|
||||
# ~30 s à monter la connexion.
|
||||
for _i in 1 2 3 4 5 6 7 8 9 10; do
|
||||
getent hosts geo.mirror.pkgbuild.com >/dev/null 2>&1 && break
|
||||
sleep 3
|
||||
done
|
||||
# Synchro + filtre : un paquet renommé/absent ne doit pas faire échouer TOUT
|
||||
# le bureau (même approche que fws-setup-hardware pour la stack matérielle).
|
||||
pacman -Syy --noconfirm || { echo "Échec de la synchro (réseau ?) — réessayez."; exit 1; }
|
||||
_FILTERED=""
|
||||
for _p in hyprland kitty wofi waybar sddm noto-fonts dolphin kio-extras udisks2 hyprlock grim slurp wl-clipboard playerctl mako libnotify polkit-gnome network-manager-applet xdg-desktop-portal-hyprland ttf-nerd-fonts-symbols pipewire pipewire-alsa pipewire-pulse wireplumber pavucontrol bluez bluez-utils blueman firefox python-gobject pacman-contrib; do
|
||||
pacman -Si "$_p" >/dev/null 2>&1 && _FILTERED="$_FILTERED $_p"
|
||||
done
|
||||
PKGS="${_FILTERED# }"
|
||||
[ -n "$PKGS" ] || { echo "Aucun paquet du bureau hyprland trouvé dans les dépôts — réessayez plus tard."; exit 1; }
|
||||
pacman -S --noconfirm --needed $PKGS || { echo "Échec (réseau ?) — réessayez."; exit 1; }
|
||||
[ -n "sddm" ] && systemctl enable "sddm"
|
||||
systemctl set-default graphical.target
|
||||
rm -f /var/lib/fws/desktop-failed
|
||||
[ -f /etc/motd ] && grep -q fws-desktop-retry /etc/motd && rm -f /etc/motd
|
||||
echo "==> Bureau installé ✔"
|
||||
if [ -n "$AUTO" ]; then
|
||||
echo "==> Passage sur l'écran de connexion…"
|
||||
systemctl isolate graphical.target || true
|
||||
else
|
||||
echo "==> Redémarrez (reboot) pour arriver sur l'écran de connexion."
|
||||
fi
|
||||
Executable
+166
@@ -0,0 +1,166 @@
|
||||
#!/bin/bash
|
||||
# ============================================================
|
||||
# FWS — fws-grub-finalize : verrouille le bootloader au 1er démarrage.
|
||||
#
|
||||
# POURQUOI : sur du vrai matériel (bare-metal UEFI — cartes mères ASUS et
|
||||
# autres), l'installation peut se terminer sans que GRUB soit inscrit dans la
|
||||
# NVRAM, ou sans que Windows soit détecté (os-prober désactivé / partitions
|
||||
# pas visibles pendant l'install). Résultats vus en conditions réelles :
|
||||
# « le PC redémarre sur Windows », ou « GRUB s'ouvre mais le menu est vide ».
|
||||
#
|
||||
# Ce service tourne au premier démarrage du système installé (marqueur
|
||||
# /var/lib/fws/grub-finalize-done posé seulement en cas de SUCCÈS, le service
|
||||
# ne se relance donc pas ensuite). À ce moment-là, contrairement au chroot de
|
||||
# l'installateur :
|
||||
# - /sys/firmware/efi/efivars est accessible → l'entrée NVRAM « FWS »
|
||||
# (efibootmgr) PEUT être créée/rafraîchie,
|
||||
# - tous les disques sont présents → os-prober retrouve Windows (et tout
|
||||
# autre OS) sur les autres disques/partitions,
|
||||
# - le chemin de secours EFI/BOOT/BOOTX64.EFI (--removable) est (re)posé :
|
||||
# les firmwares récalcitrants (ASUS…) bootent quand même dessus.
|
||||
#
|
||||
# Journal : /var/log/fws-grub-finalize.log
|
||||
# ============================================================
|
||||
set -u
|
||||
LOG=/var/log/fws-grub-finalize.log
|
||||
DONE=/var/lib/fws/grub-finalize-done
|
||||
|
||||
# Déjà finalisé → ne rien faire (le service a une ConditionPathExists=…, on se
|
||||
# protège aussi d'un lancement manuel).
|
||||
[ -e "$DONE" ] && exit 0
|
||||
|
||||
mkdir -p /var/lib/fws
|
||||
exec >>"$LOG" 2>&1
|
||||
echo "== fws-grub-finalize : $(date '+%F %T')"
|
||||
|
||||
# Laisse udev finir d'énumérer les disques (os-prober a besoin de tout voir).
|
||||
udevadm settle --timeout=30 2>/dev/null || true
|
||||
|
||||
# os-prober doit être présent et ACTIF (par défaut sur Arch : désactivé → les
|
||||
# autres OS n'apparaissent jamais au menu). Les paquets sont normalement dans
|
||||
# l'image installée (os-prober + ntfs-3g listés dans packages.x86_64) ; on
|
||||
# tente un install de secours sans bloquer si pas de réseau.
|
||||
if command -v os-prober >/dev/null 2>&1; then
|
||||
if grep -q '^GRUB_DISABLE_OS_PROBER=' /etc/default/grub 2>/dev/null; then
|
||||
sed -i 's/^GRUB_DISABLE_OS_PROBER=.*/GRUB_DISABLE_OS_PROBER=false/' /etc/default/grub
|
||||
else
|
||||
echo 'GRUB_DISABLE_OS_PROBER=false' >> /etc/default/grub
|
||||
fi
|
||||
else
|
||||
pacman -S --noconfirm --needed os-prober ntfs-3g >/dev/null 2>&1 || \
|
||||
echo "[FWS] os-prober indisponible — Windows ne sera pas détecté au menu GRUB"
|
||||
fi
|
||||
|
||||
# Première partition ESP (vfat + type de partition EFI), optionnellement
|
||||
# limitée à un disque donné.
|
||||
#
|
||||
# ⚠ NE PAS revenir à « lsblk -nro PATH,PARTTYPENAME,FSTYPE | awk '$2=="EFI
|
||||
# System" …' » : « lsblk -r » sépare les colonnes par des ESPACES et le
|
||||
# libellé d'une ESP est littéralement « EFI System » — avec une espace. awk
|
||||
# voyait $2="EFI" et $3="System", le test n'était JAMAIS vrai, aucune ESP
|
||||
# n'était trouvée et GRUB n'était donc jamais posé en UEFI (ni ici, ni dans
|
||||
# le %post du kickstart qui portait le même bug).
|
||||
# On lit PARTTYPE (un CODE : GUID en GPT, 0xef en MBR — jamais d'espace) et on
|
||||
# interroge chaque partition séparément : une valeur par appel, donc aucun
|
||||
# décalage de colonnes même si un champ est vide.
|
||||
find_esp() {
|
||||
_disk="${1:-}"
|
||||
lsblk -nrpo NAME,FSTYPE $_disk 2>/dev/null | awk '$2=="vfat"{print $1}' \
|
||||
| while read -r _part; do
|
||||
_ptype="$(lsblk -nrdo PARTTYPE "$_part" 2>/dev/null | tr 'A-Z' 'a-z')"
|
||||
case "$_ptype" in
|
||||
c12a7328-f81f-11d2-ba4b-00a0c93ec93b|0xef) printf '%s\n' "$_part" ;;
|
||||
esac
|
||||
done | head -n1
|
||||
}
|
||||
|
||||
# --- UEFI : installer GRUB sur une ESP ---------------------------------------
|
||||
# Règle : on préfère une ESP PORTÉE PAR LE MÊME DISQUE que « / » (installation
|
||||
# FWS typique : /boot/efi déjà dans le fstab). Si l'installation a réutilisé
|
||||
# l'ESP d'un autre OS (cas dual-boot vu en réel : ESP Windows sur le 1er
|
||||
# disque), on retombe sur la première ESP FAT32 trouvée.
|
||||
OK=1
|
||||
if [ -d /sys/firmware/efi ]; then
|
||||
esp=""
|
||||
if ! mountpoint -q /boot/efi; then
|
||||
# /boot/efi pas monté (ou pas dans le fstab) : on cherche.
|
||||
rootsrc="$(findmnt -no SOURCE / 2>/dev/null)"
|
||||
rootdisk="$(lsblk -spno NAME,TYPE "$rootsrc" 2>/dev/null | awk '$2=="disk"{print $1; exit}')"
|
||||
if [ -n "$rootdisk" ]; then
|
||||
esp="$(find_esp "$rootdisk")"
|
||||
fi
|
||||
# Repli : première ESP du système (ex. ESP Windows réutilisée).
|
||||
[ -n "$esp" ] || esp="$(find_esp)"
|
||||
if [ -n "$esp" ]; then
|
||||
echo "[FWS] ESP : $esp → montage sur /boot/efi (ne pas démonter, reboot ensuite)"
|
||||
mkdir -p /boot/efi
|
||||
mount "$esp" /boot/efi 2>/dev/null || echo "[FWS] montage ESP impossible ($esp)"
|
||||
else
|
||||
echo "[FWS] aucune partition EFI trouvée sur ce système"
|
||||
fi
|
||||
fi
|
||||
|
||||
if mountpoint -q /boot/efi || [ -d /boot/efi/EFI ]; then
|
||||
# (a) Entrée NVRAM « FWS » + fichiers EFI/FWS (best effort : grub-install
|
||||
# crée lui-même l'entrée si efivars est accessible) :
|
||||
grub-install --target=x86_64-efi --efi-directory=/boot/efi \
|
||||
--bootloader-id=FWS --recheck || echo "[FWS] grub-install (NVRAM) : échec, ignoré"
|
||||
# (b) Chemin de SECOURS EFI/BOOT/BOOTX64.EFI (--removable) : boote SANS
|
||||
# aucune entrée NVRAM. INDISPENSABLE sur firmware qui « oublie »
|
||||
# l'entrée (ASUS…) — c'est lui qui garantit le 1er boot.
|
||||
if ! grub-install --target=x86_64-efi --efi-directory=/boot/efi \
|
||||
--bootloader-id=FWS --removable --recheck; then
|
||||
OK=0
|
||||
fi
|
||||
# Copie physique de secours si --removable n'a pas produit le fichier.
|
||||
if [ ! -f /boot/efi/EFI/BOOT/BOOTX64.EFI ] \
|
||||
&& [ -f /boot/efi/EFI/FWS/grubx64.efi ]; then
|
||||
mkdir -p /boot/efi/EFI/BOOT
|
||||
cp -f /boot/efi/EFI/FWS/grubx64.efi /boot/efi/EFI/BOOT/BOOTX64.EFI \
|
||||
&& echo "[FWS] BOOTX64.EFI copié depuis EFI/FWS" || OK=0
|
||||
fi
|
||||
# (c) Rafraîchir l'entrée NVRAM si elle manque (efibootmgr). GRUB booté
|
||||
# a déjà créé « FWS » ; on ne duplique pas si l'entrée existe.
|
||||
if command -v efibootmgr >/dev/null 2>&1 \
|
||||
&& [ -d /sys/firmware/efi/efivars ]; then
|
||||
espdev="$(findmnt -no SOURCE /boot/efi 2>/dev/null)"
|
||||
if [ -n "$espdev" ]; then
|
||||
disk="$(lsblk -spno NAME,TYPE "$espdev" | awk '$2=="disk"{print $1; exit}')"
|
||||
part="$(printf '%s' "$espdev" | grep -oE '[0-9]+$')"
|
||||
if ! efibootmgr 2>/dev/null | grep -qi 'FWS'; then
|
||||
efibootmgr -c -d "${disk:-/dev/null}" -p "${part:-1}" \
|
||||
-L "FWS" -l '\EFI\FWS\grubx64.efi' >/dev/null 2>&1 \
|
||||
&& echo "[FWS] entrée NVRAM FWS créée" || \
|
||||
echo "[FWS] NVRAM non modifiable — le chemin --removable suffit"
|
||||
else
|
||||
echo "[FWS] entrée NVRAM FWS déjà présente"
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
else
|
||||
echo "[FWS] aucune ESP montée sur /boot/efi — grub-install UEFI impossible ici"
|
||||
OK=0
|
||||
fi
|
||||
else
|
||||
# --- BIOS/CSM : GRUB dans le MBR du disque portant « / » ---------------
|
||||
rootsrc="$(findmnt -no SOURCE / 2>/dev/null)"
|
||||
disk="$(lsblk -spno NAME,TYPE "$rootsrc" 2>/dev/null \
|
||||
| awk '$2=="disk"{print $1; exit}' | grep -oE '/dev/[a-z0-9]+')"
|
||||
if [ -n "$disk" ]; then
|
||||
grub-install --target=i386-pc --recheck "$disk" || OK=0
|
||||
else
|
||||
echo "[FWS] disque BIOS introuvable"
|
||||
OK=0
|
||||
fi
|
||||
fi
|
||||
|
||||
# Régénère le menu COMPLET (FWS + recovery + Windows/autres OS via os-prober).
|
||||
if grub-mkconfig -o /boot/grub/grub.cfg; then
|
||||
if grep -q 'menuentry' /boot/grub/grub.cfg; then
|
||||
touch "$DONE"
|
||||
echo "[FWS] GRUB finalisé : entrées NVRAM + menu OK ($(date '+%T'))"
|
||||
exit 0
|
||||
fi
|
||||
fi
|
||||
echo "[FWS] grub.cfg absent/vide — nouvel essai au prochain démarrage"
|
||||
exit 1
|
||||
Executable
+158
@@ -0,0 +1,158 @@
|
||||
#!/usr/bin/env python3
|
||||
# FWS — fenêtre de bienvenue au premier démarrage (pendant post-install de la
|
||||
# page récap de l'installateur). Boutons : mise à jour, codecs, VR, raccourcis,
|
||||
# Proton-GE. GTK3 : présent sur TOUS les bureaux FWS (Firefox le tire) ;
|
||||
# python-gobject est installé avec le bureau par le kickstart.
|
||||
#
|
||||
# Lancement : /etc/xdg/autostart (KDE/GNOME/XFCE) et exec des configs
|
||||
# Hyprland/i3, toujours avec --autostart : on se retire sans bruit si
|
||||
# l'utilisateur a coché « ne plus afficher » (~/.config/fws/hello-done).
|
||||
|
||||
import os
|
||||
import shutil
|
||||
import subprocess
|
||||
import sys
|
||||
|
||||
import gi
|
||||
|
||||
gi.require_version("Gtk", "3.0")
|
||||
gi.require_version("Gdk", "3.0") # sinon gi charge Gdk 4.0 (conflit avec Gtk3)
|
||||
from gi.repository import Gdk, GLib, Gtk # noqa: E402
|
||||
|
||||
# WM_CLASS déterministe : les règles i3/Hyprland « fenêtre flottante »
|
||||
# ciblent cette classe.
|
||||
GLib.set_prgname("fws-hello")
|
||||
|
||||
_FLAG = os.path.expanduser("~/.config/fws/hello-done")
|
||||
|
||||
_CODECS = ("gst-plugins-base gst-plugins-good gst-plugins-bad "
|
||||
"gst-plugins-ugly gst-libav ffmpeg mpv")
|
||||
|
||||
# (libellé, description, commande, en_terminal)
|
||||
_ACTIONS = [
|
||||
("Mettre à jour le système",
|
||||
"pacman -Syu + nettoyage du cache",
|
||||
"fws-update", True),
|
||||
("Installer les codecs multimédia",
|
||||
"lecture vidéo/audio (GStreamer, ffmpeg, mpv)",
|
||||
f"sudo pacman -S --needed {_CODECS}", True),
|
||||
("Proton-GE pour Steam",
|
||||
"meilleure compatibilité des jeux Windows",
|
||||
"fws-proton-ge", True),
|
||||
("Configurer la VR",
|
||||
"drivers casque : HTC Vive, Index, Quest…",
|
||||
"fws-vr-setup", True),
|
||||
]
|
||||
|
||||
_TERMINALS = ["kitty", "konsole", "gnome-terminal", "xfce4-terminal", "xterm"]
|
||||
|
||||
|
||||
def _terminal():
|
||||
for term in _TERMINALS:
|
||||
if shutil.which(term):
|
||||
return term
|
||||
return None
|
||||
|
||||
|
||||
def _run(command, in_terminal):
|
||||
if in_terminal:
|
||||
term = _terminal()
|
||||
if term is None:
|
||||
return
|
||||
if term == "gnome-terminal":
|
||||
argv = [term, "--", "sh", "-c", command]
|
||||
else:
|
||||
argv = [term, "-e", "sh", "-c", command]
|
||||
else:
|
||||
argv = ["sh", "-c", command]
|
||||
subprocess.Popen(argv) # noqa: S603 — commandes internes FWS
|
||||
|
||||
|
||||
class HelloWindow(Gtk.Window):
|
||||
def __init__(self):
|
||||
super().__init__(title="Bienvenue sur FWS")
|
||||
self.set_default_size(460, -1)
|
||||
self.set_position(Gtk.WindowPosition.CENTER)
|
||||
self.set_border_width(18)
|
||||
# DIALOGUE : les tuileurs (i3/Hyprland) laissent les dialogues en
|
||||
# flottant → la fenêtre garde sa taille naturelle au lieu d'être
|
||||
# étirée sur tout l'espace de travail (layout illisible sinon).
|
||||
self.set_type_hint(Gdk.WindowTypeHint.DIALOG)
|
||||
self.set_resizable(False)
|
||||
|
||||
box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=12)
|
||||
self.add(box)
|
||||
|
||||
title = Gtk.Label()
|
||||
title.set_markup("<span size='x-large' weight='bold'>Bienvenue sur FWS !</span>")
|
||||
box.pack_start(title, False, False, 0)
|
||||
|
||||
subtitle = Gtk.Label(
|
||||
label="Ton système est prêt. Quelques réglages utiles pour bien démarrer :")
|
||||
subtitle.set_line_wrap(True)
|
||||
subtitle.set_xalign(0)
|
||||
box.pack_start(subtitle, False, False, 0)
|
||||
|
||||
actions = list(_ACTIONS)
|
||||
# Raccourcis clavier : uniquement sur les sessions qui ont fws-keys
|
||||
# (Hyprland/i3) — les autres bureaux ont leurs propres réglages.
|
||||
session = os.environ.get("XDG_CURRENT_DESKTOP", "").lower()
|
||||
if os.environ.get("HYPRLAND_INSTANCE_SIGNATURE") or "i3" in session:
|
||||
actions.append(("Voir les raccourcis clavier",
|
||||
"aussi disponible à tout moment : Super+K",
|
||||
"fws-keys", False))
|
||||
|
||||
for label, desc, command, in_term in actions:
|
||||
button = Gtk.Button()
|
||||
inner = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=2)
|
||||
lab = Gtk.Label()
|
||||
lab.set_markup(f"<b>{label}</b>")
|
||||
lab.set_xalign(0)
|
||||
sub = Gtk.Label(label=desc)
|
||||
sub.set_xalign(0)
|
||||
sub.get_style_context().add_class("dim-label")
|
||||
inner.pack_start(lab, False, False, 0)
|
||||
inner.pack_start(sub, False, False, 0)
|
||||
button.add(inner)
|
||||
button.connect("clicked",
|
||||
lambda _b, c=command, t=in_term: _run(c, t))
|
||||
box.pack_start(button, False, False, 0)
|
||||
|
||||
self._again = Gtk.CheckButton(label="Afficher cette fenêtre au prochain démarrage")
|
||||
self._again.set_active(False)
|
||||
box.pack_start(self._again, False, False, 6)
|
||||
|
||||
close = Gtk.Button(label="Fermer")
|
||||
close.connect("clicked", lambda _b: self.close())
|
||||
box.pack_start(close, False, False, 0)
|
||||
|
||||
self.connect("destroy", self._on_destroy)
|
||||
|
||||
def _on_destroy(self, _win):
|
||||
if not self._again.get_active():
|
||||
os.makedirs(os.path.dirname(_FLAG), exist_ok=True)
|
||||
with open(_FLAG, "w") as fh:
|
||||
fh.write("ok\n")
|
||||
else:
|
||||
try:
|
||||
os.unlink(_FLAG)
|
||||
except OSError:
|
||||
pass
|
||||
Gtk.main_quit()
|
||||
|
||||
|
||||
def main():
|
||||
if "--autostart" in sys.argv and os.path.exists(_FLAG):
|
||||
return 0
|
||||
# Pas d'affichage joignable (lancement hors session graphique) : on se
|
||||
# retire sans traceback plutôt que de crasher.
|
||||
if not Gtk.init_check()[0]:
|
||||
return 1
|
||||
win = HelloWindow()
|
||||
win.show_all()
|
||||
Gtk.main()
|
||||
return 0
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
sys.exit(main())
|
||||
Executable
+18
@@ -0,0 +1,18 @@
|
||||
#!/bin/sh
|
||||
if systemd-detect-virt --quiet 2>/dev/null; then
|
||||
# GPU virtuel (VMware vmwgfx…) : on FORCE le chemin d'affichage 100% logiciel.
|
||||
# La PIÈCE MAÎTRESSE est MESA_LOADER_DRIVER_OVERRIDE=kms_swrast : elle force
|
||||
# Mesa à allouer le GBM/EGL via kms_swrast (rendu logiciel dans les « dumb
|
||||
# buffers » KMS) AU LIEU du pilote vmwgfx (qui ne fournit pas le GBM dont
|
||||
# aquamarine a besoin → « CBackend::create() failed »). + llvmpipe pour le GL.
|
||||
export MESA_LOADER_DRIVER_OVERRIDE=kms_swrast
|
||||
export GALLIUM_DRIVER=llvmpipe LIBGL_ALWAYS_SOFTWARE=1
|
||||
export WLR_RENDERER_ALLOW_SOFTWARE=1 WLR_NO_HARDWARE_CURSORS=1
|
||||
export AQ_NO_ATOMIC=1
|
||||
fi
|
||||
# Hyprland ≥ 0.53 : start-hyprland est le lanceur officiel (prépare la
|
||||
# session/env systemd) — sans lui, bandeau « started without start-hyprland ».
|
||||
if command -v start-hyprland >/dev/null 2>&1; then
|
||||
exec start-hyprland "$@"
|
||||
fi
|
||||
exec Hyprland "$@"
|
||||
Executable
+129
@@ -0,0 +1,129 @@
|
||||
#!/usr/bin/env python3
|
||||
# FWS — affiche les raccourcis clavier RÉELS de la session (bouton ⌨ de la
|
||||
# barre ou Super+K). Universel :
|
||||
# • Hyprland : « hyprctl binds -j » = les binds effectivement chargés
|
||||
# (descriptions des bindd) — affichage wofi (Wayland).
|
||||
# • i3 : parse ~/.config/i3/config (bindsym, variables résolues)
|
||||
# — affichage rofi (X11).
|
||||
# Aucune dépendance hors python3 + wofi/rofi (déjà installés avec le bureau).
|
||||
|
||||
import json
|
||||
import os
|
||||
import re
|
||||
import subprocess
|
||||
import sys
|
||||
|
||||
_WOFI_STYLE = "/usr/local/share/fws/wofi-keys.css"
|
||||
|
||||
# Bits de modmask Hyprland (masques X11) dans l'ordre d'affichage voulu.
|
||||
_MODS = [(64, "SUPER"), (4, "CTRL"), (8, "ALT"), (1, "SHIFT")]
|
||||
|
||||
_KEY_LABELS = {
|
||||
"mouse:272": "clic gauche",
|
||||
"mouse:273": "clic droit",
|
||||
"mouse:274": "clic molette",
|
||||
"mouse_down": "molette bas",
|
||||
"mouse_up": "molette haut",
|
||||
"button4": "molette haut",
|
||||
"button5": "molette bas",
|
||||
"return": "Entrée",
|
||||
"space": "Espace",
|
||||
"escape": "Échap",
|
||||
"tab": "Tab",
|
||||
"left": "←",
|
||||
"right": "→",
|
||||
"up": "↑",
|
||||
"down": "↓",
|
||||
"print": "Impr écran",
|
||||
}
|
||||
|
||||
|
||||
def _label(key):
|
||||
return _KEY_LABELS.get(key.lower(), key)
|
||||
|
||||
|
||||
# --- Hyprland : binds réels via hyprctl ------------------------------------
|
||||
def hyprland_lines():
|
||||
raw = subprocess.check_output(["hyprctl", "binds", "-j"], text=True)
|
||||
lines, seen = [], set()
|
||||
for bind in json.loads(raw):
|
||||
parts = [name for bit, name in _MODS if bind.get("modmask", 0) & bit]
|
||||
key = bind.get("key") or (f"code {bind['keycode']}" if bind.get("keycode") else "")
|
||||
parts.append(_label(key))
|
||||
combo = " + ".join(p for p in parts if p)
|
||||
if not combo or combo in seen:
|
||||
continue
|
||||
seen.add(combo)
|
||||
desc = (bind.get("description") or "").strip() \
|
||||
or f"{bind.get('dispatcher', '?')} {(bind.get('arg') or '').strip()}".strip()
|
||||
lines.append(f"{combo:<24} {desc}")
|
||||
return lines
|
||||
|
||||
|
||||
# --- i3 : parse de la config (variables résolues) ----------------------------
|
||||
def i3_lines():
|
||||
path = os.path.expanduser("~/.config/i3/config")
|
||||
variables = {}
|
||||
lines, seen = [], set()
|
||||
with open(path, encoding="utf-8", errors="replace") as fh:
|
||||
content = fh.readlines()
|
||||
for line in content:
|
||||
m = re.match(r"\s*set\s+(\$\S+)\s+(.+)$", line)
|
||||
if m:
|
||||
variables[m.group(1)] = m.group(2).strip()
|
||||
def resolve(text):
|
||||
# $var les plus longs d'abord ($filemanager avant $file…).
|
||||
for var in sorted(variables, key=len, reverse=True):
|
||||
text = text.replace(var, variables[var])
|
||||
return text
|
||||
for line in content:
|
||||
m = re.match(r"\s*bindsym\s+(?:--\S+\s+)*(\S+)\s+(.+)$", line)
|
||||
if not m:
|
||||
continue
|
||||
combo_raw, action = m.groups()
|
||||
combo_raw = resolve(combo_raw).replace("Mod4", "Super").replace("Mod1", "Alt")
|
||||
combo = " + ".join(_label(k) for k in combo_raw.split("+"))
|
||||
if combo in seen:
|
||||
continue
|
||||
seen.add(combo)
|
||||
action = resolve(action)
|
||||
action = re.sub(r"^exec\s+(--no-startup-id\s+)?", "", action).strip().strip('"')
|
||||
lines.append(f"{combo:<24} {action}")
|
||||
return lines
|
||||
|
||||
|
||||
def show(lines):
|
||||
if not lines:
|
||||
lines = ["(aucun raccourci trouvé)"]
|
||||
text = "\n".join(lines)
|
||||
if os.environ.get("HYPRLAND_INSTANCE_SIGNATURE"):
|
||||
cmd = ["wofi", "--dmenu", "--prompt", "Raccourcis clavier — taper pour filtrer",
|
||||
"--width", "820", "--height", "600", "--insensitive",
|
||||
"--cache-file", "/dev/null"]
|
||||
if os.path.exists(_WOFI_STYLE):
|
||||
cmd += ["--style", _WOFI_STYLE]
|
||||
else:
|
||||
# X11/i3 : rofi en dmenu, style assorti (mono pour l'alignement).
|
||||
cmd = ["rofi", "-dmenu", "-i", "-p", "Raccourcis clavier",
|
||||
"-no-custom",
|
||||
"-theme-str", 'window { width: 880px; } listview { lines: 18; }',
|
||||
"-theme-str", '* { font: "Noto Sans Mono 11"; }']
|
||||
subprocess.run(cmd, input=text, text=True, check=False)
|
||||
|
||||
|
||||
def main():
|
||||
try:
|
||||
if os.environ.get("HYPRLAND_INSTANCE_SIGNATURE"):
|
||||
lines = hyprland_lines()
|
||||
else:
|
||||
lines = i3_lines()
|
||||
except Exception as exc: # noqa: BLE001 — best effort, jamais de crash muet
|
||||
subprocess.run(["notify-send", "Raccourcis FWS", f"Erreur : {exc}"],
|
||||
check=False)
|
||||
return 1
|
||||
show(lines)
|
||||
return 0
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
sys.exit(main())
|
||||
Executable
+59
@@ -0,0 +1,59 @@
|
||||
#!/usr/bin/env python3
|
||||
# FWS — menu d'alimentation (verrouiller / déconnexion / suspendre /
|
||||
# redémarrer / éteindre). Bouton de la barre ou Super+X. Universel :
|
||||
# • Hyprland (Wayland) → wofi, verrouillage hyprlock, sortie hyprctl.
|
||||
# • i3 (X11) → rofi, verrouillage i3lock, sortie i3-msg exit.
|
||||
# Aucune dépendance hors python3 + wofi/rofi (déjà là avec le bureau).
|
||||
|
||||
import os
|
||||
import subprocess
|
||||
import sys
|
||||
|
||||
_WOFI_STYLE = "/usr/local/share/fws/wofi-style.css"
|
||||
_HYPR = bool(os.environ.get("HYPRLAND_INSTANCE_SIGNATURE"))
|
||||
|
||||
# (libellé affiché, commande shell). L'icône Nerd Font aide au repérage.
|
||||
if _HYPR:
|
||||
_lock = "hyprlock"
|
||||
_logout = "hyprctl dispatch exit"
|
||||
else:
|
||||
_lock = "i3lock -c 1e1e2e"
|
||||
_logout = "i3-msg exit"
|
||||
|
||||
_ITEMS = [
|
||||
(" Verrouiller", _lock),
|
||||
(" Déconnexion", _logout),
|
||||
(" Suspendre", "systemctl suspend"),
|
||||
(" Redémarrer", "systemctl reboot"),
|
||||
(" Éteindre", "systemctl poweroff"),
|
||||
]
|
||||
|
||||
|
||||
def _menu(entries):
|
||||
text = "\n".join(entries)
|
||||
if _HYPR:
|
||||
cmd = ["wofi", "--dmenu", "--prompt", "Alimentation",
|
||||
"--width", "300", "--height", "260", "--cache-file", "/dev/null"]
|
||||
if os.path.exists(_WOFI_STYLE):
|
||||
cmd += ["--style", _WOFI_STYLE]
|
||||
else:
|
||||
cmd = ["rofi", "-dmenu", "-i", "-p", "Alimentation", "-no-custom",
|
||||
"-theme-str", "window { width: 300px; } listview { lines: 5; }"]
|
||||
out = subprocess.run(cmd, input=text, text=True,
|
||||
capture_output=True, check=False)
|
||||
return out.stdout.strip()
|
||||
|
||||
|
||||
def main():
|
||||
choice = _menu([label for label, _ in _ITEMS])
|
||||
if not choice:
|
||||
return 0
|
||||
for label, command in _ITEMS:
|
||||
if label == choice:
|
||||
subprocess.Popen(["sh", "-c", command]) # noqa: S603,S607
|
||||
break
|
||||
return 0
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
sys.exit(main())
|
||||
Executable
+46
@@ -0,0 +1,46 @@
|
||||
#!/bin/bash
|
||||
# FWS — installe/actualise Proton-GE (GloriousEggroll) pour Steam :
|
||||
# meilleure compatibilité des jeux Windows que le Proton officiel.
|
||||
# S'exécute en UTILISATEUR (installe dans ~/.steam/root/compatibilitytools.d).
|
||||
set -u
|
||||
say() { printf '\n\033[1;34m==> %s\033[0m\n' "$*"; }
|
||||
fail() { printf '\033[1;31m ✗ %s\033[0m\n' "$*"; read -rp "Entrée pour fermer. " _; exit 1; }
|
||||
|
||||
[ "$(id -u)" -eq 0 ] && fail "à lancer en utilisateur normal (pas root) : l'outil s'installe dans ton Steam."
|
||||
|
||||
API="https://api.github.com/repos/GloriousEggroll/proton-ge-custom/releases/latest"
|
||||
DEST="$HOME/.steam/root/compatibilitytools.d"
|
||||
|
||||
say "Recherche de la dernière version de Proton-GE…"
|
||||
JSON="$(curl -fsSL "$API")" || fail "GitHub inaccessible (réseau ?)"
|
||||
URL="$(printf '%s' "$JSON" | grep -o '"browser_download_url": *"[^"]*\.tar\.gz"' | cut -d'"' -f4 | head -1)"
|
||||
SUM_URL="$(printf '%s' "$JSON" | grep -o '"browser_download_url": *"[^"]*\.sha512sum"' | cut -d'"' -f4 | head -1)"
|
||||
[ -n "$URL" ] || fail "archive introuvable dans la release GitHub"
|
||||
NAME="$(basename "$URL" .tar.gz)"
|
||||
|
||||
if [ -d "$DEST/$NAME" ]; then
|
||||
say "$NAME est déjà installé ✔"
|
||||
read -rp "Entrée pour fermer. " _; exit 0
|
||||
fi
|
||||
|
||||
TMP="$(mktemp -d)"
|
||||
trap 'rm -rf "$TMP"' EXIT
|
||||
say "Téléchargement de $NAME (~450 Mo)…"
|
||||
curl -fL --progress-bar -o "$TMP/$NAME.tar.gz" "$URL" || fail "téléchargement échoué"
|
||||
|
||||
if [ -n "$SUM_URL" ]; then
|
||||
say "Vérification de l'intégrité (sha512)…"
|
||||
curl -fsSL -o "$TMP/sum" "$SUM_URL" \
|
||||
&& (cd "$TMP" && sed "s|[^ ]*\.tar\.gz|$NAME.tar.gz|" sum | sha512sum -c -) \
|
||||
|| fail "somme de contrôle invalide — archive corrompue ?"
|
||||
fi
|
||||
|
||||
say "Installation dans $DEST…"
|
||||
mkdir -p "$DEST"
|
||||
tar -xzf "$TMP/$NAME.tar.gz" -C "$DEST" || fail "extraction échouée"
|
||||
|
||||
say "$NAME installé ✔"
|
||||
echo " Dans Steam : Paramètres → Compatibilité → activer, puis choisir"
|
||||
echo " « $NAME » (ou par jeu : Propriétés → Compatibilité)."
|
||||
echo " Redémarre Steam pour qu'il apparaisse."
|
||||
read -rp "Entrée pour fermer. " _
|
||||
Executable
+220
@@ -0,0 +1,220 @@
|
||||
#!/bin/bash
|
||||
# ============================================================================
|
||||
# FWS — moteur de réparation d'une installation existante depuis le live
|
||||
# (« point de restauration à la Windows »).
|
||||
#
|
||||
# L'interface GRAPHIQUE est fws-recovery-gui (GTK3 python — le live embarque
|
||||
# python-gobject/gtk3 via Anaconda) ; elle pilote CE script en sous-commandes.
|
||||
# Sans argument : assistant CONSOLE (repli sans X, ou usage à la main).
|
||||
#
|
||||
# Sous-commandes (pour la GUI / scripts) :
|
||||
# scan → une ligne « périphérique|nom » par install FWS
|
||||
# repair <action> <dev> → monte, répare, démonte ; sortie en continu
|
||||
# action ∈ grub|initramfs|pacman|pacman-update|all
|
||||
# shell <dev> → terminal DANS le système (xterm si DISPLAY)
|
||||
#
|
||||
# arch-chroot (arch-install-scripts, présent sur le live) gère les binds.
|
||||
#
|
||||
# Fonctionne depuis le LIVE (autre disque) ET depuis le SYSTÈME INSTALLÉ
|
||||
# lui-même (menu d'applications / entrée GRUB « Réparer FWS ») : si la cible
|
||||
# est la racine en cours d'exécution, on opère directement, sans mount/chroot.
|
||||
# ============================================================================
|
||||
set -u
|
||||
MNT=/mnt/fws-recovery
|
||||
ROOTDEV=""
|
||||
DO_UPDATE=""
|
||||
SELF="" # cible = système courant
|
||||
ROOTSRC="$(findmnt -no SOURCE / 2>/dev/null)" # sur le live : overlay → jamais un lsblk
|
||||
|
||||
say() { printf '\n==> %s\n' "$*"; }
|
||||
warn() { printf ' ⚠ %s\n' "$*"; }
|
||||
|
||||
[ "$(id -u)" -eq 0 ] || { echo "root requis"; exit 1; }
|
||||
|
||||
cleanup() { [ -n "$MNT" ] && [ "$MNT" != "/" ] && umount -R "$MNT" 2>/dev/null; }
|
||||
|
||||
# Exécute DANS la cible : chroot si elle est montée, directement si c'est nous.
|
||||
in_target() {
|
||||
if [ -n "$SELF" ]; then "$@"; else arch-chroot "$MNT" "$@"; fi
|
||||
}
|
||||
|
||||
# ── Moteur ───────────────────────────────────────────────────────────────────
|
||||
|
||||
scan_installs() {
|
||||
vgscan --mknodes >/dev/null 2>&1
|
||||
vgchange -ay >/dev/null 2>&1
|
||||
udevadm settle --timeout=10 >/dev/null 2>&1
|
||||
# Le système en cours d'exécution d'abord (app lancée depuis l'OS installé).
|
||||
if [ ! -d /run/archiso ] && grep -qiE '^(ID|NAME)=.*fws' /etc/os-release 2>/dev/null; then
|
||||
printf '%s|%s (ce système)\n' "$ROOTSRC" \
|
||||
"$(. /etc/os-release 2>/dev/null; echo "${PRETTY_NAME:-FWS}")"
|
||||
fi
|
||||
mkdir -p "$MNT"
|
||||
local dev name
|
||||
while read -r dev; do
|
||||
[ -b "$dev" ] || continue
|
||||
[ "$dev" = "$ROOTSRC" ] && continue # déjà listé ci-dessus
|
||||
mount -o ro "$dev" "$MNT" 2>/dev/null || continue
|
||||
if [ -f "$MNT/etc/os-release" ] && [ -d "$MNT/boot" ] \
|
||||
&& grep -qiE '^(ID|NAME)=.*fws' "$MNT/etc/os-release" 2>/dev/null; then
|
||||
name="$(. "$MNT/etc/os-release" 2>/dev/null; echo "${PRETTY_NAME:-FWS}")"
|
||||
printf '%s|%s\n' "$dev" "$name"
|
||||
fi
|
||||
umount "$MNT" 2>/dev/null
|
||||
done < <(lsblk -rpno NAME,TYPE | awk '$2=="part"||$2=="lvm"{print $1}')
|
||||
}
|
||||
|
||||
# Monte la cible + /boot + ESP d'après son fstab.
|
||||
# Cas particulier : la cible EST la racine en cours d'exécution (app lancée
|
||||
# depuis l'OS installé, ou entrée GRUB « Réparer FWS ») → tout est déjà là,
|
||||
# on opère en place (MNT="" : les chemins "$MNT/…" pointent sur la vraie racine).
|
||||
mount_target() {
|
||||
ROOTDEV="$1"
|
||||
if [ "$ROOTDEV" = "$ROOTSRC" ] && [ ! -d /run/archiso ]; then
|
||||
SELF=1; MNT=""
|
||||
echo " cible = système en cours d'exécution (pas de montage)"
|
||||
return 0
|
||||
fi
|
||||
mkdir -p "$MNT"
|
||||
mount "$ROOTDEV" "$MNT" || return 1
|
||||
local mp src
|
||||
for mp in /boot /boot/efi; do
|
||||
src="$(awk -v mp="$mp" '$2==mp && $1!~/^#/{print $1; exit}' "$MNT/etc/fstab" 2>/dev/null)"
|
||||
[ -n "$src" ] || continue
|
||||
mount "$(findfs "$src" 2>/dev/null || echo "$src")" "$MNT$mp" 2>/dev/null \
|
||||
&& echo " $mp monté" || warn "$mp non monté (on continue)"
|
||||
done
|
||||
return 0
|
||||
}
|
||||
|
||||
fix_grub() {
|
||||
say "Réinstallation de GRUB…"
|
||||
if [ -d /sys/firmware/efi ]; then
|
||||
in_target grub-install --target=x86_64-efi \
|
||||
--efi-directory=/boot/efi --bootloader-id=FWS --recheck || true
|
||||
in_target grub-install --target=x86_64-efi \
|
||||
--efi-directory=/boot/efi --bootloader-id=FWS --removable --recheck
|
||||
else
|
||||
local disk
|
||||
disk="$(lsblk -spno NAME,TYPE "$ROOTDEV" 2>/dev/null \
|
||||
| awk '$2=="disk"{print $1; exit}' | grep -oE '/dev/[a-z0-9]+')"
|
||||
[ -n "$disk" ] || { warn "disque BIOS introuvable"; return 1; }
|
||||
in_target grub-install --target=i386-pc --recheck "$disk"
|
||||
fi
|
||||
in_target grub-mkconfig -o /boot/grub/grub.cfg
|
||||
}
|
||||
|
||||
fix_initramfs() {
|
||||
say "Régénération de l'initramfs (mkinitcpio -P)…"
|
||||
echo " NB : les avertissements « Possibly missing firmware for module … » sont"
|
||||
echo " NORMAUX sur Arch : firmware de matériel exotique (cartes SCSI/fibre…)"
|
||||
echo " non fourni par linux-firmware. Sans effet, sauf si tu AS ce matériel."
|
||||
in_target mkinitcpio -P
|
||||
}
|
||||
|
||||
fix_pacman() {
|
||||
say "Réparation de pacman…"
|
||||
rm -f "$MNT/var/lib/pacman/db.lck" && echo " verrou db.lck retiré (s'il existait)"
|
||||
in_target pacman-key --init
|
||||
in_target pacman-key --populate archlinux
|
||||
if [ -n "$DO_UPDATE" ]; then
|
||||
say "Mise à jour complète (pacman -Syu)…"
|
||||
[ -z "$SELF" ] && cp -f /etc/resolv.conf "$MNT/etc/resolv.conf" 2>/dev/null
|
||||
in_target pacman -Syu --noconfirm
|
||||
fi
|
||||
}
|
||||
|
||||
fix_all() { fix_initramfs && fix_grub; }
|
||||
|
||||
# ── Sous-commandes (pilotées par fws-recovery-gui) ───────────────────────────
|
||||
case "${1:-}" in
|
||||
scan)
|
||||
scan_installs
|
||||
exit 0 ;;
|
||||
repair)
|
||||
action="${2:?action manquante}"; dev="${3:?périphérique manquant}"
|
||||
trap cleanup EXIT
|
||||
say "Montage de $dev…"
|
||||
mount_target "$dev" || { warn "montage impossible"; exit 1; }
|
||||
rc=0
|
||||
case "$action" in
|
||||
grub) fix_grub || rc=$? ;;
|
||||
initramfs) fix_initramfs || rc=$? ;;
|
||||
pacman) fix_pacman || rc=$? ;;
|
||||
pacman-update) DO_UPDATE=1; fix_pacman || rc=$? ;;
|
||||
all) fix_all || rc=$? ;;
|
||||
*) warn "action inconnue : $action"; rc=2 ;;
|
||||
esac
|
||||
cleanup; trap - EXIT
|
||||
[ "$rc" -eq 0 ] && say "Terminé ✔" || say "Échec (code $rc)"
|
||||
exit "$rc" ;;
|
||||
shell)
|
||||
dev="${2:?périphérique manquant}"
|
||||
trap cleanup EXIT
|
||||
mount_target "$dev" || { warn "montage impossible"; exit 1; }
|
||||
if [ -z "$SELF" ] && [ -n "${DISPLAY:-}" ] && command -v xterm >/dev/null 2>&1; then
|
||||
xterm -title "FWS — terminal dans le système (chroot)" \
|
||||
-e arch-chroot "$MNT" /bin/bash
|
||||
else
|
||||
in_target /bin/bash
|
||||
fi
|
||||
cleanup; trap - EXIT
|
||||
exit 0 ;;
|
||||
""|tui) : ;; # assistant console ci-dessous
|
||||
*) echo "usage : fws-recovery [scan|repair <action> <dev>|shell <dev>]"; exit 2 ;;
|
||||
esac
|
||||
|
||||
# ── Assistant CONSOLE (repli sans X / usage manuel) ──────────────────────────
|
||||
trap cleanup EXIT
|
||||
say "Recherche des installations FWS…"
|
||||
mapfile -t CANDIDATES < <(scan_installs)
|
||||
|
||||
if [ "${#CANDIDATES[@]}" -eq 0 ]; then
|
||||
warn "Aucune installation FWS trouvée. Disques visibles :"
|
||||
lsblk -o NAME,SIZE,TYPE,FSTYPE,MOUNTPOINTS
|
||||
read -rp "Entrée pour ouvrir un shell (exit pour redémarrer). " _
|
||||
bash; exit 0
|
||||
fi
|
||||
|
||||
echo; i=1
|
||||
for c in "${CANDIDATES[@]}"; do echo " $i) ${c%%|*} — ${c##*|}"; i=$((i+1)); done
|
||||
read -rp "Installation à réparer [1] : " pick; pick="${pick:-1}"
|
||||
dev="${CANDIDATES[$((pick-1))]%%|*}"
|
||||
[ -n "$dev" ] || exit 1
|
||||
say "Montage de $dev…"
|
||||
mount_target "$dev" || { warn "montage impossible"; exit 1; }
|
||||
|
||||
while :; do
|
||||
cat <<'MENU'
|
||||
|
||||
╔════════════════════════════════════════════════════════╗
|
||||
║ FWS — Réparation du système ║
|
||||
╠════════════════════════════════════════════════════════╣
|
||||
║ 1) Réinstaller GRUB (le système ne démarre plus) ║
|
||||
║ 2) Régénérer l'initramfs (mkinitcpio -P) ║
|
||||
║ 3) Réparer pacman (verrou, clés, mise à jour) ║
|
||||
║ 4) Tout réparer (initramfs + GRUB) ║
|
||||
║ 5) Ouvrir un shell DANS le système (chroot) ║
|
||||
║ q) Quitter et redémarrer ║
|
||||
╚════════════════════════════════════════════════════════╝
|
||||
MENU
|
||||
read -rp " Choix : " choice
|
||||
case "$choice" in
|
||||
1) fix_grub ;;
|
||||
2) fix_initramfs ;;
|
||||
3) DO_UPDATE=""
|
||||
read -rp " Mise à jour complète aussi (réseau) ? [o/N] " _u
|
||||
case "$_u" in o|O|oui) DO_UPDATE=1 ;; esac
|
||||
fix_pacman ;;
|
||||
4) fix_all ;;
|
||||
5) say "Shell chroot — « exit » pour revenir au menu."
|
||||
in_target /bin/bash ;;
|
||||
q|Q) break ;;
|
||||
*) warn "choix inconnu" ;;
|
||||
esac
|
||||
done
|
||||
|
||||
cleanup; trap - EXIT
|
||||
say "Réparation terminée."
|
||||
read -rp "Redémarrer maintenant ? [O/n] " _r
|
||||
case "$_r" in n|N) bash ;; *) systemctl reboot ;; esac
|
||||
Executable
+269
@@ -0,0 +1,269 @@
|
||||
#!/usr/bin/env python3
|
||||
# FWS — application GRAPHIQUE de réparation du système (mode « Réparer FWS »
|
||||
# du live). GTK3 : le live embarque python-gobject/gtk3 via Anaconda.
|
||||
#
|
||||
# Pilote le MOTEUR fws-recovery en sous-commandes :
|
||||
# fws-recovery scan → détecte les installations FWS
|
||||
# fws-recovery repair <action> <dev> → répare (sortie streamée ici)
|
||||
# fws-recovery shell <dev> → terminal chroot (xterm)
|
||||
#
|
||||
# Deux contextes de lancement :
|
||||
# • mode « Réparer FWS » (live OU entrée GRUB de l'OS installé) : session
|
||||
# root via fws-recovery-session → le moteur est appelé directement ;
|
||||
# • menu d'applications de l'OS installé : lancée en UTILISATEUR → chaque
|
||||
# appel du moteur passe par pkexec (politique org.fws.recovery,
|
||||
# auth_admin_keep : un seul mot de passe pour toute la session).
|
||||
|
||||
import os
|
||||
import shutil
|
||||
import subprocess
|
||||
import sys
|
||||
|
||||
import gi
|
||||
|
||||
gi.require_version("Gtk", "3.0")
|
||||
from gi.repository import GLib, Gtk, Pango # noqa: E402
|
||||
|
||||
GLib.set_prgname("fws-recovery-gui")
|
||||
|
||||
_ENGINE = "/usr/local/bin/fws-recovery"
|
||||
|
||||
|
||||
def _engine_cmd(args):
|
||||
"""Commande moteur, élevée via pkexec si on n'est pas root."""
|
||||
cmd = [_ENGINE] + args
|
||||
if os.geteuid() != 0:
|
||||
cmd = ["pkexec"] + cmd
|
||||
return cmd
|
||||
|
||||
_ACTIONS = [
|
||||
("grub", "Réinstaller GRUB",
|
||||
"le système ne démarre plus / « Operating System not found »"),
|
||||
("initramfs", "Régénérer l'initramfs",
|
||||
"kernel panic au démarrage, module manquant (mkinitcpio -P)"),
|
||||
("pacman", "Réparer pacman",
|
||||
"verrou bloqué, clés de signature cassées"),
|
||||
("pacman-update", "Réparer pacman + mise à jour complète",
|
||||
"idem, puis pacman -Syu (réseau requis)"),
|
||||
("all", "Tout réparer",
|
||||
"initramfs puis GRUB — le réflexe « ça ne boote plus »"),
|
||||
]
|
||||
|
||||
|
||||
class RecoveryWindow(Gtk.Window):
|
||||
def __init__(self):
|
||||
super().__init__(title="FWS — Réparation du système")
|
||||
self.set_icon_name("fws-recovery")
|
||||
self.set_default_size(720, 560)
|
||||
self.set_position(Gtk.WindowPosition.CENTER)
|
||||
self.set_border_width(18)
|
||||
self.connect("destroy", Gtk.main_quit)
|
||||
|
||||
self._proc = None
|
||||
self._installs = [] # [(dev, nom), …]
|
||||
self._action_buttons = []
|
||||
|
||||
root = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=10)
|
||||
self.add(root)
|
||||
|
||||
title = Gtk.Label()
|
||||
title.set_markup("<span size='x-large' weight='bold'>Réparation du système FWS</span>")
|
||||
root.pack_start(title, False, False, 0)
|
||||
|
||||
self._status = Gtk.Label(label="Recherche des installations FWS sur les disques…")
|
||||
self._status.set_xalign(0)
|
||||
root.pack_start(self._status, False, False, 0)
|
||||
|
||||
# Sélecteur d'installation (rempli après le scan).
|
||||
picker_row = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL, spacing=8)
|
||||
picker_row.pack_start(Gtk.Label(label="Système à réparer :"), False, False, 0)
|
||||
self._picker = Gtk.ComboBoxText()
|
||||
picker_row.pack_start(self._picker, True, True, 0)
|
||||
root.pack_start(picker_row, False, False, 0)
|
||||
|
||||
# Boutons d'action (style fws-hello : titre + description).
|
||||
for key, label, desc in _ACTIONS:
|
||||
button = Gtk.Button()
|
||||
inner = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=2)
|
||||
lab = Gtk.Label()
|
||||
lab.set_markup(f"<b>{label}</b>")
|
||||
lab.set_xalign(0)
|
||||
sub = Gtk.Label(label=desc)
|
||||
sub.set_xalign(0)
|
||||
sub.get_style_context().add_class("dim-label")
|
||||
inner.pack_start(lab, False, False, 0)
|
||||
inner.pack_start(sub, False, False, 0)
|
||||
button.add(inner)
|
||||
button.connect("clicked", self._on_action, key)
|
||||
root.pack_start(button, False, False, 0)
|
||||
self._action_buttons.append(button)
|
||||
|
||||
shell_btn = Gtk.Button(label="Ouvrir un terminal dans le système (chroot)")
|
||||
shell_btn.connect("clicked", self._on_shell)
|
||||
root.pack_start(shell_btn, False, False, 0)
|
||||
self._action_buttons.append(shell_btn)
|
||||
|
||||
# Journal (sortie du moteur, en continu).
|
||||
frame = Gtk.Frame(label="Journal")
|
||||
scroll = Gtk.ScrolledWindow()
|
||||
scroll.set_min_content_height(150)
|
||||
self._log = Gtk.TextView()
|
||||
self._log.set_editable(False)
|
||||
self._log.set_cursor_visible(False)
|
||||
self._log.set_monospace(True)
|
||||
self._log.modify_font(Pango.FontDescription("Monospace 9"))
|
||||
scroll.add(self._log)
|
||||
frame.add(scroll)
|
||||
root.pack_start(frame, True, True, 0)
|
||||
|
||||
# Pied : redémarrer / éteindre.
|
||||
footer = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL, spacing=8)
|
||||
reboot = Gtk.Button(label="Redémarrer")
|
||||
reboot.connect("clicked", lambda _b: self._power("reboot"))
|
||||
poweroff = Gtk.Button(label="Éteindre")
|
||||
poweroff.connect("clicked", lambda _b: self._power("poweroff"))
|
||||
footer.pack_end(reboot, False, False, 0)
|
||||
footer.pack_end(poweroff, False, False, 0)
|
||||
root.pack_start(footer, False, False, 0)
|
||||
|
||||
self._set_busy(True)
|
||||
GLib.idle_add(self._start_scan)
|
||||
|
||||
# ── Utilitaires ─────────────────────────────────────────────────────────
|
||||
def _append(self, text):
|
||||
# Rebranding d'affichage : les outils sous-jacents parlent
|
||||
# d'« Arch Linux » — pas le journal FWS. (Les identifiants techniques
|
||||
# comme archlinux-keyring restent tels quels : ce sont de vrais noms
|
||||
# de fichiers/paquets, les masquer fausserait le diagnostic.)
|
||||
text = text.replace("Arch Linux", "FWS").replace("Fedora", "FWS")
|
||||
buf = self._log.get_buffer()
|
||||
buf.insert(buf.get_end_iter(), text)
|
||||
mark = buf.create_mark(None, buf.get_end_iter(), False)
|
||||
self._log.scroll_mark_onscreen(mark)
|
||||
buf.delete_mark(mark)
|
||||
|
||||
def _set_busy(self, busy):
|
||||
for b in self._action_buttons:
|
||||
b.set_sensitive(not busy and bool(self._installs))
|
||||
# Sensible même avec UNE seule install : un combo grisé donne
|
||||
# l'impression que TOUTE l'app est désactivée (retour utilisateur).
|
||||
self._picker.set_sensitive(not busy and bool(self._installs))
|
||||
|
||||
def _selected_dev(self):
|
||||
idx = self._picker.get_active()
|
||||
if 0 <= idx < len(self._installs):
|
||||
return self._installs[idx][0]
|
||||
return None
|
||||
|
||||
def _power(self, what):
|
||||
subprocess.run(["systemctl", what], check=False)
|
||||
|
||||
# ── Scan des installations ──────────────────────────────────────────────
|
||||
def _start_scan(self):
|
||||
self._run_engine(["scan"], self._scan_done, quiet=True)
|
||||
return False
|
||||
|
||||
def _scan_done(self, rc, output):
|
||||
self._installs = []
|
||||
for line in output.splitlines():
|
||||
if "|" in line:
|
||||
dev, _, name = line.partition("|")
|
||||
self._installs.append((dev.strip(), name.strip()))
|
||||
self._picker.append_text(f"{name.strip()} — {dev.strip()}")
|
||||
if self._installs:
|
||||
self._picker.set_active(0)
|
||||
n = len(self._installs)
|
||||
self._status.set_markup(
|
||||
f"<b>{n}</b> installation{'s' if n > 1 else ''} FWS détectée{'s' if n > 1 else ''}."
|
||||
" Choisis une réparation :")
|
||||
elif rc in (126, 127):
|
||||
# pkexec : authentification annulée ou refusée.
|
||||
self._status.set_markup(
|
||||
"<b>Authentification annulée.</b> Ferme puis relance"
|
||||
" l'application pour réessayer.")
|
||||
else:
|
||||
self._status.set_markup(
|
||||
"<b>Aucune installation FWS détectée.</b> Vérifie les disques"
|
||||
" (terminal ci-dessous) ou redémarre.")
|
||||
self._append("Aucune installation FWS trouvée.\n\n"
|
||||
+ subprocess.run(["lsblk", "-o", "NAME,SIZE,TYPE,FSTYPE"],
|
||||
capture_output=True, text=True,
|
||||
check=False).stdout)
|
||||
self._set_busy(False)
|
||||
# Le terminal reste utile même sans installation détectée (diagnostic).
|
||||
self._action_buttons[-1].set_sensitive(True)
|
||||
|
||||
# ── Exécution du moteur avec sortie en continu ──────────────────────────
|
||||
def _run_engine(self, args, done_cb, quiet=False):
|
||||
self._set_busy(True)
|
||||
self._proc = subprocess.Popen(
|
||||
_engine_cmd(args), stdout=subprocess.PIPE,
|
||||
stderr=subprocess.STDOUT, text=True, bufsize=1)
|
||||
chunks = []
|
||||
|
||||
def on_io(source, _cond):
|
||||
line = source.readline()
|
||||
if line:
|
||||
chunks.append(line)
|
||||
if not quiet:
|
||||
self._append(line)
|
||||
return True
|
||||
rc = self._proc.wait()
|
||||
done_cb(rc, "".join(chunks))
|
||||
return False
|
||||
|
||||
GLib.io_add_watch(self._proc.stdout,
|
||||
GLib.IO_IN | GLib.IO_HUP, on_io)
|
||||
|
||||
def _on_action(self, _button, key):
|
||||
dev = self._selected_dev()
|
||||
if not dev:
|
||||
return
|
||||
label = next(lab for k, lab, _d in _ACTIONS if k == key)
|
||||
self._status.set_markup(f"<b>{label}</b> sur {dev} — en cours…")
|
||||
self._append(f"\n───── {label} ({dev}) ─────\n")
|
||||
self._run_engine(["repair", key, dev], self._action_done)
|
||||
|
||||
def _action_done(self, rc, _output):
|
||||
if rc == 0:
|
||||
self._status.set_markup("<b>Terminé ✔</b> — autre réparation, ou redémarre.")
|
||||
elif rc in (126, 127):
|
||||
self._status.set_markup(
|
||||
"<b>Authentification annulée</b> — rien n'a été modifié.")
|
||||
else:
|
||||
self._status.set_markup(
|
||||
f"<b>Échec (code {rc})</b> — détail dans le journal ci-dessous.")
|
||||
self._set_busy(False)
|
||||
|
||||
def _on_shell(self, _button):
|
||||
dev = self._selected_dev()
|
||||
if dev and os.geteuid() == 0:
|
||||
subprocess.Popen([_ENGINE, "shell", dev])
|
||||
elif dev:
|
||||
# pkexec purge DISPLAY → le moteur ouvre le chroot DANS cet xterm
|
||||
# (lancé en utilisateur, donc visible sur X11 comme Wayland).
|
||||
subprocess.Popen(["xterm", "-title",
|
||||
"FWS — terminal dans le système (chroot)",
|
||||
"-e", "pkexec", _ENGINE, "shell", dev])
|
||||
elif shutil.which("xterm"):
|
||||
subprocess.Popen(["xterm", "-title", "FWS — terminal"])
|
||||
|
||||
|
||||
def main():
|
||||
if not Gtk.init_check()[0]:
|
||||
# Pas d'affichage : le .zprofile retombera sur l'assistant console.
|
||||
return 1
|
||||
if os.geteuid() != 0 and not shutil.which("pkexec"):
|
||||
dlg = Gtk.MessageDialog(message_type=Gtk.MessageType.ERROR,
|
||||
buttons=Gtk.ButtonsType.CLOSE,
|
||||
text="pkexec introuvable : lance fws-recovery-gui en root.")
|
||||
dlg.run()
|
||||
return 1
|
||||
win = RecoveryWindow()
|
||||
win.show_all()
|
||||
Gtk.main()
|
||||
return 0
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
sys.exit(main())
|
||||
Executable
+8
@@ -0,0 +1,8 @@
|
||||
#!/bin/sh
|
||||
# FWS — session X du mode réparation. Lancé par startx (cf. /root/.zprofile,
|
||||
# entrée de boot « Réparer FWS »). Openbox minimal + l'application GTK
|
||||
# fws-recovery-gui. Si la GUI meurt, openbox reste pour un xterm de secours.
|
||||
xsetroot -solid "#1a1a2e" 2>/dev/null
|
||||
openbox &
|
||||
fws-recovery-gui
|
||||
exec openbox
|
||||
Executable
+84
@@ -0,0 +1,84 @@
|
||||
#!/bin/bash
|
||||
# ============================================================================
|
||||
# FWS — détection matérielle + drivers + stack « remplacement de Windows ».
|
||||
#
|
||||
# Appelé par le %post du kickstart : fws-setup-hardware <bureau>
|
||||
# (<bureau> = cli|gnome|kde|xfce|hyprland). Réseau requis ; CHAQUE étape est
|
||||
# NON bloquante (pas de set -e) : un paquet manquant ou pas de réseau ne casse
|
||||
# pas l'installation.
|
||||
#
|
||||
# Installe :
|
||||
# - les drivers GPU détectés via lspci (Intel / AMD / NVIDIA) + Mesa/Vulkan,
|
||||
# - les outils invité selon l'hyperviseur (VMware/VirtualBox/QEMU/Hyper-V),
|
||||
# - le son/micro/casque (PipeWire), le Bluetooth (BlueZ), les conteneurs
|
||||
# (Podman),
|
||||
# - et — si un bureau est choisi — la stack « comme Windows » : Steam, Wine,
|
||||
# VR (Monado/OpenXR → SteamVR pour HTC Vive / Valve Index ; Oculus n'a pas
|
||||
# de support Linux officiel), winboat-bin (apps Windows).
|
||||
# ============================================================================
|
||||
DESK="${1:-cli}"
|
||||
log() { echo "[FWS-hw] $*"; }
|
||||
|
||||
# ── 1) Drivers GPU (détection lspci) ─────────────────────────────────────────
|
||||
DRIVERS="mesa"
|
||||
GPU="$(lspci 2>/dev/null | grep -iE 'VGA compatible controller|3D controller|Display controller')"
|
||||
case "$GPU" in
|
||||
*NVIDIA*|*GeForce*) DRIVERS="$DRIVERS nvidia-dkms nvidia-utils linux-headers dkms" ;;
|
||||
*AMD*|*ATI*|*Radeon*) DRIVERS="$DRIVERS vulkan-radeon libva-mesa-driver" ;;
|
||||
*Intel*) DRIVERS="$DRIVERS vulkan-intel intel-media-driver" ;;
|
||||
esac
|
||||
|
||||
# ── 2) Outils invité selon l'hyperviseur ─────────────────────────────────────
|
||||
VMSVC=""
|
||||
case "$(systemd-detect-virt 2>/dev/null)" in
|
||||
vmware) DRIVERS="$DRIVERS open-vm-tools"; VMSVC="vmtoolsd vmware-vmblock-fuse" ;;
|
||||
oracle) DRIVERS="$DRIVERS virtualbox-guest-utils"; VMSVC="vboxservice" ;;
|
||||
qemu|kvm) DRIVERS="$DRIVERS qemu-guest-agent spice-vdagent"; VMSVC="qemu-guest-agent spice-vdagentd" ;;
|
||||
microsoft) DRIVERS="$DRIVERS hyperv"; VMSVC="hv_fcopy_daemon hv_kvp_daemon hv_vss_daemon" ;;
|
||||
esac
|
||||
|
||||
# ── 3) Stack de base : son / micro / casque, Bluetooth, luminosité, conteneurs
|
||||
# brightnessctl : réglage de luminosité sans root (via logind) — consommé par
|
||||
# les touches XF86MonBrightness* et la molette du module backlight de waybar.
|
||||
BASE="pipewire pipewire-alsa pipewire-pulse pipewire-jack wireplumber \
|
||||
pavucontrol bluez bluez-utils brightnessctl podman"
|
||||
# Gestionnaire Bluetooth graphique : KDE et GNOME ont le leur ; blueman pour
|
||||
# les bureaux qui n'en fournissent pas (tray + assistant d'appairage).
|
||||
case "$DESK" in
|
||||
hyprland|xfce|i3) BASE="$BASE blueman" ;;
|
||||
esac
|
||||
|
||||
# ── 4) Stack desktop : jeux, Windows-compat, VR (si un bureau est choisi) ────
|
||||
DESKTOP=""
|
||||
if [ "$DESK" != "cli" ]; then
|
||||
# multilib requis (Steam / Wine 32 bits).
|
||||
grep -qE '^\[multilib\]' /etc/pacman.conf \
|
||||
|| printf '\n[multilib]\nInclude = /etc/pacman.d/mirrorlist\n' >> /etc/pacman.conf
|
||||
# mangohud : overlay FPS/perfs en jeu (mangohud %command% dans Steam).
|
||||
DESKTOP="steam wine winetricks wine-mono wine-gecko \
|
||||
lib32-mesa lib32-pipewire monado gamemode \
|
||||
mangohud lib32-mangohud \
|
||||
noto-fonts ttf-liberation"
|
||||
fi
|
||||
|
||||
# ── Sync + filtre aux paquets RÉELLEMENT existants ───────────────────────────
|
||||
# (un nom de paquet manquant/renommé ne doit pas faire échouer tout le reste).
|
||||
pacman -Sy --noconfirm || log "synchro pacman échouée (réseau ?)"
|
||||
VALID=""
|
||||
for p in $DRIVERS $BASE $DESKTOP; do
|
||||
pacman -Si "$p" >/dev/null 2>&1 && VALID="$VALID $p"
|
||||
done
|
||||
if [ -n "$VALID" ]; then
|
||||
log "installation :$VALID"
|
||||
pacman -S --noconfirm --needed $VALID || log "certains paquets non installés"
|
||||
fi
|
||||
|
||||
# NB : winboat-bin (AUR) n'est PAS installé ici (fws-local n'existe pas sur la
|
||||
# cible) : il est intégré à l'image FWS via packages.x86_64 et recopié par le
|
||||
# payload LiveOS d'Anaconda → déjà présent sur le système installé.
|
||||
|
||||
# ── Services matériels ───────────────────────────────────────────────────────
|
||||
[ -n "$VMSVC" ] && systemctl enable $VMSVC 2>/dev/null
|
||||
systemctl enable bluetooth.service 2>/dev/null
|
||||
systemctl enable podman.socket 2>/dev/null
|
||||
exit 0
|
||||
Executable
+33
@@ -0,0 +1,33 @@
|
||||
#!/bin/bash
|
||||
# FWS — mise à jour du système en une commande (bouton de la barre, fws-hello,
|
||||
# ou terminal). pacman -Syu + nettoyage du cache + rapport des orphelins.
|
||||
set -u
|
||||
say() { printf '\n\033[1;34m==> %s\033[0m\n' "$*"; }
|
||||
|
||||
if [ "$(id -u)" -ne 0 ]; then
|
||||
exec sudo "$0" "$@"
|
||||
fi
|
||||
|
||||
say "Mise à jour du système (pacman -Syu)…"
|
||||
pacman -Syu || { echo "Échec de la mise à jour (réseau ?)"; read -rp "Entrée pour fermer. " _; exit 1; }
|
||||
|
||||
if command -v paccache >/dev/null 2>&1; then
|
||||
say "Nettoyage du cache des paquets (2 dernières versions gardées)…"
|
||||
paccache -rk2
|
||||
fi
|
||||
|
||||
ORPHANS="$(pacman -Qtdq 2>/dev/null)"
|
||||
if [ -n "$ORPHANS" ]; then
|
||||
say "Paquets orphelins (plus requis par rien) :"
|
||||
echo "$ORPHANS"
|
||||
read -rp "Les supprimer ? [o/N] " _rm
|
||||
case "$_rm" in o|O|oui) echo "$ORPHANS" | pacman -Rns --noconfirm - ;; esac
|
||||
fi
|
||||
|
||||
if command -v flatpak >/dev/null 2>&1; then
|
||||
say "Mise à jour des Flatpaks…"
|
||||
flatpak update -y || true
|
||||
fi
|
||||
|
||||
say "Système à jour ✔"
|
||||
read -rp "Entrée pour fermer. " _
|
||||
Executable
+8
@@ -0,0 +1,8 @@
|
||||
#!/bin/sh
|
||||
# FWS — indicateur « mises à jour disponibles » pour waybar/polybar.
|
||||
# checkupdates (pacman-contrib) : lit les dépôts SANS toucher la base pacman.
|
||||
# Sortie vide = rien à faire → le module de la barre se cache.
|
||||
command -v checkupdates >/dev/null 2>&1 || exit 0
|
||||
n="$(checkupdates 2>/dev/null | wc -l)"
|
||||
[ "$n" -gt 0 ] && printf ' %s\n' "$n"
|
||||
exit 0
|
||||
Executable
+115
@@ -0,0 +1,115 @@
|
||||
#!/bin/bash
|
||||
# ============================================================================
|
||||
# FWS — installation des drivers/runtimes VR selon le casque.
|
||||
#
|
||||
# À lancer depuis un terminal (Super+Shift+V sous i3, ou l'entrée
|
||||
# « Installation VR (FWS) » du menu d'applications). Réservé aux sessions
|
||||
# X11 (i3) : SteamVR ne fonctionne PAS sous Wayland/Hyprland.
|
||||
#
|
||||
# Réalité du support Linux (résumé honnête) :
|
||||
# • HTC Vive / Vive Pro / Valve Index (stations lighthouse) → NATIF via
|
||||
# SteamVR. C'est le chemin le plus fiable.
|
||||
# • Meta/Oculus Quest 1-3, Pico → PAS de support officiel ; streaming
|
||||
# Wi-Fi via ALVR (+ SteamVR). ALVR n'est pas dans les dépôts Arch :
|
||||
# le script installe la base et donne la marche à suivre.
|
||||
# • Oculus Rift CV1/S (filaire) → pas de support utilisable.
|
||||
# • Monado : runtime OpenXR libre (déjà proposé par fws-setup-hardware),
|
||||
# utile pour les applis OpenXR natives sans SteamVR.
|
||||
# ============================================================================
|
||||
set -u
|
||||
say() { printf '\n\033[1;34m==> %s\033[0m\n' "$*"; }
|
||||
warn() { printf '\033[1;33m ⚠ %s\033[0m\n' "$*"; }
|
||||
|
||||
if [ "$(id -u)" -ne 0 ]; then
|
||||
exec sudo "$0" "$@"
|
||||
fi
|
||||
|
||||
# VM = cul-de-sac VR : pas d'accès direct au GPU ni à l'USB/DisplayPort du
|
||||
# casque, et Steam (steamwebhelper) est INSTABLE en rendu logiciel (llvmpipe).
|
||||
# On prévient au lieu de laisser l'utilisateur croire à une panne de FWS.
|
||||
if systemd-detect-virt --quiet 2>/dev/null; then
|
||||
warn "Machine VIRTUELLE détectée ($(systemd-detect-virt 2>/dev/null))."
|
||||
warn "La VR ne fonctionnera PAS ici : casque et GPU inaccessibles depuis une VM."
|
||||
warn "Steam lui-même peut planter en rendu logiciel (steamwebhelper)."
|
||||
echo " → Fais cette installation sur la machine RÉELLE avec le casque branché."
|
||||
read -rp " Continuer quand même (tests uniquement) ? [o/N] " _ok
|
||||
case "$_ok" in o|O|oui) ;; *) exit 0 ;; esac
|
||||
fi
|
||||
|
||||
# lib32 Vulkan selon le GPU (indispensable à SteamVR, qui est 32/64 bits).
|
||||
GPU="$(lspci 2>/dev/null | grep -iE 'VGA compatible controller|3D controller|Display controller')"
|
||||
LIB32="lib32-mesa"
|
||||
case "$GPU" in
|
||||
*NVIDIA*|*GeForce*) LIB32="$LIB32 lib32-nvidia-utils" ;;
|
||||
*AMD*|*ATI*|*Radeon*) LIB32="$LIB32 lib32-vulkan-radeon" ;;
|
||||
*Intel*) LIB32="$LIB32 lib32-vulkan-intel" ;;
|
||||
esac
|
||||
|
||||
install_pkgs() {
|
||||
# multilib requis pour Steam/lib32.
|
||||
grep -qE '^\[multilib\]' /etc/pacman.conf \
|
||||
|| printf '\n[multilib]\nInclude = /etc/pacman.d/mirrorlist\n' >> /etc/pacman.conf
|
||||
pacman -Sy --noconfirm || { warn "synchro pacman échouée (réseau ?)"; return 1; }
|
||||
local valid="" p
|
||||
for p in "$@"; do
|
||||
pacman -Si "$p" >/dev/null 2>&1 && valid="$valid $p" || warn "paquet inconnu ignoré : $p"
|
||||
done
|
||||
# shellcheck disable=SC2086
|
||||
pacman -S --noconfirm --needed $valid
|
||||
}
|
||||
|
||||
steamvr_base() {
|
||||
say "Installation de la base SteamVR (Steam + Vulkan 32 bits : $LIB32)…"
|
||||
# ttf-liberation : polices attendues par l'interface Steam (évite des
|
||||
# rendus cassés/plantages cosmétiques sur install minimale).
|
||||
# shellcheck disable=SC2086
|
||||
install_pkgs steam $LIB32 ttf-liberation || return 1
|
||||
say "Base installée. Étapes suivantes :"
|
||||
echo " 1. Lance Steam, connecte-toi, puis installe « SteamVR » (Bibliothèque → Outils)."
|
||||
echo " 2. Branche le casque et les stations, puis lance SteamVR."
|
||||
echo " 3. Premier lancement : SteamVR peut demander à ajuster les règles udev — accepte."
|
||||
say "Si Steam PLANTE (fenêtre qui se ferme, souvent steamwebhelper) :"
|
||||
echo " • Vérifie l'espace disque (SteamVR ≈ 5 Go) : df -h ~"
|
||||
echo " • GPU faible / VM / rendu logiciel — lance :"
|
||||
echo " steam -cef-disable-gpu -cef-disable-gpu-compositing"
|
||||
echo " • Pour voir l'erreur exacte : lance « steam » depuis un terminal,"
|
||||
echo " ou regarde ~/.steam/steam/logs/ (console_log.txt, bootstrap_log.txt)."
|
||||
}
|
||||
|
||||
case "${1:-menu}" in
|
||||
menu)
|
||||
cat <<'MENU'
|
||||
|
||||
╔══════════════════════════════════════════════════════════╗
|
||||
║ FWS — Installation VR (session X11 requise) ║
|
||||
╠══════════════════════════════════════════════════════════╣
|
||||
║ 1) HTC Vive / Vive Pro / Valve Index (natif, SteamVR) ║
|
||||
║ 2) Meta Quest / Pico (streaming ALVR) ║
|
||||
║ 3) Monado (runtime OpenXR libre, sans SteamVR) ║
|
||||
║ q) Quitter ║
|
||||
╚══════════════════════════════════════════════════════════╝
|
||||
MENU
|
||||
read -rp " Choix : " choice
|
||||
exec "$0" "$choice"
|
||||
;;
|
||||
1|vive|index)
|
||||
steamvr_base || exit 1
|
||||
;;
|
||||
2|quest|pico)
|
||||
steamvr_base || exit 1
|
||||
say "Streaming Quest/Pico : il faut AUSSI ALVR (pas dans les dépôts Arch) :"
|
||||
echo " 1. Télécharge le .tar.gz « ALVR Launcher » : https://github.com/alvr-org/ALVR/releases"
|
||||
echo " 2. Sur le casque, installe le client ALVR (App Lab / SideQuest)."
|
||||
echo " 3. Lance ALVR sur le PC (même Wi-Fi 5 GHz que le casque) — il pilote SteamVR."
|
||||
;;
|
||||
3|monado)
|
||||
say "Installation de Monado (OpenXR) + outils…"
|
||||
install_pkgs monado || exit 1
|
||||
say "Monado installé. Les applis OpenXR le trouvent via /usr/share/openxr/."
|
||||
;;
|
||||
q|Q) exit 0 ;;
|
||||
*) warn "choix inconnu : ${1}"; exec "$0" menu ;;
|
||||
esac
|
||||
|
||||
echo
|
||||
read -rp "Terminé — appuie sur Entrée pour fermer. " _
|
||||
Executable
+239
@@ -0,0 +1,239 @@
|
||||
#!/usr/bin/env bash
|
||||
#
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
usage() {
|
||||
cat <<-_EOF_
|
||||
live cd sound helper script.
|
||||
Usage: livecdsound [OPTION]
|
||||
OPTIONS
|
||||
-u, --unmute unmute all sound cards
|
||||
-p, --pick select a card for speetch output
|
||||
-h, --help Show this usage message
|
||||
|
||||
_EOF_
|
||||
}
|
||||
|
||||
bugout() {
|
||||
printf "/usr/local/bin/livecdsound: programming error"
|
||||
stat_fail
|
||||
}
|
||||
|
||||
echo_card_indices() {
|
||||
if [[ -f /proc/asound/cards ]]; then
|
||||
sed -n -e's/^[[:space:]]*\([0-7]\)[[:space:]].*/\1/p' /proc/asound/cards
|
||||
fi
|
||||
}
|
||||
|
||||
# The following functions try to set many controls.
|
||||
# No card has all the controls and so some of the attempts are bound to fail.
|
||||
# Because of this, the functions can't return useful status values.
|
||||
|
||||
# $1 <card id>
|
||||
# $2 <control>
|
||||
# $3 <level>
|
||||
unmute_and_set_level() {
|
||||
[[ -n "$3" && -n "$2" && -n "$1" ]] || bugout
|
||||
systemd-cat -t "livecdsound" printf "Setting: %s on card: %s to %s\n" "$2" "$1" "$3"
|
||||
systemd-cat -t "livecdsound" amixer -c "$1" set "$2" "$3" unmute
|
||||
return 0
|
||||
}
|
||||
|
||||
# $1 <card id>
|
||||
# $2 <control>
|
||||
mute_and_zero_level() {
|
||||
[[ -n "$1" && -n "$2" ]] || bugout
|
||||
systemd-cat -t "livecdsound" printf "Muting control: %s on card: %s\n" "$2" "$1"
|
||||
systemd-cat -t "livecdsound" amixer -c "$1" set "$2" "0%" mute
|
||||
return 0
|
||||
}
|
||||
|
||||
# $1 <card ID>
|
||||
# $2 <control>
|
||||
# $3 "on" | "off"
|
||||
switch_control() {
|
||||
[[ -n "$3" && -n "$1" ]] || bugout
|
||||
systemd-cat -t "livecdsound" printf "Switching control: %s on card: %s to %s\n" "$2" "$1" "$3"
|
||||
systemd-cat -t "livecdsound" amixer -c "$1" set "$2" "$3"
|
||||
return 0
|
||||
}
|
||||
|
||||
# $1 <card ID>
|
||||
sanify_levels_on_card() {
|
||||
unmute_and_set_level "$1" "Front" "80%"
|
||||
unmute_and_set_level "$1" "Master" "80%"
|
||||
unmute_and_set_level "$1" "Master Mono" "80%"
|
||||
unmute_and_set_level "$1" "Master Digital" "80%" # E.g., cs4237B
|
||||
unmute_and_set_level "$1" "Playback" "80%"
|
||||
unmute_and_set_level "$1" "Headphone" "100%"
|
||||
unmute_and_set_level "$1" "PCM" "80%"
|
||||
unmute_and_set_level "$1" "PCM,1" "80%" # E.g., ess1969
|
||||
unmute_and_set_level "$1" "DAC" "80%" # E.g., envy24, cs46xx
|
||||
unmute_and_set_level "$1" "DAC,0" "80%" # E.g., envy24
|
||||
unmute_and_set_level "$1" "DAC,1" "80%" # E.g., envy24
|
||||
unmute_and_set_level "$1" "Synth" "80%"
|
||||
unmute_and_set_level "$1" "CD" "80%"
|
||||
unmute_and_set_level "$1" "PC Speaker" "100%"
|
||||
|
||||
mute_and_zero_level "$1" "Mic"
|
||||
mute_and_zero_level "$1" "IEC958" # Ubuntu #19648
|
||||
|
||||
# Intel P4P800-MX
|
||||
switch_control "$1" "Master Playback Switch" on
|
||||
switch_control "$1" "Master Surround" on
|
||||
|
||||
# Trident/YMFPCI/emu10k1:
|
||||
unmute_and_set_level "$1" "Wave" "80%"
|
||||
unmute_and_set_level "$1" "Music" "80%"
|
||||
unmute_and_set_level "$1" "AC97" "80%"
|
||||
|
||||
# DRC:
|
||||
unmute_and_set_level "$1" "Dynamic Range Compression" "80%"
|
||||
|
||||
# Required for HDA Intel (hda-intel):
|
||||
unmute_and_set_level "$1" "Front" "80%"
|
||||
|
||||
# Required for SB Live 7.1/24-bit (ca0106):
|
||||
unmute_and_set_level "$1" "Analog Front" "80%"
|
||||
|
||||
# Required at least for Via 823x hardware on DFI K8M800-MLVF Motherboard
|
||||
switch_control "$1" "IEC958 Capture Monitor" off
|
||||
|
||||
# Required for hardware allowing toggles for AC97 through IEC958,
|
||||
# valid values are 0, 1, 2, 3. Needs to be set to 0 for PCM1.
|
||||
unmute_and_set_level "$1" "IEC958 Playback AC97-SPSA" "0"
|
||||
|
||||
# Required for newer Via hardware
|
||||
unmute_and_set_level "$1" "VIA DXS,0" "80%"
|
||||
unmute_and_set_level "$1" "VIA DXS,1" "80%"
|
||||
unmute_and_set_level "$1" "VIA DXS,2" "80%"
|
||||
unmute_and_set_level "$1" "VIA DXS,3" "80%"
|
||||
|
||||
# Required on some notebooks with ICH4:
|
||||
switch_control "$1" "Headphone Jack Sense" off
|
||||
switch_control "$1" "Line Jack Sense" off
|
||||
|
||||
# Some machines need one or more of these to be on;
|
||||
# others need one or more of these to be off:
|
||||
|
||||
switch_control "$1" "Audigy Analog/Digital Output Jack" on
|
||||
switch_control "$1" "SB Live Analog/Digital Output Jack" on
|
||||
|
||||
# D1984 -- Thinkpad T61/X61
|
||||
switch_control "$1" "Speaker" on
|
||||
switch_control "$1" "Headphone" on
|
||||
|
||||
# HDA-Intel w/ "Digital" capture mixer (See Ubuntu #193823)
|
||||
unmute_and_set_level "$1" "Digital" "80%"
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
# $1 <card ID> | "all"
|
||||
sanify_levels() {
|
||||
local ttsdml_returnstatus=0
|
||||
local card
|
||||
case "$1" in
|
||||
all)
|
||||
for card in $(echo_card_indices); do
|
||||
sanify_levels_on_card "$card" || ttsdml_returnstatus=1
|
||||
done
|
||||
;;
|
||||
*)
|
||||
sanify_levels_on_card "$1" || ttsdml_returnstatus=1
|
||||
;;
|
||||
esac
|
||||
return "$ttsdml_returnstatus"
|
||||
}
|
||||
|
||||
# List all cards that *should* be usable for PCM audio. In my experience,
|
||||
# the console speaker (handled by the pcsp driver) isn't a suitable playback
|
||||
# device, so we'll exclude it.
|
||||
list_non_pcsp_cards() {
|
||||
for card in $(echo_card_indices); do
|
||||
local cardfile="/proc/asound/card${card}/id"
|
||||
if [[ -r "$cardfile" && -f "$cardfile" && "$(cat "$cardfile")" != pcsp ]]; then
|
||||
echo "$card"
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
# Properly initialize the sound card so that we have audio at boot.
|
||||
unmute_all_cards() {
|
||||
sanify_levels all
|
||||
}
|
||||
|
||||
is_numeric() {
|
||||
local str="$1"
|
||||
[[ "$str" =~ ^[0-9]+$ ]]
|
||||
}
|
||||
|
||||
set_default_card() {
|
||||
local card="$1"
|
||||
sed -e "s/%card%/$card/g" </usr/local/share/livecd-sound/asound.conf.in \
|
||||
>/etc/asound.conf
|
||||
}
|
||||
|
||||
play_on_card() {
|
||||
local card="$1" file="$2"
|
||||
aplay -q "-Dplughw:$card,0" "$file"
|
||||
}
|
||||
|
||||
# If there are multiple usable sound cards, prompt the user to choose one,
|
||||
# using auditory feedback.
|
||||
pick_a_card() {
|
||||
set -f
|
||||
usable_cards="$(list_non_pcsp_cards)"
|
||||
num_usable_cards="$(wc -w <<<"$usable_cards")"
|
||||
|
||||
if (( num_usable_cards == 1 )); then
|
||||
systemd-cat -t "livecdsound" printf "Only one sound card is detected\n"
|
||||
exit 0
|
||||
fi
|
||||
systemd-cat -t "livecdsound" printf "multiple sound cards detected\n"
|
||||
for card in "${usable_cards[@]}"; do
|
||||
if ! is_numeric "$card"; then
|
||||
continue
|
||||
fi
|
||||
play_on_card "$card" /usr/share/livecd-sounds/pick-a-card.wav &
|
||||
done
|
||||
wait
|
||||
sleep 1
|
||||
for card in "${usable_cards[@]}"; do
|
||||
if ! is_numeric "$card"; then
|
||||
continue
|
||||
fi
|
||||
play_on_card "$card" /usr/share/livecd-sounds/beep.wav
|
||||
if read -r -t 10; then
|
||||
systemd-cat -t "livecdsound" printf "Selecting %s sound card as default\n" "$card"
|
||||
set_default_card "$card"
|
||||
break
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
if (( $# == 0 )); then
|
||||
echo "error: No argument passed."
|
||||
exit 1
|
||||
fi
|
||||
while [[ "${1}" != "" ]]; do
|
||||
case ${1} in
|
||||
-h|--help)
|
||||
usage
|
||||
exit
|
||||
;;
|
||||
-u|--unmute)
|
||||
systemd-cat -t "livecdsound" printf "Unmuting all cards"
|
||||
unmute_all_cards
|
||||
;;
|
||||
-p|--pick)
|
||||
pick_a_card
|
||||
;;
|
||||
*)
|
||||
echo "error: Unsupported argument"
|
||||
usage
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
@@ -0,0 +1 @@
|
||||
1.4.1
|
||||
Reference in new issue
Block a user