80 lines
3.0 KiB
Bash
Executable File
80 lines
3.0 KiB
Bash
Executable File
#!/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"
|
|
check "import PySide6" "python3-pyside6 (calibrazione)"
|
|
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/ambicatcher.py" "$BIN/ambicatcher.py"
|
|
install -m 755 "$HERE/backend/ambilight-ctl" "$BIN/ambilight-ctl"
|
|
install -m 755 "$HERE/calibration/ambilight_calibrate.py" "$BIN/ambilight-calibrate"
|
|
|
|
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
|
|
systemctl --user restart ambilight.service # applica eventuali aggiornamenti del backend
|
|
|
|
# ---------------------------------------------------------------- plasmoide
|
|
say "Installo il plasmoide $APPLET_ID"
|
|
TMP="$(mktemp -d)"
|
|
trap 'rm -rf "$TMP"' EXIT
|
|
cp -r "$HERE/package/$APPLET_ID" "$TMP/"
|
|
sed -i -e "s|@CTL@|$BIN/ambilight-ctl|g" \
|
|
-e "s|@CALIBRATE@|$BIN/ambilight-calibrate|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
|