64 lines
1.7 KiB
Bash
64 lines
1.7 KiB
Bash
|
#!/bin/bash
|
||
|
|
||
|
# Chemin du fichier profiles.ini
|
||
|
PROFILES_INI="$HOME/.cachy/profiles.ini"
|
||
|
|
||
|
# Vérifier si le fichier profiles.ini existe
|
||
|
if [ ! -f "$PROFILES_INI" ]; then
|
||
|
yad --error --text="Le fichier profiles.ini n'existe pas : $PROFILES_INI"
|
||
|
exit 1
|
||
|
fi
|
||
|
|
||
|
# Extraire les noms des profils depuis le fichier profiles.ini
|
||
|
PROFILS=()
|
||
|
while IFS= read -r line; do
|
||
|
if [[ "$line" =~ ^Name= ]]; then
|
||
|
PROFILS+=("${line#Name=}")
|
||
|
fi
|
||
|
done <<< "$(grep "^Name=" "$PROFILES_INI")"
|
||
|
|
||
|
# Si aucun profil n'a été trouvé
|
||
|
if [ ${#PROFILS[@]} -eq 0 ]; then
|
||
|
yad --error --text="Aucun profil trouvé dans le fichier profiles.ini."
|
||
|
exit 1
|
||
|
fi
|
||
|
|
||
|
# DEBUG
|
||
|
#for profil in "${PROFILS[@]}"; do
|
||
|
# echo "DEBUG Profil trouvé : $profil"
|
||
|
#done
|
||
|
|
||
|
# Générer les boutons pour Yad
|
||
|
BUTTONS=""
|
||
|
for i in "${!PROFILS[@]}"; do
|
||
|
BUTTONS+="--button=${PROFILS[i]}:$((i+1)) "
|
||
|
done
|
||
|
|
||
|
# Exécuter Yad avec les boutons générés
|
||
|
yad --form --title="Choisissez un profil" --text="Sélectionnez un profil pour démarrer Cachy Browser :" --buttons-layout=center $BUTTONS
|
||
|
|
||
|
CHOIX=$?
|
||
|
|
||
|
# DEBUG
|
||
|
#echo "DEBUG liste boutons = $BUTTONS"
|
||
|
#echo "DEBUG CHOIX brut = $CHOIX"
|
||
|
#echo "DEBUG Index utilisé pour PROFILS = $((CHOIX-1))"
|
||
|
#echo "DEBUG Profil sélectionné = ${PROFILS[$((CHOIX-1))]}"
|
||
|
|
||
|
# Quitter si fermeture fenêtre
|
||
|
if [ $CHOIX = 252 ]; then exit; fi
|
||
|
|
||
|
# Vérifier si un bouton a été cliqué
|
||
|
if [ $CHOIX != 0 ]; then
|
||
|
# Récupérer le profil correspondant au bouton cliqué
|
||
|
SELECTION="${PROFILS[$((CHOIX-1))]}"
|
||
|
# Ouvrir le navigateur avec le profil sélectionné
|
||
|
cachy-browser -P "$SELECTION" $1 &
|
||
|
else
|
||
|
yad --error --text="Aucun profil sélectionné."
|
||
|
exit 1
|
||
|
fi
|
||
|
|
||
|
# DEBUG
|
||
|
#echo "DEBUG Profil sélectionné : $SELECTION"
|