+ff-profsel

This commit is contained in:
T0MuX 2024-12-28 00:39:36 +01:00
parent dca5e75297
commit ae97dd793d
9 changed files with 253 additions and 0 deletions

View file

@ -0,0 +1,11 @@
#!/bin/bash
# Creating directories if missing
mkdir -p ~/.local/bin ~/.local/share/applications
# Copying the good stuff
cp -pv cb-profsel.sh ~/.local/bin/
cp -pv cb-profsel.desktop ~/.local/share/applications/
echo -e "\nCachy Browser Profile Selector is installed. You can use it from your applications list or menu, and use it as the main navigator for a one clic profil selection.\nTo uninstall, simply remove the installed files."

10
ff-profsel/cb-profsel.desktop Executable file
View file

@ -0,0 +1,10 @@
[Desktop Entry]
Version=1.0
Name=Cachy Browser Profile Selector
Exec=$HOME/.local/bin/cb-profsel.sh %u
Icon=cachy-browser
Terminal=false
Type=Application
MimeType=text/html;text/xml;application/xhtml+xml;application/vnd.mozilla.xul+xml;text/mml;x-scheme-handler/http;x-scheme-handler/https;application/x-xpinstall;application/pdf;application/json;
Categories=Network;WebBrowser;
StartupWMClass=cachybrowser

63
ff-profsel/cb-profsel.sh Executable file
View file

@ -0,0 +1,63 @@
#!/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"

View file

@ -0,0 +1,11 @@
#!/bin/bash
# Creating directories if missing
mkdir -p ~/.local/bin ~/.local/share/applications
# Copying the good stuff
cp -pv ff-profsel.sh ~/.local/bin/
cp -pv ff-profsel.desktop ~/.local/share/applications/
echo -e "\nFirefox Profile Selector is installed. You can use it from your applications list or menu, and use it as the main navigator for a one clic profil selection.\nTo uninstall, simply remove the installed files."

11
ff-profsel/ff-profsel.desktop Executable file
View file

@ -0,0 +1,11 @@
[Desktop Entry]
Version=1.0
Name=Firefox Profile Selector
Exec=$HOME/.local/bin/ff-profsel.sh %u
Icon=firefox
Terminal=false
Type=Application
Categories=Network;WebBrowser;
StartupWMClass=firefox
MimeType=text/html;text/xml;application/xhtml+xml;application/xml;
Actions=

63
ff-profsel/ff-profsel.sh Executable file
View file

@ -0,0 +1,63 @@
#!/bin/bash
# Chemin du fichier profiles.ini
PROFILES_INI="$HOME/.mozilla/firefox/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 Firefox :" --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é
firefox -P "$SELECTION" $1 &
else
yad --error --text="Aucun profil sélectionné."
exit 1
fi
# DEBUG
#echo "DEBUG Profil sélectionné : $SELECTION"

View file

@ -0,0 +1,11 @@
#!/bin/bash
# Creating directories if missing
mkdir -p ~/.local/bin ~/.local/share/applications
# Copying the good stuff
cp -pv wf-profsel.sh ~/.local/bin/
cp -pv wf-profsel.desktop ~/.local/share/applications/
echo -e "\nWaterfox Profile Selector is installed. You can use it from your applications list or menu, and use it as the main navigator for a one clic profil selection.\n"

10
ff-profsel/wf-profsel.desktop Executable file
View file

@ -0,0 +1,10 @@
[Desktop Entry]
Version=1.0
Name=Waterfox Profile Selector
Exec=$HOME/.local/bin/wf-profsel.sh %u
Icon=waterfox
Terminal=false
Type=Application
Categories=Network;WebBrowser;
StartupWMClass=waterfox
MimeType=text/html;text/xml;application/xhtml+xml;application/vnd.mozilla.xul+xml;text/mml;x-scheme-handler/http;x-scheme-handler/https;application/x-xpinstall;application/pdf;application/json;

63
ff-profsel/wf-profsel.sh Executable file
View file

@ -0,0 +1,63 @@
#!/bin/bash
# Chemin du fichier profiles.ini
PROFILES_INI="$HOME/.waterfox/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 Waterfox :" --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é
waterfox -P "$SELECTION" $1 &
else
yad --error --text="Aucun profil sélectionné."
exit 1
fi
# DEBUG
#echo "DEBUG Profil sélectionné : $SELECTION"