import time
import usb_hid
from adafruit_hid.keyboard import Keyboard
from adafruit_hid.keycode import Keycode
from adafruit_hid.keyboard_layout_win_fr import KeyboardLayoutFR # Layout AZERTY
# Initialisation du clavier
kbd = Keyboard(usb_hid.devices)
layout = KeyboardLayoutFR(kbd)
# --- CONFIGURATION ---
MOT_DE_PASSE_SUDO = "votre_mot_de_passe" # Laissez vide "" si vous préférez le taper vous-même
# Applications APT classiques (requis pour installer flatpak lui-même)
LOGICIELS_APT = "curl git flatpak"
# Applications Flatpak (Utilisez les identifiants uniques de Flathub)
# Exemple : Spotify, Discord, et LibreOffice
LOGICIELS_FLATPAK = "com.spotify.Client com.discordapp.Discord org.libreoffice.LibreOffice"
def press_combo(key1, key2, key3=None):
kbd.press(key1)
kbd.press(key2)
if key3:
kbd.press(key3)
time.sleep(0.1)
kbd.release_all()
time.sleep(0.5)
def envoyer_commande(texte):
layout.write(texte)
time.sleep(0.1)
kbd.send(Keycode.ENTER)
time.sleep(0.5)
# --- DÉBUT DE L'AUTOMATISATION ---
time.sleep(3) # Attente après branchement USB
# 1. Ouverture du terminal (Ctrl + Alt + T)
press_combo(Keycode.CONTROL, Keycode.ALT, Keycode.T)
time.sleep(1.5)
# 2. Mise à jour APT et installation du gestionnaire Flatpak
envoyer_commande("sudo apt update && sudo apt install -y " + LOGICIELS_APT)
if MOT_DE_PASSE_SUDO:
envoyer_commande(MOT_DE_PASSE_SUDO)
time.sleep(15) # Temps d'attente pour l'installation d'APT et de Flatpak
# 3. Ajout du dépôt officiel Flathub
envoyer_commande("flatpak remote-add --if-not-exists flathub https://flathub.org")
time.sleep(2)
# 4. Installation massive des applications Flatpak (-y pour valider automatiquement)
# L'option --noninteractive évite que Flatpak ne demande des confirmations de permissions
commande_flatpak = f"flatpak install -y --noninteractive flathub {LOGICIELS_FLATPAK}"
envoyer_commande(commande_flatpak)
# Fin du script
Aucun commentaire:
Enregistrer un commentaire