diff --git a/applications/install.sh b/applications/install.sh new file mode 100644 index 0000000..934071e --- /dev/null +++ b/applications/install.sh @@ -0,0 +1,11 @@ +#!/bin/bash +# desktop apps +cp ~/.linux-env/applications/*/*.desktop ~/.local/share/applications/ +cp ~/.linux-env/applications/*/*.sh ~/.local/bin/ +cp ~/.linux-env/applications/*/*.svg ~/.local/share/icons/ + +chmod +x ~/.local/share/applications/*.desktop +chmod +x ~/.local/bin/*.sh + +update-desktop-database ~/.local/share/applications/ +gtk-update-icon-cache ~/.local/share/icons/ # inutile sauf si tu fais un vrai thème d'icônes diff --git a/.bashrc b/bashrc/.bashrc similarity index 96% rename from .bashrc rename to bashrc/.bashrc index 22108fa..bf168b8 100644 --- a/.bashrc +++ b/bashrc/.bashrc @@ -1,6 +1,8 @@ +# .linux-env alias dlmusic='MUSIC_PATH="/mnt/media/music/evilspins/$(date +"%Y")" && mkdir -p $MUSIC_PATH && NOW=$(date +"%Y%m%d%H") && pip install -U yt-dlp && yt-dlp -f bestaudio -x --audio-format mp3 --audio-quality 0 -o $MUSIC_PATH"/"$NOW"__%(title)s__%(artist)s__%(id)s.%(ext)s" $1' alias dlvideo='VIDEO_PATH="/mnt/media/video/autre" && cd "$VIDEO_PATH" && pip install -U yt-dlp && yt-dlp -f "bestvideo[ext=mp4]+bestaudio[ext=m4a]/mp4" --merge-output-format mp4 "$@"' alias dlfilm='VIDEO_PATH="/mnt/media/video/film" && yt-dlp -o $VIDEO_PATH $1' alias dlimage='IMAGE_PATH="/mnt/media/image/screenshit" && wget -P $IMAGE_PATH $1' alias search='find ./ -iname "*$1*"' alias searchinside='grep -rwl "*$1*" ./' +# .linux-env diff --git a/bashrc/install.sh b/bashrc/install.sh new file mode 100644 index 0000000..33375e2 --- /dev/null +++ b/bashrc/install.sh @@ -0,0 +1,4 @@ +#!/bin/bash + +sed -i '/# .linux-env/,/# .linux-env/d' ~/.bashrc +cat ~/.linux-env/bashrc/.bashrc >> ~/.bashrc diff --git a/gamecube-pad/gamecube-pad.service b/gamecube-pad/gamecube-pad.service deleted file mode 100644 index cd110c8..0000000 --- a/gamecube-pad/gamecube-pad.service +++ /dev/null @@ -1,13 +0,0 @@ -[Unit] -Description=Pad Dolphin Watcher Service (User) -After=graphical.target - -[Service] -Type=simple -ExecStart=/usr/bin/python3 /home/%u/.local/bin/gamecube-pad.py -Restart=always -RestartSec=3 -WorkingDirectory=/home/%u - -[Install] -WantedBy=default.target diff --git a/gamecube-pad/install.sh b/gamecube-pad/install.sh index 8734018..e81c0f2 100755 --- a/gamecube-pad/install.sh +++ b/gamecube-pad/install.sh @@ -1,46 +1,77 @@ #!/bin/bash set -e -SERVICE_NAME="gamecube-pad.service" -SERVICE_PATH="$HOME/.config/systemd/user/gamecube-pad.service" -PYTHON_SCRIPT="/home/$USER/.local/bin/gamecube-pad.py" +PYTHON_SCRIPT="$HOME/.local/bin/gamecube-pad.py" +AUTOSTART_DIR="$HOME/.config/autostart" +AUTOSTART_FILE="$AUTOSTART_DIR/gamecube-pad.desktop" -install_service() { - echo "[+] Installation des dépendances..." - sudo apt install -y python3-evdev python3-uinput xdotool wmctrl +SILENT=false +if [[ "$1" == "silent" ]]; then + SILENT=true +fi - echo "[+] Copie du script Python..." - mkdir -p "$(dirname "$PYTHON_SCRIPT")" - cp gamecube-pad.py "$PYTHON_SCRIPT" - chmod +x "$PYTHON_SCRIPT" - - echo "[+] Copie du fichier systemd utilisateur..." - mkdir -p "$HOME/.config/systemd/user" - cp gamecube-pad.service "$SERVICE_PATH" - - echo "[+] Activation du service..." - systemctl --user daemon-reload - systemctl --user enable gamecube-pad.service - systemctl --user restart gamecube-pad.service - - echo "[✓] Installation terminée. Consultez les logs avec : journalctl --user -u gamecube-pad.service -f" +log() { + if [ "$SILENT" = false ]; then + echo "$@" + fi } -uninstall_service() { - echo "[+] Arrêt et suppression du service..." - systemctl --user stop gamecube-pad.service || true - systemctl --user disable gamecube-pad.service || true - rm -f "$SERVICE_PATH" +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" </dev/null + install_script &>/dev/null ;; *) - install_service + install_script ;; esac diff --git a/install.sh b/install.sh index 0b2d5e9..b5a13c7 100755 --- a/install.sh +++ b/install.sh @@ -1,10 +1,16 @@ -# desktop apps -cp ./applications/*/*.desktop ~/.local/share/applications/ -cp ./applications/*/*.sh ~/.local/bin/ -cp ./applications/*/*.svg ~/.local/share/icons/ +#!/bin/bash +set -e -chmod +x ~/.local/share/applications/*.desktop -chmod +x ~/.local/bin/*.sh +# Chemin de base : le dossier où se trouve ce script +BASE_DIR="$(dirname "$(realpath "$0")")" -update-desktop-database ~/.local/share/applications/ -# gtk-update-icon-cache ~/.local/share/icons/ # inutile sauf si tu fais un vrai thème d'icônes +echo "[+] Recherche et exécution des install.sh..." + +# Boucle récursive sur tous les fichiers install.sh +find "$BASE_DIR" -type f -name "install.sh" ! -path "$BASE_DIR/install.sh" | while read -r script; do + echo "[+] Lancement : $script" + chmod +x "$script" + "$script" +done + +echo "[✓] Tous les install.sh ont été exécutés."