add home to repo
This commit is contained in:
77
home/gamecube-pad/install.sh
Executable file
77
home/gamecube-pad/install.sh
Executable file
@@ -0,0 +1,77 @@
|
||||
#!/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 l’installer 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
|
||||
Reference in New Issue
Block a user