diff --git a/borg-gui.sh b/borg-gui.sh index 9521d93..da79b4d 100755 --- a/borg-gui.sh +++ b/borg-gui.sh @@ -1,5 +1,6 @@ #! /bin/bash +# tests de base which zenity if [ "$?" != "0" ]; then echo "Zenity n'est pas installé.";exit @@ -17,8 +18,9 @@ fi export BORG_UNKNOWN_UNENCRYPTED_REPO_ACCESS_IS_OK=yes export BORG_RELOCATED_REPO_ACCESS_IS_OK=yes dossierprofil="$HOME/.config/borg/" -W="600" -H="500" +W="--width=600" +H="--height=500" +iconborg="--window-icon=$HOME/.icons/borg.svg" # FONCTIONS ################################################################################# @@ -26,21 +28,21 @@ TestBorgRepo () { if [ ! -f "config" ]; then TestBorgErr=1 infoerr=$(echo "Impossible de trouver le fichier de configuration borg.") - zenity --width=$W --error --text="$infoerr" + zenity $W --error --text="$infoerr" exit fi if [ ! -d "data" ]; then TestBorgErr=1 infoerr=$(echo "Impossible de trouver le fichier de configuration borg.") - zenity --width=$W --error --text="$infoerr" + zenity $W --error --text="$infoerr" exit fi if [ -d "lock.exclusive" ]; then TestBorgErr=1 infoerr=$(echo "Le dépôt est bloqué, une opération est peut-être en cours") - zenity --width=$W --error --text="$infoerr" + zenity $W --error --text="$infoerr" exit fi } @@ -53,13 +55,13 @@ bobainfoa () { DossierPresent () { if [ ! -d "$1" ]; then inforerror=$(echo "Erreur, le dossier $1 est absent.") - zenity --width=$W --error --text="$inforerror" + zenity $W --error --text="$inforerror" VarDossierPresent="false" fi } ZenityPulsate () { - zenity --width=$W --window-icon=$HOME/.icons/borg.svg --progress --pulsate --auto-close + zenity $W $iconborg --progress --pulsate --auto-close } # Profils et tests @@ -70,21 +72,21 @@ if [ ! $1 = "" ]; then fichierprofil="$1" . "$1" else - fichierprofil=$(ls -1 "$dossierprofil"*.conf | zenity --height=$H --width=$W --window-icon=$HOME/.icons/borg.svg --list --title "Liste des profils" --text "Choisir un profil dans la liste" --hide-header --column "profil") + fichierprofil=$(ls -1 "$dossierprofil"*.conf | zenity $H $W $iconborg --list --title "Liste des profils" --text "Choisir un profil dans la liste" --hide-header --column "profil") . $fichierprofil fi if [ "$fichierprofil" = "" ]; then infoerr=$(echo "Aucun profil choisi.") - zenity --width=$W --error --text="$infoerr" + zenity $W --error --text="$infoerr" exit elif [ "$nomsauvegarde" = "" ]; then infoerr=$(echo "Nom de sauvegarde non défini.") - zenity --width=$W --error --text="$infoerr" + zenity $W --error --text="$infoerr" exit elif [ "$borg_repo" = "" ]; then infoerr=$(echo "Variable \$borg_repo absente") - zenity --width=$W --error --text="$infoerr" + zenity $W --error --text="$infoerr" exit fi @@ -107,8 +109,8 @@ id\nInformation sur le dépôt\n\ ap\nAfficher le profil\n\ --\n------------------------------------------\n\ ed\nEspace disque utilisé : $(df -k --output=pcent $borg_repo | tail -n +2)" \ -| zenity --window-icon=$HOME/.icons/borg.svg --list \ ---height=$H --width=$W \ +| zenity $iconborg --list \ +$H $W \ --title "BORG GUI : $nomsauvegarde" \ --hide-header --hide-column=1 --column "id" --column "choix") @@ -127,26 +129,26 @@ elif [ "$choixmenu" = "cs" ];then borg create $borg_excludes $borg_compress $borg_repo::$borg_archive $borg_dir | ZenityPulsate sync | ZenityPulsate zenity --notification --text "Sauvegarde $nomsauvegarde terminée" - zenity --width=$W --info --text "Sauvegarde $nomsauvegarde terminée" + zenity $W --info --text "Sauvegarde $nomsauvegarde terminée" fi elif [ "$choixmenu" = "ms" ];then # Monter une archive if [ "$filter" = "" ];then - borg_archive=$(borg list --short $borg_repo | zenity --height=$H --window-icon=$HOME/.icons/borg.svg --list --title "Listes des archives" --column "Archive") + borg_archive=$(borg list --short $borg_repo | zenity $H $iconborg --list --title "Listes des archives" --column "Archive") else - borg_archive=$(borg list --short $borg_repo | grep $filter | zenity --height=$H --window-icon=$HOME/.icons/borg.svg --list --title "Listes des archives" --column "Archive") + borg_archive=$(borg list --short $borg_repo | grep $filter | zenity $H $iconborg --list --title "Listes des archives" --column "Archive") fi mkdir $HOME/$borg_archive borg mount $borg_repo::$borg_archive $HOME/$borg_archive | ZenityPulsate - zenity --width=$W --info --text="La sauvegarde est disponible dans le dossier\n$HOME/$borg_archive" + zenity $W --info --text="La sauvegarde est disponible dans le dossier\n$HOME/$borg_archive" elif [ "$choixmenu" = "dm" ];then # Demonter une archive - ptnmontage=$(mount | grep borgfs | cut -d" " -f3 | zenity --width=500 --height=$H --window-icon=$HOME/.icons/borg.svg --list --title "Liste des points de montages" --column "Archive") + ptnmontage=$(mount | grep borgfs | cut -d" " -f3 | zenity --width=500 $H $iconborg --list --title "Liste des points de montages" --column "Archive") if [ "$ptnmontage" != "" ];then fusermount -u $ptnmontage | ZenityPulsate sleep 2 | ZenityPulsate @@ -157,17 +159,17 @@ elif [ "$choixmenu" = "ss" ];then # Supprimmer une archive if [ "$filter" = "" ];then - borg_archive=$(borg list --short $borg_repo | zenity --height=$H --window-icon=$HOME/.icons/borg.svg --list --title "Listes des archives" --column "Archive") + borg_archive=$(borg list --short $borg_repo | zenity $H $iconborg --list --title "Listes des archives" --column "Archive") else - borg_archive=$(borg list --short $borg_repo | grep $filter | zenity --height=$H --window-icon=$HOME/.icons/borg.svg --list --title "Listes des archives" --column "Archive") + borg_archive=$(borg list --short $borg_repo | grep $filter | zenity $H $iconborg --list --title "Listes des archives" --column "Archive") fi if [ "$borg_archive" = "" ];then - zenity --width=$W --info --text "Aucune archive choisie, retour au menu" + zenity $W --info --text "Aucune archive choisie, retour au menu" else borg delete $borg_repo::$borg_archive | ZenityPulsate - zenity --width=$W --info --text="Suppresion de l'archive $borg_archive terminée" + zenity $W --info --text="Suppresion de l'archive $borg_archive terminée" fi @@ -175,15 +177,15 @@ elif [ "$choixmenu" = "is" ];then # Information archive if [ "$filter" = "" ];then - borg_archive=$(borg list --short $borg_repo | zenity --height=$H --window-icon=$HOME/.icons/borg.svg --list --title "Listes des archives" --column "Archive") + borg_archive=$(borg list --short $borg_repo | zenity $H $iconborg --list --title "Listes des archives" --column "Archive") else - borg_archive=$(borg list --short $borg_repo | grep $filter | zenity --height=$H --window-icon=$HOME/.icons/borg.svg --list --title "Listes des archives" --column "Archive") + borg_archive=$(borg list --short $borg_repo | grep $filter | zenity $H $iconborg --list --title "Listes des archives" --column "Archive") fi if [ "$borg_archive" = "" ];then - zenity --width=$W --info --text "Aucune archive choisie, retour au menu" + zenity $W --info --text "Aucune archive choisie, retour au menu" else - zenity --width=$W --info --text="$(borg info $borg_repo::$borg_archive)" | ZenityPulsate + zenity $W --info --text="$(borg info $borg_repo::$borg_archive)" | ZenityPulsate fi elif [ "$choixmenu" = "fi" ];then @@ -194,12 +196,12 @@ elif [ "$choixmenu" = "fi" ];then elif [ "$choixmenu" = "id" ];then # Information sur le dépôt - zenity --width=$W --info --text="$(borg info $borg_repo)" | ZenityPulsate + zenity $W --info --text="$(borg info $borg_repo)" | ZenityPulsate elif [ "$choixmenu" = "ap" ];then # Afficher le profil - zenity --width=$W --height=$H --info --text="$(cd $dossierprofil && cat $fichierprofil)" + zenity $W $H --info --text="$(cd $dossierprofil && cat $fichierprofil)" elif [ "$choixmenu" = "qu" ];then exit