Vous n'êtes pas identifié(e).
L'icône rouge permet de télécharger chaque page du wiki visitée au format PDF et la grise au format ODT →
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 Prochaine révision Les deux révisions suivantes | ||
utilisateurs:tawal:scripts:switch-on-off-dans-le-systray [11/05/2023 01:04] Tawal [Utilisation] |
utilisateurs:tawal:scripts:switch-on-off-dans-le-systray [12/05/2023 21:03] Tawal [Le script] |
||
---|---|---|---|
Ligne 13: | Ligne 13: | ||
Il s'appuie sur le mode notification de //yad//.\\ | Il s'appuie sur le mode notification de //yad//.\\ | ||
Dans le chapitre "Images icônes", vous trouverez des fichiers images pour les icônes ON et OFF. | Dans le chapitre "Images icônes", vous trouverez des fichiers images pour les icônes ON et OFF. | ||
+ | \\ | ||
+ | == Version avec fichier d'état. == | ||
+ | //(Possibilité de mettre les instructions dans le script ou de faire un script extérieur qui viendra lire le fichier d'état.//\\ | ||
<file bash systray_switch> | <file bash systray_switch> | ||
#!/bin/bash | #!/bin/bash | ||
Ligne 27: | Ligne 30: | ||
{ | { | ||
local s="inotifywait -qme close_write ${Switch//\//\\\\/}" | local s="inotifywait -qme close_write ${Switch//\//\\\\/}" | ||
- | kill -15 "$(ps -ef | awk -vs="$s" '$0 ~ s && !/grep/{print $2}')" | + | kill -15 "$(ps -ef | awk -vs="$s" '$0 ~ s && !/awk/{print $2}')" |
} | } | ||
Ligne 80: | Ligne 83: | ||
</file> | </file> | ||
+ | == Version sans fichier d'état == | ||
+ | //(oblige de mettre les instruction On/Off dans ce script).//\\ | ||
+ | <file bash nom.sh> | ||
+ | #!/bin/bash | ||
+ | |||
+ | ### Variables Customisables. | ||
+ | Icon_Off="/home/tawal/Images/Icônes/switch-off.png" | ||
+ | Icon_On="/home/tawal/Images/Icônes/switch-on.png" | ||
+ | |||
+ | ### Créations des canaux de communication | ||
+ | mkfifo fifo fifo2 | ||
+ | exec 8<>fifo 4>fifo 5<fifo 8>&- | ||
+ | exec 9<>fifo2 6>fifo2 7<fifo2 9>&- | ||
+ | rm fifo fifo2 | ||
+ | |||
+ | fd4="/proc/$$/fd/4" | ||
+ | fd5="/proc/$$/fd/5" | ||
+ | fd6="/proc/$$/fd/6" | ||
+ | |||
+ | ### Initialisation de l'état de l'icône. | ||
+ | echo "OFF" >&4 | ||
+ | echo "icon:$Icon_Off" >&6 | ||
+ | |||
+ | ### Fonctions. | ||
+ | _quit () | ||
+ | { | ||
+ | exec 6>"$1" | ||
+ | echo "EOF" >&6 | ||
+ | } | ||
+ | |||
+ | _switch () | ||
+ | { | ||
+ | local etat | ||
+ | exec 4>"$1" 5<"$2" 6>"$3" | ||
+ | read -r etat <&5 | ||
+ | |||
+ | if [ "$etat" = "ON" ] | ||
+ | then | ||
+ | echo "OFF" >&4 | ||
+ | echo "icon:$Icon_Off" >&6 | ||
+ | # | ||
+ | # Actions pour OFF | ||
+ | # | ||
+ | else | ||
+ | echo "ON" >&4 | ||
+ | echo "icon:$Icon_On" >&6 | ||
+ | # | ||
+ | # Actions pour ON | ||
+ | # | ||
+ | fi | ||
+ | } | ||
+ | |||
+ | ### Export des Fonctions et Variables. | ||
+ | export -f _quit _switch | ||
+ | export Icon_On Icon_Off | ||
+ | |||
+ | ### Notification YAD (icône systray). | ||
+ | yad --notification \ | ||
+ | --text "Texte au survol de la souris." \ | ||
+ | --icon-size 64 \ | ||
+ | --no-middle \ | ||
+ | --menu "Switcher!bash -c '_switch $fd4 $fd5 $fd6'|Quitter!bash -c '_quit $fd6'" \ | ||
+ | --command "bash -c '_switch $fd4 $fd5 $fd6'" \ | ||
+ | --listen < <(while read -r <&7; do [ "$REPLY" = "EOF" ] && break; echo "$REPLY"; done) | ||
+ | </file> | ||
===== Images icônes ===== | ===== Images icônes ===== | ||
- | Icône OFF : [[:utilisateurs:tawal:scripts:switch-off.png]]\\ | + | |
- | Icône ON : [[:utilisateurs:tawal:scripts:switch-on.png]] | + | {{https://debian-facile.org/images/file-R477709fd6aaa5940ba2be7b06e643632|Icône ON}}\\ |
+ | {{https://debian-facile.org/images/file-R9815d946627cdf57a09164453a56c84e|Icône OFF}} | ||
===== Utilisation ===== | ===== Utilisation ===== | ||
- | Bah, il ne reste plus qu'à le lancer en début de session ^_^ | + | Bah, il ne reste plus qu'à le lancer en début de session ^_^\\ |
Après adaptation évidemment ... :-P | Après adaptation évidemment ... :-P |