Files
linux-env/gamecube-pad/install.sh
2025-10-07 09:34:46 +02:00

78 lines
1.7 KiB
Bash
Executable File
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/bin/bash
set -e
PYTHON_SCRIPT="$HOME/.local/bin/gamecube-pad.py"
AUTOSTART_DIR="$HOME/.config/autostart"
AUTOSTART_FILE="$AUTOSTART_DIR/gamecube-pad.desktop"
SILENT=false
if [[ "$1" == "silent" ]]; then
SILENT=true
fi
log() {
if [ "$SILENT" = false ]; then
echo "$@"
fi
}
check_and_install_deps() {
for pkg in evdev uinput; do
if ! python3 -c "import $pkg" &>/dev/null; then
log "[!] Dépendance manquante : $pkg. Installation avec pip..."
python3 -m pip install --user "$pkg" &>/dev/null
fi
done
for cmd in xdotool wmctrl; do
if ! command -v "$cmd" &>/dev/null; then
log "[!] Commande manquante : $cmd. Merci de linstaller via votre gestionnaire de paquets."
fi
done
}
install_script() {
check_and_install_deps
log "[+] Copie du script Python..."
mkdir -p "$(dirname "$PYTHON_SCRIPT")"
cp "$HOME/.linux-env/gamecube-pad/gamecube-pad.py" "$PYTHON_SCRIPT"
chmod +x "$PYTHON_SCRIPT"
log "[+] Création du fichier autostart..."
mkdir -p "$AUTOSTART_DIR"
cat > "$AUTOSTART_FILE" <<EOF
[Desktop Entry]
Type=Application
Exec=$PYTHON_SCRIPT
Hidden=false
NoDisplay=false
X-GNOME-Autostart-enabled=true
Name=GameCube Pad
Comment=Lance le script GameCube Pad au démarrage
EOF
log "[✓] Installation terminée. Le script se lancera automatiquement à l'ouverture de session."
}
uninstall_script() {
log "[+] Suppression du script Python et autostart..."
rm -f "$PYTHON_SCRIPT"
rm -f "$AUTOSTART_FILE"
log "[✓] Désinstallation terminée."
}
case "$1" in
uninstall)
uninstall_script
;;
silent)
SILENT=true
uninstall_script &>/dev/null
install_script &>/dev/null
;;
*)
install_script
;;
esac