Le script ne chargeait que /usr/local/share/fws/wofi-style.css, resté en Catppuccin bleu sur les machines déjà installées, alors que le style violet du thème vit dans ~/.config/wofi/style.css. Le style est désormais résolu par ordre de préférence, ce qui aligne le menu Super+X sur le menu d'applications Super+R sans dépendre d'un fichier système qui peut être obsolète. 🤖 Generated with Codebuff Co-Authored-By: Codebuff <noreply@codebuff.com>
69 lines
2.3 KiB
Python
Executable File
69 lines
2.3 KiB
Python
Executable File
#!/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
|
|
|
|
# Style passé à wofi, par ordre de préférence : d'abord le style violet
|
|
# installé par le thème dans le profil utilisateur (Super+X — alimentation —
|
|
# et Super+R — applications — partagent ainsi le même look), sinon le style
|
|
# système FWS s'il est présent.
|
|
_WOFI_STYLE_CANDIDATES = (
|
|
os.path.expanduser("~/.config/wofi/style.css"),
|
|
"/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"]
|
|
style = next((s for s in _WOFI_STYLE_CANDIDATES
|
|
if os.path.exists(s)), None)
|
|
if style:
|
|
cmd += ["--style", 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())
|