Hello tout le monde,
j’ai un script qui doit être lancé grâce à l’autostart d’openbox, mais qui ne se lance pas.
Il s’agit d’une sorte de “daemon” qui rafraichit l’arrière plan du bureau.
C’est depuis l’ajout de la condition ci-dessous :
if [[ "$1" = "start" || "$1" = "restart" ]]
then if [ "$( ps aux | grep 'dyn_wp.sh execute' | grep -vc 'grep' )" = "0" ]
then ( $scr_dir execute > /dev/null 2>&1 & )
echo "Dyn_wp [$1]"
else echo "Dyn_wp est déjà démarré!"
fi
fi
Rien ne se passe au démarrage le grep ne ressort rien.
Auriez vous une idée svp ?
Merci d’avance.
PS:
le script complet :
[code]#!/bin/bash
PATH=/sbin:/bin:/usr/bin:
scr_dir=$( echo “$PWD$( echo $0 | sed ‘s/^.//’ )”)
S_act=$( date -u ‘+%s’ )
if [ “$1” = “configure” ]
then prog=$( which bc xplanet convert composite feh | grep -c ‘/’)
if [ “$prog” = “5” ]
then if [ ! -d “$HOME/.dyn_wp/” ]; then mkdir “$HOME/.dyn_wp/”; fi
cd "$HOME/.dyn_wp/“
if [ -f “dyn_wp.conf” ]; then for i in cat dyn_wp.conf | grep -P '[^#]'
; do export $i ; done ; fi
conf=( )
sup=”“
clear
echo -e “--------Configuration de DYN_WP--------\n\n"
read -p “Résolution en x (largeur en px) [$res_x]:” conf[0]
read -p “Résolution en y (longueur en px) [$res_y]:” conf[1]
read -p “Temps de rechargement en minutes [$reload]:” conf[2]
read -p “Faire une image à la taille de la résolution (0/1) [$full_img]:” conf[3]
if [[ “${conf[3]}” = “1” || “${conf[3]}” = “” ]]
then read -p “Couleur du dégradé circulaire en anglais [$color_gradient]:” conf[4]
read -p “hauteur en pixel de l’image satellite par rapport à l’écran [$gap_y_top]:” conf[5]
read -p “hauteur en pixel entre le bas de l’écran et les informations spatiales (lune et information soleil) [$gap_y_bottom]:” conf[6]
sup=”\ncolor_gradient=${conf[4]:=$color_gradient}\ngap_y_top=${conf[5]:=$gat_y_top}\ngap_y_bottom=${conf[6]:=$gat_y_bottom}”
fi
echo -e “res_x=${conf[0]:=$res_x}\nres_y=${conf[1]:=$res_y}\nreload=${conf[2]:=$reload}\nfull_img=${conf[3]:=$full_img}$sup” > dyn_wp.conf
if [ ! -f “dl” ]; then echo -n “0 0” > dl; fi
if [ ! -f “alert.conf” ]; then echo -n “0 6” > alert.conf; fi
else echo "il vous manque des programmes essentiels: bc, xplanet, image-magick"
fi
fi
if [ -f “$HOME/.dyn_wp/dyn_wp.conf” ]
then cd "$HOME/.dyn_wp/"
if [[ “$1” = “execute” ]]
then echo $$ > pid
while true
do
function mkt {
mois="January01February02March03April04May05June06July07August08September09October10November11December12"
if [[ “${#3}” = “1” ]]; then j=“0$3”; else j=$3; fi
date -d “$1$( echo “$mois” | sed -r “s/.$2([0-9]+)./\1/”)$j $4” “+%s”
}
function lat2px {
echo “$2*(90-($1))/360” | bc | sed -r ‘s/…+//’
}
function long2px {
echo “$2*($1+180)/360” | bc | sed -r ‘s/…+//’
}
for i in cat dyn_wp.conf | grep -P '[^#]'
; do export $i ; done
ddl=( $( cat dl ) )
wget http://www.swpc.noaa.gov/ftpdir/latest/curind.txt -O kp
wget http://earthquake.usgs.gov/earthquakes/catalogs/eqs1day-M2.5.txt -O eq
wget http://www.swpc.noaa.gov/ftpdir/indices/events/events.txt -O se
if (( “$(( $S_act - ${ddl[0]} ))” >= “$(( 3600 * 3 ))” ))
then wget http://www.narrabri.atnf.csiro.au/operations/NASA/clouds_2048.jpg -O clouds.jpg
ddl[0]=$S_act
else echo "Sat picture: already up to date"
fi
if (( “$(( $S_act - ${ddl[1]} ))” >= “$(( 3600 * 4 ))” ))
then wget http://tycho.usno.navy.mil/cgi-bin/phase.gif -O phase.gif
ddl[1]=$S_act
else echo "Lunar picture: already up to date"
fi
echo ${ddl[@]} > dl
mag_max=( 0 0 )
while read line; do
eval “d=( “$line” )“
dif=$(( $S_act - ${d[0]} ))
if [[ $( echo ${d[3]}10 | bc | sed -r ‘s/.[0]+$//’) -ge “60” ]]
then LAB+=( " -draw “text $( echo ${d[2]}-10 | bc ),$( echo ${d[1]}+5 | bc ) ‘${d[3]}’”" )
fi
if [[ $dif -lt “86400” ]]
then gf=$( echo $dif128/86400 | bc )
gs=$( echo $dif128/86400+127 | bc )
colf="rgb(255,$gf,0)"
cols="rgb(255,$gs,0)"
else colf="rgb(255,128,0)"
cols="rgb(255,255,0)"
fi
COM_eq=( “-fill ‘$colf’ -stroke ‘$cols’ -strokewidth 2% -draw 'circle ${d[2]},${d[1]} ${d[2]},”$( echo ${d[3]}^30.06+${d[1]} | bc )”’” “${COM_eq[@]}” )
if (( $( echo “${mag_max[0]}<${d[3]}” | bc ) == 1 )); then mag_max=( ${d[3]} ${d[0]} ); fi
done < <(sed -rn 's/.+\s+([a-zA-Z]+)\s+([0-9]+),\s+([0-9]+)\s+([0-9]+:[0-9]+:[0-9]+).+,(-?[0-9]+\.[0-9]+),(-?[0-9]+\.[0-9]+),([0-9]+\.[0-9]+),[0-9]+\.[0-9]+,.+/$( mkt \3 \1 \2 \4) $( lat2px \5 $res_x ) $( long2px \6 $res_x ) \7/p' eq )
sup=""
if [[ "$full_img" = "1" ]]
then COM_xfla=( )
xfla_arr=( $( grep -Po '[ABCMX][0-9]{1,2}[\.][0-9]' se | sort -ur ) )
kp_arr=( $( tail -1 kp ) )
for i in {9..16}
do
if [[ ${kp_arr[$i]} < "4" ]]
then col="green"
elif [[ ${kp_arr[$i]} = "4" ]]
then col="yellow"
elif [[ ${kp_arr[$i]} > "4" ]]
then col="red"
else col="0"
fi
if [[ "$col" != "0" ]]
then COM_xfla+=( "-fill $col -draw 'rectangle $(( 20 + ( $i - 8 ) * 8 )),$(( $res_y - $gap_y_bottom - ${kp_arr[$i]} * 5 )) $(( 26 + ( $i - 8 ) * 8 )),$(( $res_y - $gap_y_bottom ))'" )
fi
done
if [[ "$color_gradient" = "random" ]]
then rcol=( red orange yellow green cyan blue purple brown white grey violet)
rand=$RANDOM
let "rand %= 11"
color_gradient=${rcol[$rand]}
fi
sup=$( date -d "1970-01-01 UTC + ${mag_max[1]} seconds" "+ -fill '${color_gradient:-white}' -gravity NorthEast -draw \"text 0,20 ' M ${mag_max[0]}: %d/%m/%y %T UTC'\"" )
eval convert -size ${res_x}x${res_y} radial-gradient:${color_gradient}-black -strokewidth 0 ${COM_xfla[@]} -fill ${color_gradient} -draw "\"text $(( $res_x / 2 )),$(( $res_y - 50 - $gap_y_bottom ))'"$( date '+%d/%m/%y %T' )"'\"" -pointsize 14 -fill red "-draw \"text 100,$(( ${res_y} - 25 - $gap_y_bottom )) '${xfla_arr[0]}'\" -fill $color_gradient -gravity NorthEast -draw \"text 5,0 '"$(date -d "1970-01-01 UTC + ${mag_max[1]} seconds" "+M ${mag_max[0]}: %d/%m/%y %T UTC")"'\"" wallpaper.png
composite -gravity SouthEast -geometry +30+$(( $gap_y_bottom - 10 )) phase.gif wallpaper.png wallpaper.png
else convert -size ${res_x}x$(( ${res_x} / 2 )) xc:none wallpaper.png
fi
xplanet -num_times 1 -config overlay_clouds -projection rectangular -quality 100 -geometry ${res_x}x$(( ${res_x} / 2 )) -output sat.png
COM_eq="convert -size ${res_x}x$(( ${res_x} / 2 )) xc:transparent ${COM_eq[@]} -channel RGBA -blur 3x3 -strokewidth 0 ${LAB[@]} eq.png"
eval $COM_eq
convert wallpaper.png \
sat.png -gravity North -geometry +0+${gap_y_top:-0} -composite \
eq.png -gravity North -geometry +0+${gap_y_top:-0} -composite wallpaper.png
feh --bg-max wallpaper.png
echo "done, next update: $reload minutes"
sleep ${reload}m
done
fi
if [[ "$1" = "stop" || "$1" = "restart" ]]
then if [ "$( ps aux | grep 'dyn_wp.sh execute' | grep -vc 'grep' )" = "0" ]
then echo "Dyn_wp n'est pas démarré!"
exit
else kill -9 $( cat pid )
echo "Dyn_wp [$1]"
fi
fi
if [[ "$1" = "start" || "$1" = "restart" ]]
then if [ "$( ps aux | grep 'dyn_wp.sh execute' | grep -vc 'grep' )" = "0" ]
then ( $scr_dir execute > /dev/null 2>&1 & )
echo "Dyn_wp [$1]"
else echo "Dyn_wp est déjà démarré!"
fi
fi
else echo "executer dyn_wp.sh configure"
fi
[/code]