Ambilight per Plasma 6: demone Adalight + plasmoide con slider

- backend/ambicapture.py: cattura Wayland via ScreenCast portal + PipeWire
- backend/ambilightd.py: demone, 47 zone sul bordo superiore, luminosita/contrasto/
  saturazione/banda, invio Adalight su seriale, servizio D-Bus org.enne2.Ambilight
- backend/ambilight-ctl: CLI JSON per il plasmoide
- backend/ambilight.service: avvio automatico (systemd --user)
- package/org.enne2.ambilight: applet vassoio con popup e slider
- install.sh / uninstall.sh senza root
This commit is contained in:
enne2
2026-11-01 13:11:02 +01:00
commit a3b6bc66c9
10 changed files with 1142 additions and 0 deletions
Executable
+74
View File
@@ -0,0 +1,74 @@
#!/usr/bin/env bash
# Installa ambilightd + ambilight-ctl + il plasmoide + il servizio utente.
# Nessun privilegio di root: tutto in ~/.local e ~/.config.
set -euo pipefail
HERE="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
BIN="${XDG_BIN_HOME:-$HOME/.local/bin}"
SYSDIR="$HOME/.config/systemd/user"
APPLET_ID="org.enne2.ambilight"
say() { printf '\033[1;32m==>\033[0m %s\n' "$*"; }
warn() { printf '\033[1;33m[!]\033[0m %s\n' "$*"; }
# ---------------------------------------------------------------- dipendenze
say "Controllo dipendenze Python"
missing=0
check() {
if ! python3 -c "$1" >/dev/null 2>&1; then
warn "manca: $2"
missing=1
fi
}
check "import gi; gi.require_version('Gio','2.0'); gi.require_version('GLib','2.0')" \
"python3-gobject (Gio/GLib)"
check "import gi; gi.require_version('Gst','1.0'); gi.require_version('GstApp','1.0')" \
"GStreamer + python3-gobject (Gst, GstApp)"
check "import dbus" "python3-dbus"
check "import serial" "python3-pyserial"
check "import numpy" "python3-numpy"
if ! gst-inspect-1.0 pipewiresrc >/dev/null 2>&1; then
warn "manca: gstreamer1-plugin-pipewire (pipewiresrc)"
missing=1
fi
if [ "$missing" = 1 ]; then
warn "Installa i pacchetti mancanti (es. sudo dnf install python3-gobject python3-dbus python3-pyserial python3-numpy gstreamer1-plugin-pipewire) e rilancia."
exit 1
fi
# ---------------------------------------------------------------- file
say "Installo il backend in $BIN"
install -d "$BIN"
install -m 755 "$HERE/backend/ambilightd.py" "$BIN/ambilightd.py"
install -m 644 "$HERE/backend/ambicapture.py" "$BIN/ambicapture.py"
install -m 755 "$HERE/backend/ambilight-ctl" "$BIN/ambilight-ctl"
say "Installo il servizio utente"
install -d "$SYSDIR"
install -m 644 "$HERE/backend/ambilight.service" "$SYSDIR/ambilight.service"
systemctl --user daemon-reload
systemctl --user enable --now ambilight.service
# ---------------------------------------------------------------- plasmoide
say "Installo il plasmoide $APPLET_ID"
TMP="$(mktemp -d)"
trap 'rm -rf "$TMP"' EXIT
cp -r "$HERE/package/$APPLET_ID" "$TMP/"
sed -i "s|@CTL@|$BIN/ambilight-ctl|g" "$TMP/$APPLET_ID/contents/ui/main.qml"
if kpackagetool6 --type Plasma/Applet --show "$APPLET_ID" >/dev/null 2>&1; then
kpackagetool6 --type Plasma/Applet --upgrade "$TMP/$APPLET_ID"
else
kpackagetool6 --type Plasma/Applet --install "$TMP/$APPLET_ID"
fi
say "Fatto."
cat <<EOF
Verifica:
systemctl --user status ambilight.service --no-pager
$BIN/ambilight-ctl state
Il plasmoide compare nel vassoio di sistema come "Ambilight" (icona TV).
Al primo avvio del demone il desktop chiede il permesso di condividere lo
schermo: concedilo una volta, viene ricordato.
EOF