Scheduled Maintenance: We are aware of an issue with Google, AOL, and Yahoo services as email providers which are blocking new registrations. We are trying to fix the issue and we have several internal and external support tickets in process to resolve the issue. Please see: viewtopic.php?t=158230

 

 

 

yad notification does not work when started at boot

Graphical Environments, Managers, Multimedia & Desktop questions.
Post Reply
Message
Author
peer
Posts: 449
Joined: 2017-03-26 10:14
Has thanked: 8 times
Been thanked: 22 times

yad notification does not work when started at boot

#1 Post by peer »

I have the following test script that I want to run at boot.

Code: Select all

#!/bin/bash
exec 3>&1 4>&2
trap 'exec 2>&4 1>&3' 0 1 2 3
exec 1>log.out 2>&1
echo "script started" > logFile 
#export DISPLAY=:0.0
/usr/bin/yad --notification 
echo "script ended" >> logFile
The only thing this script is supposed to do is show an icon on the panel.
When I ran the script as user or as root it works.

When i add the script to cron as user or as root the icon is not shown.
In the logfile log.out I get the following error:

Code: Select all

Unable to init server: Could not connect: Connection refused

(yad:682): Gtk-WARNING **: 13:01:18.954: cannot open display: 
I tried to add the line "export DISPLAY=:0.0¨ but that did not help.

Can anybody help me with this problem???

User avatar
Head_on_a_Stick
Posts: 14114
Joined: 2014-06-01 17:46
Location: London, England
Has thanked: 81 times
Been thanked: 133 times

Re: yad notification does not work when started at boot

#2 Post by Head_on_a_Stick »

peer wrote:I tried to add the line "export DISPLAY=:0.0¨ but that did not help.
It that really the value of $DISPLAY for your graphical desktop? It's usually ":0" rather than ":0.0".

Check with

Code: Select all

echo $DISPLAY
deadbang

peer
Posts: 449
Joined: 2017-03-26 10:14
Has thanked: 8 times
Been thanked: 22 times

Re: yad notification does not work when started at boot

#3 Post by peer »

you are right.
the value of $DISPLAY = 0:

Strange, the script does run properly at boot now without any errors. I did not make any changes so I do not know what went wrong yesterday.

User avatar
Head_on_a_Stick
Posts: 14114
Joined: 2014-06-01 17:46
Location: London, England
Has thanked: 81 times
Been thanked: 133 times

Re: yad notification does not work when started at boot

#4 Post by Head_on_a_Stick »

It might make more sense to add the yad command to ~/.xsessionrc, any commands in that file will be run when the graphical desktop starts.

https://wiki.debian.org/Xsession
deadbang

peer
Posts: 449
Joined: 2017-03-26 10:14
Has thanked: 8 times
Been thanked: 22 times

Re: yad notification does not work when started at boot

#5 Post by peer »

I want to use the yad command in a larger update script.
Yesterday I also added the script to the autostart section. That's why the yad icon worked.
I tried the line: export DISPLAY=:0 in the script but I still got the error message

Code: Select all

Unable to init server: Could not connect: Connection refused

(yad:678): Gtk-WARNING **: 12:23:28.973: cannot open display: :0
Probably the problem has to do with the first line in the error message: the init server

I will make a workaround
1. a script started at reboot by cron, checkes for updates and stores the number of updates
2. a script in the autostart section that uses yad and notify-send for informing the user

User avatar
Head_on_a_Stick
Posts: 14114
Joined: 2014-06-01 17:46
Location: London, England
Has thanked: 81 times
Been thanked: 133 times

Re: yad notification does not work when started at boot

#6 Post by Head_on_a_Stick »

peer wrote:the first line in the error message: the init server
Perhaps the script is being run before the X session starts.
deadbang

Post Reply