Page 1 sur 2
[cron & feh] Can't open X display (résolu)
Publié : ven. 15 avr. 2011, 01:30
par blacktail
Salut tout le monde,
Je me bats depuis plusieurs heure avec un script qui est rafraichir l'arriere plan de mon bureau toutes les 20 minutes.
A la fin de mon script je me retrouve avec
il execute correctement par le bash mais lorsqu'il est executé par le crontab il me fait cette erreur :
Code : Tout sélectionner
No protocol specified
feh ERROR: Can't open X display. It *is* running, yeah?
J'ai regardé cette page
https://bugs.archlinux.org/task/23706 j'ai tout essayé mais rien y fait.
Mon crontab : */5 * * * * export DISPLAY=:0 && /home/neo/earth/changer.sh
Si vous avez une idée ...
Merci d'avance.
Re: [cron & feh] Can't open X display
Publié : ven. 15 avr. 2011, 09:15
par benjarobin
Tu as essayé la solution du bug report :
Ce qui revient pour toi :
Code : Tout sélectionner
HOME=/home/neo DISPLAY=:0 feh --bg-max /home/neo/earth/wallpaper.jpg
Re: [cron & feh] Can't open X display
Publié : ven. 15 avr. 2011, 11:51
par blacktail
Je viens de tester mais je me retrouve toujours avec la même erreur.
Re: [cron & feh] Can't open X display
Publié : ven. 15 avr. 2011, 13:33
par Wisthler
Perso j'ai un script random-wallpaper.sh qui contient un
puis le crontab utilisateur appelle le script.
Sinon, pour garder le tout en une ligne dans le cron, tu as bien entouré la ligne de "`" pour indiquer qu'il s'agissait bien d'une seule et même commande ?
Dans le même ordre d'idée, t'as essayé de séparé les instructions par des ";" ?
Re: [cron & feh] Can't open X display
Publié : ven. 15 avr. 2011, 20:03
par blacktail
J'ai essayé pas mal de vos options mais il refuse catégoriquement toujours cette même erreur
Re: [cron & feh] Can't open X display
Publié : ven. 15 avr. 2011, 20:11
par benjarobin
Mais que ce passe t'il si tu lance cette commande dans une console (Une chose après l'autre) :
Code : Tout sélectionner
HOME=/home/neo DISPLAY=:0 feh --bg-max /home/neo/earth/wallpaper.jpg
Quel est le contenu de
Re: [cron & feh] Can't open X display
Publié : ven. 15 avr. 2011, 20:42
par blacktail
Lorsque j'essaie cette commande dans lxterminal :
Code : Tout sélectionner
HOME=/home/neo DISPLAY=:0 feh --bg-max /home/neo/earth/wallpaper.jpg
Ce code fonctionne correctement, meme si j'execute changer.sh par lxterminal, mais lorsqu'il s'agit du cron, c'est la que le problème apparait.
le contenu de changer.sh :
Code : Tout sélectionner
#!/bin/bash
export DISPLAY=:0
PATH=/sbin:/bin:/usr/bin
cd /home/neo/earth/
rm eq.gif
wget http://www.opentopia.com/images/cams/world_sunlight_map_rectangular.jpg -O world.jpg
temp=$(stat -c%s world.jpg)
if [[ $temp > 1000 ]]
then rm world_sunlight_Wallpaper.jpg
mv world.jpg world_sunlight_Wallpaper.jpg
fi
convert world_sunlight_Wallpaper.jpg -crop 1560x887+0+0 w_1.jpg
convert world_sunlight_Wallpaper.jpg -crop 40x887+1560+0 w_0.jpg
convert -size 1600x887 xc:black wallpaper.jpg
composite -blend 85 -gravity East w_1.jpg wallpaper.jpg wallpaper.jpg
composite -blend 85 -gravity West w_0.jpg wallpaper.jpg wallpaper.jpg
S_act=$(( $( date -u '+%T' | sed 's/^[0]//' | sed -r 's/[\:]{1}[0]?/ \* 60 + /2'| sed -r 's/[\:]{1}[0]?/ \* 3600 + /' ) + 86400 ))
D_act=$( date -u '+%d' | sed 's/^[0]//' )
wget http://earthquake.usgs.gov/earthquakes/catalogs/eqs1day-M2.5.txt -O eq
COM=( )
LAB=( "-fill black -stroke purple -strokewidth 1 -pointsize 16" )
while read line
do
lat_eq=$( echo $( echo "887*(90-($( echo $line | cut -d' ' -f6 | cut -d',' -f2 )))/180+20"
) | bc )
long_eq=$( echo $( echo "1600*($( echo $line | cut -d' ' -f6 | cut -d',' -f3 )+180)/360" ) | bc )
M_eq=$( echo $line | cut -d' ' -f6 | cut -d',' -f4 )
d_eq=$( echo $M_eq^2*0.4+$lat_eq | bc )
D_eq=$( echo $line | cut -d" " -f3 | sed -r 's/^[0]|,//' )
if [[ $D_act == $D_eq ]]
then ajust=86400
else ajust=0
fi
S_eq=$(( $ajust + $( echo $line | cut -d" " -f5 | sed 's/^[0]//' | sed -r 's/[\:]{1}[0]?/ \* 60 + /2'| sed -r 's/[\:]{1}[0]?/ \* 3600 + /' ) ))
dif=$(( $S_act - $S_eq ))
if [[ $( echo $M_eq*10 | bc | sed -r 's/\.[0]+$//') -ge "60" ]]
then ofxt=$( echo $long_eq-10 | bc )
ofyt=$( echo $lat_eq+5 | bc )
LAB+=( " -draw \"text $ofxt,$ofyt '$M_eq'\"" )
fi
if [[ $dif -lt "86400" ]]
then gf=$( echo $dif*128/86400 | bc )
gs=$( echo $dif*128/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=( "-fill '$colf' -stroke '$cols' -strokewidth 2 -draw 'circle $long_eq,$lat_eq
$long_eq,$d_eq'" "${COM[@]}" )
done < <(cat eq | grep -P '^[a-z]')
#157
COM="convert -size 1600x887 xc:transparent ${COM[@]} -channel RGBA -blur 3x3 ${LAB[@]} eq.png"
eval $COM
composite -blend 70 -gravity Center eq.png wallpaper.jpg wallpaper.jpg
feh --bg-max /home/neo/earth/wallpaper.jpg &
le cron actuel :
Re: [cron & feh] Can't open X display
Publié : ven. 15 avr. 2011, 20:44
par benjarobin
Non mais il faut remplacer
par
Code : Tout sélectionner
HOME=/home/neo DISPLAY=:0 feh --bg-max /home/neo/earth/wallpaper.jpg
dans changer.sh
Re: [cron & feh] Can't open X display
Publié : ven. 15 avr. 2011, 20:54
par blacktail
J'ai modifié mais me fait toujours cette foutu erreur :
Code : Tout sélectionner
No protocol specified
feh ERROR: Can't open X display. It *is* running, yeah?
Re: [cron & feh] Can't open X display
Publié : ven. 15 avr. 2011, 20:57
par benjarobin
J'ai un petit doute, c'est le cron de quel user ? root ou le tient ?
Sinon rajoute pour débugger je ne vois qu'une solution un peu lourde, mais bon :
Rajoute dans changer.sh cette ligne au tout début :
Et exécute depuis ton terminal cette commande
Puis donne la sortie de
Re: [cron & feh] Can't open X display
Publié : ven. 15 avr. 2011, 20:58
par blacktail
Il s'agit de mon cron, j'édite le crontab sous l'user neo.
ne m'a rien sorti
Code : Tout sélectionner
$ diff /home/neo/envFromCron /home/neo/envFromTerm
1,2c1,9
< CMDLINE=root=/dev/disk/by-uuid/a0b798d9-1d0d-471e-848c-d1969370f2bf ro
< CONSOLE=/dev/console
---
> DBUS_SESSION_BUS_ADDRESS=unix:abstract=/tmp/dbus-yvauG50XN7,guid=a00851916e26e474696aa64400000026
> DESKTOP_SESSION=openbox
> DISPLAY=:0.0
> EDITOR=nano
> G_BROKEN_FILENAMES=1
> GDM_KEYBOARD_LAYOUT=us
> GDM_LANG=fr_FR.utf8
> GDMSESSION=openbox
> GTK_MODULES=canberra-gtk-module
4,5c11,12
< INIT_VERSION=sysvinit-2.88
< LANG=C
---
> LANG=fr_FR.utf8
> LIBGL_DRIVERS_PATH=/usr/lib/xorg/modules/dri/
7,8c14,15
< PATH=/sbin:/usr/sbin:/bin:/usr/bin
< PREVLEVEL=N
---
> MOZ_PLUGIN_PATH=/usr/lib/mozilla/plugins
> PATH=/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/sbin:/usr/bin/vendor_perl:/usr/bin/core_perl
10,13c17,22
< RUNLEVEL=5
< SHELL=/bin/sh
< SHLVL=4
< TERM=linux
---
> SHELL=/bin/bash
> SHLVL=3
> SSH_AGENT_PID=1634
> SSH_AUTH_SOCK=/tmp/ssh-KhkyJBkZ1619/agent.1619
> TERM=xterm
> USERNAME=neo
16,19c25,32
< init=/sbin/init
< root=/dev/sda3
< rootdelay=10
< udevd_running=1
---
> WINDOWPATH=7
> XAUTHORITY=/var/run/gdm/auth-for-neo-OHwA7C/database
> XDG_CACHE_HOME=/home/neo/.cache
> XDG_CONFIG_DIRS=/etc/xdg
> XDG_CONFIG_HOME=/home/neo/.config
> XDG_DATA_DIRS=/usr/share/:/usr/local/share/
> XDG_DATA_HOME=/home/neo/.local/share
> XDG_SESSION_COOKIE=f7817a4d38b4b45ebcba375e00000235-1302878877.541388-2056717522
Re: [cron & feh] Can't open X display
Publié : ven. 15 avr. 2011, 21:01
par benjarobin
J'ai édité...
Re: [cron & feh] Can't open X display
Publié : ven. 15 avr. 2011, 21:02
par FoolEcho
Il y a pas une histoire d'autorisation d'accès au moyen de xhost à faire ?
Re: [cron & feh] Can't open X display
Publié : ven. 15 avr. 2011, 21:04
par benjarobin
Pas si c'est le cron du même user... De toute façon avec les commandes env on va de suite être fixé
Re: [cron & feh] Can't open X display
Publié : ven. 15 avr. 2011, 21:06
par blacktail
J'ai donné les sorties sur le poste après ton édition
Re: [cron & feh] Can't open X display
Publié : ven. 15 avr. 2011, 21:11
par benjarobin
Remplace
par
Ce qui donne
Code : Tout sélectionner
XAUTHORITY=/var/run/gdm/auth-for-neo-OHwA7C/database DISPLAY=:0 feh --bg-max /home/neo/earth/wallpaper.jpg
Mais ceci n'est pas une solution car le chemin changera à chaque boot. Mais testons si cela fonctionne
Je pense qu'il va falloir utiliser bash --login
Re: [cron & feh] Can't open X display
Publié : ven. 15 avr. 2011, 21:16
par blacktail
En mettant ceci :
Code : Tout sélectionner
XAUTHORITY=/var/run/gdm/auth-for-neo-OHwA7C/database DISPLAY=:0 feh --bg-max /home/neo/earth/wallpaper.jpg
ça fonctionne.
Re: [cron & feh] Can't open X display
Publié : ven. 15 avr. 2011, 21:19
par benjarobin
Donc il va falloir trouvé une vrai solution maintenant, je ne suis pas un expert dans bash, mais j'ai une piste
Essaye avec
Code : Tout sélectionner
bash --login -c "DISPLAY=:0 feh --bg-max /home/neo/earth/wallpaper.jpg"
Si cela ne fonctionne pas donne la sortie de
Puis donne nous la sortie du diff mais avec ce fichier
Re: [cron & feh] Can't open X display
Publié : ven. 15 avr. 2011, 21:27
par blacktail
j'obtiens rien avec
bash --login -c "DISPLAY=:0 feh --bg-max /home/neo/earth/wallpaper.jpg"
la commande ci-dessus me donne l'erreur du tout début.
Code : Tout sélectionner
$ diff /home/neo/envFromCron2 /home/neo/envFromTerm
11,12c11,12
< LANG=fr_FR.UTF-8
< LIBGL_DRIVERS_PATH=/usr/lib/xorg/modules/dri/:/usr/lib32/xorg/modules/dri
---
> LANG=fr_FR.utf8
> LIBGL_DRIVERS_PATH=/usr/lib/xorg/modules/dri/
18c18
< SHLVL=4
---
> SHLVL=3
28c28
< XDG_CONFIG_DIRS=/etc/xdg:/etc/xdg
---
> XDG_CONFIG_DIRS=/etc/xdg
30c30
< XDG_DATA_DIRS=/usr/share/:/usr/local/share/:/usr/share/:/usr/local/share/
---
> XDG_DATA_DIRS=/usr/share/:/usr/local/share/
Re: [cron & feh] Can't open X display
Publié : ven. 15 avr. 2011, 21:29
par benjarobin
Attends, tu as mis ou cette ligne :
tu l'as bien mis dans le script du cron ?