Bon, voici le Wallpaper terminé, tout du moins pour le moment
Voici :
Alors, pour le fond d'écran, c'est ici.
Après, pour pouvoir executer des scripts sur le Wallpaper (cotation des indices) c'est ici.
Enfin, pour l'écriture et l'enregistrement de scripts SH, c'est ici.
1/. Ouvrez un nouveau script via Fraise puis mettez le code ci-suit :
Code :
- #!/bin/bash
- OUTPTYPE=$1
- TICKFILE=$2
- ping -c 1 www.google.com >/dev/null 2>&1
- ret="$?"
- if [ "$ret" = "0" ]; then
- rm /tmp/geektool/CotationCAC40
- cat $TICKFILE | while read line
- do
- tmp="${line:0:1}"
-
- if [ $tmp != "#" ]; then
- MARKET=`echo "${line}" | cut -d " " -f1`
- SYMBOL=`echo "${line}" | cut -d " " -f2`
-
- if [ "$MARKET" = "INDEXEURO:PX1" ]; then
- URL=http://www.google.com/finance?q=$MARKET
- else
- echo "Pas de données"
- fi
- curl --silent $URL > /tmp/geektool/$SYMBOL.stock
- COMPID=`grep 'var _companyId =' /tmp/geektool/$SYMBOL.stock | cut -d '=' -f2 | cut -d ';' -f1 | cut -d " " -f2`
- STKVAL=`grep "ref_$COMPID\_l" /tmp/geektool/$SYMBOL.stock | cut -d ">" -f2 | cut -d "<" -f1 | sed 's/,//g'`
- CHANGEVAL=`grep "id=\"ref_$COMPID\_c" /tmp/geektool/$SYMBOL.stock | cut -d ">" -f3 | cut -d "<" -f1`
- PNE=${CHANGEVAL:0:1}
- CHANGEPER=`grep "id=\"ref_$COMPID\_cp" /tmp/geektool/$SYMBOL.stock | cut -d ">" -f2 | cut -d "<" -f1 | sed 's/(//g' | sed 's/)//g'`
-
- if [ $PNE == "-" ]; then
- BCOL="-"
- elif [ $PNE == "+" ]; then
- BCOL="+"
- else
- BCOL="="
- fi
- if [ $OUTPTYPE == "-n" ]; then
- echo $SYMBOL: $CHANGEPER >> /tmp/geektool/CotationCAC40
- elif [ $OUTPTYPE == "-c" ]; then
- echo $BCOL";"$SYMBOL";"$STKVAL";"$CHANGEPER >> /tmp/geektool/CotationCAC40
- fi
- fi
- done
- if [ $OUTPTYPE == "-n" ]; then
- (printf "%s\t%s\t%s\t%s\n"; cat /tmp/geektool/CotationCAC40) | column -t
- elif [ $OUTPTYPE == "-c" ]; then
- awk 'BEGIN{
- FS=";";
- }{
- if ($1 == "+" )
- printf "\033[42;1;30m%-2s%-8s%-8s%-8s\n"," " $2 " : ",$3,"+"$4,$5 " ";
- else if ($1 == "-" )
- printf "\033[41;1;37m%-2s%-8s%-8s%-8s\n"," " $2 " : ",$3,$4,$5 " ";
- else
- printf "%-2s%-8s%-8s%-8s\n"," " $2 " : ",$3,$4,$5 " ";
- }' /tmp/geektool/CotationCAC40
- fi
-
- else
- echo "Pas de réseau Internet"
- fi
|
2/. Enregitrez le script sous CotationCAC40.sh (par exemple).
3/. Ouvrez un second script via FRAISE qui va contenir le ticker Google ainsi que le Nom de l'indice (séparé d'un espace) :
Code :
- INDEXEURO:PX1 CAC40
|
4/. Enregistrez sous TickerCAC40 (par exemple).
5/. Ouvrez GeekTool, icone SHELL (click/glisser sur le Bureau), avec rafraichissement de x secondes (au choix, >0), en command ajoutez ceci :
Code :
- /Chemin du fichier/CotationCAC40.sh -c /Chemin du fichier/TickerCAC40
|
la commande -c peut être remplacée par -n si vous ne voulez pas de changement de couleur du cadre (rouge/vert - transparent).
Note.
Peut être vous faudra-t-il les droits d'execution sur le script CotationCAC40.sh, soit dans le terminal faites un chmod +x ou chmod +755
Important
Dans le terminal, tapez pour la première fois :
Code :
- mkdir /tmp/geektool
- touch /tmp/geektool/CotationCAC40
|
Afin de vérifier que les scripts chargés issus de Google sont bien dans le dossier /geektool du dossier /temp de votre Mac…
Pour les autres indices, suffit de changer dans le script "$MARKET" = "INDEXEURO:PX1" par un autre ticker et de changer les arborescences /tmp/geektool/CotationCAC40 Par un autre nom (CotationNASDAQ, etc.) et idem pour le fichier TickerXXX, et la commande dans Geektool
Bonne nuit
P.S. dans le script j'ai "désactivé" certaines variables, comme les variations en points des indices (en plus des pourcentages). A noter que dans un seul de ces scripts on peut facilement afficher tout une liste d'indices en une seule fois aussi… 