variable courte pour les hauteur et largeur

variable courte pour l'icône de borg
This commit is contained in:
Djan GICQUEL 2021-08-04 14:19:59 +02:00
parent 1ddcfcd88f
commit 15b08837a4
1 changed files with 30 additions and 28 deletions

View File

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