Différences
Ci-dessous, les différences entre deux révisions de la page.
Les deux révisions précédentes Révision précédente Prochaine révision | Révision précédente | ||
arriere_plan_dynamique_gnome [Le 31/12/2021, 14:03] wiki-corrector-bot passage de http à https sur les liens externes (détecté et corrigé via le bot wiki-corrector (https://forum.ubuntu-fr.org/viewtopic.php?id=2067892) |
arriere_plan_dynamique_gnome [Le 27/11/2022, 01:33] (Version actuelle) Coeur Noir [Avec Mate] |
||
---|---|---|---|
Ligne 1: | Ligne 1: | ||
- | |||
{{tag>Gnome personnalisation Mate}} | {{tag>Gnome personnalisation Mate}} | ||
Ligne 118: | Ligne 117: | ||
#!/bin/bash | #!/bin/bash | ||
- | if [ $# -eq 0 ] || [ $# -gt 1 ]; then echo "$0 folder" && exit 2; fi | + | usage(){ |
+ | echo "$0 DOSSIER_À_IMAGES" | ||
+ | exit 2 | ||
+ | } | ||
- | # Si chemin absolu alors continue, sinon ajout du dossier courant | + | [[ "$#" -eq 0 ]] && usage |
- | if ! echo $1 | grep -iq "^/"; then | + | [[ "$#" -gt 1 ]] && usage |
- | FOLDER="$(pwd)/$1" | + | |
- | else | + | # on passe en chemin absolu |
- | FOLDER="$1" | + | FOLDER=$(realpath "$1") |
- | fi | + | |
# Test si le dossier est accessible et est un répertoire | # Test si le dossier est accessible et est un répertoire | ||
- | [ ! -d ${FOLDER} ] && echo "Impossible d'acceder a ${FOLDER}" && exit 2 | + | [ ! -d "${FOLDER}" ] && echo "Impossible d'acceder a ${FOLDER}" && exit 2 |
- | [ ! -r ${FOLDER} ] && echo "Impossible d'acceder a ${FOLDER}" && exit 2 | + | [ ! -r "${FOLDER}" ] && echo "Impossible d'acceder a ${FOLDER}" && exit 2 |
- | + | ||
- | # Suppression du slash de fin | + | |
- | FOLDER="$(echo ${FOLDER} | sed 's:\/$::')" | + | |
# Supression des parentheses | # Supression des parentheses | ||
- | find ${FOLDER} -type f -name "*)*" -exec rename 's/\)/_/g' {} \; | + | find "${FOLDER}" -type f -name "*)*" -exec rename 's/\)/_/g' {} \; |
- | find ${FOLDER} -type f -name "*(*" -exec rename 's/\(/_/g' {} \; | + | find "${FOLDER}" -type f -name "*(*" -exec rename 's/\(/_/g' {} \; |
+ | |||
# Supression des espaces | # Supression des espaces | ||
- | find ${FOLDER} -type f -name "* *" -exec rename 's/ /_/g' {} \; | + | find "${FOLDER}" -type f -name "* *" -exec rename 's/ /_/g' {} \; |
+ | |||
# Fichier de sortie | # Fichier de sortie | ||
- | xml_file="${FOLDER}/$(echo ${FOLDER} | sed 's:.*/\(.*\)$:\1:').xml" | + | xml_file="$FOLDER/${FOLDER##*/}.xml" |
- | [ -e ${xml_file} ] && echo "ATTENTION le fichier ${xml_file} existe" && exit 2 | + | |
# Constante | # Constante | ||
STATIC_DURATION='10.0' | STATIC_DURATION='10.0' | ||
TRANSITION_DURATION='5.0' | TRANSITION_DURATION='5.0' | ||
+ | |||
# Initialisation du fichier | # Initialisation du fichier | ||
- | cat > ${xml_file} << EOF_initialisation | + | cat > "${xml_file}" << EOF_initialisation |
<background> | <background> | ||
<starttime> | <starttime> | ||
Ligne 161: | Ligne 158: | ||
</starttime> | </starttime> | ||
EOF_initialisation | EOF_initialisation | ||
+ | |||
# Corps du fichier XML | # Corps du fichier XML | ||
old_file='' | old_file='' | ||
first_file='' | first_file='' | ||
- | for file in ${FOLDER}/*.{png,jpg,jpeg,gif,bmp,svg}; do | + | for file in "${FOLDER}"/*.{png,jpg,jpeg,gif,bmp,svg}; do |
- | [ -z $old_file ] && old_file=$file && first_file=$file && continue | + | [ -z "$old_file" ] && old_file="$file" && first_file="$file" && continue |
- | cat >> ${xml_file} << EOF_static_transition | + | cat >> "${xml_file}" << EOF_static_transition |
<static> | <static> | ||
<duration>${STATIC_DURATION}</duration> | <duration>${STATIC_DURATION}</duration> | ||
Ligne 178: | Ligne 175: | ||
</transition> | </transition> | ||
EOF_static_transition | EOF_static_transition | ||
- | old_file=$file | + | old_file="$file" |
done | done | ||
+ | |||
# Fin du fichier - boucle sur le premier fichier de la liste | # Fin du fichier - boucle sur le premier fichier de la liste | ||
- | cat >> ${xml_file} << EOF_fin_fichier | + | cat >> "${xml_file}" << EOF_fin_fichier |
<static> | <static> | ||
<duration>${STATIC_DURATION}</duration> | <duration>${STATIC_DURATION}</duration> | ||
Ligne 210: | Ligne 207: | ||
* Allez dans le répertoire où se situe le fichier XML personnalisé | * Allez dans le répertoire où se situe le fichier XML personnalisé | ||
* Sélectionnez afficher tous les fichiers | * Sélectionnez afficher tous les fichiers | ||
- | * Sélectionnez le fichier XML | + | * Sélectionnez le fichier XML |
* Cliquez sur « Ouvrir » | * Cliquez sur « Ouvrir » | ||
+ | |||
+ | <note tip>Quelques essais testés sous Ubuntu 22.04 et 22.10 [[https://forum.ubuntu-fr.org/viewtopic.php?pid=22623292#p22623292|par là]].</note> | ||
---- | ---- |