yad notification does not work when started at boot

Everything about X, Gnome, KDE, ... and everything running on it

yad notification does not work when started at boot

Postby peer » 2020-12-30 11:20

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???
peer
 
Posts: 150
Joined: 2017-03-26 10:14

Re: yad notification does not work when started at boot

Postby Head_on_a_Stick » 2020-12-30 18:34

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
Black Lives Matter

Debian buster-backports ISO image: for new hardware support
User avatar
Head_on_a_Stick
 
Posts: 13041
Joined: 2014-06-01 17:46
Location: /dev/chair

Re: yad notification does not work when started at boot

Postby peer » 2020-12-31 08:14

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.
peer
 
Posts: 150
Joined: 2017-03-26 10:14

Re: yad notification does not work when started at boot

Postby Head_on_a_Stick » 2020-12-31 09:58

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
Black Lives Matter

Debian buster-backports ISO image: for new hardware support
User avatar
Head_on_a_Stick
 
Posts: 13041
Joined: 2014-06-01 17:46
Location: /dev/chair

Re: yad notification does not work when started at boot

Postby peer » 2020-12-31 10:57

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
peer
 
Posts: 150
Joined: 2017-03-26 10:14

Re: yad notification does not work when started at boot

Postby Head_on_a_Stick » 2020-12-31 11:01

peer wrote:the first line in the error message: the init server

Perhaps the script is being run before the X session starts.
Black Lives Matter

Debian buster-backports ISO image: for new hardware support
User avatar
Head_on_a_Stick
 
Posts: 13041
Joined: 2014-06-01 17:46
Location: /dev/chair


Return to Desktop & Multimedia

Who is online

Users browsing this forum: No registered users and 12 guests

fashionable