Hello. I installed artix this week and everything is going perfectly. But i have this issue with the $DISPLAY variable.
I'm using crontab and to be able to use notify-send i have to set the display variable. But for some reason echo $DISPLAY outputs a different number everytime. This morning it was :6 and after a reboot now its :7, in arch it was always :0. Anybody knows how to fix this? I couldn't find any information online.
I don't think you should ever be setting $DISPLAY manually. That should be done automatically whenever you start up a graphical session.
Move the whole session to another VT
If tty terminals 3-6 are not used and commented out (You may use screen and therefore only need one terminal), change /etc/X11/xinit/xserverrc:
exec /usr/bin/X -nolisten tcp vt07
For notify-send to work on crontabs it have to be set for cronie.
How can i comment out the tty 3-6? I tried to change
exec /usr/bin/X -nolisten tcp vt07
but at boot xorg outputs that it has no permission for it. So i changed it back to
exec /usr/bin/X -nolisten tcp "$@"
and now $DISPLAY is :0 again so for some reason it keeps changing.
Could you get the DISPLAY dynamically at runtime in the command?
Something like this might work although on a server with multiple displays you would need to find the correct one, but I only tried it in the terminal, not with cron:
$ DISPLAY=$(ls /tmp/.X11-unix | head -n1 | tr 'X' ':')".0" notify-send Hey "How are you?"
This link suggests this as a current working solution for someone too, and it also works in my terminal, but so does plain notify-send.
XDG_RUNTIME_DIR=/run/user/$(id -u) notify-send Hey "this is dog!"
https://stackoverflow.com/questions/16519673/cron-with-notify-send (https://stackoverflow.com/questions/16519673/cron-with-notify-send)
https://unix.stackexchange.com/questions/17255/is-there-a-command-to-list-all-open-displays-on-a-machine (https://unix.stackexchange.com/questions/17255/is-there-a-command-to-list-all-open-displays-on-a-machine)
I wonder why the number keeps changing though, because that seems unusual. Is X crashing and being restarted at boot or something? Perhaps check syslog and .local/share/xorg/Xorg.0.log (& .old) for clues? Or is there some config resetting it?
It looks today that it keeps it at :0 i don't know why. I implemented your solution to crontab it works great!
I checked the syslog and xorg log and i have the same errors i had ever: some acpi bios bugs and this:
[ 13.475810] elogind[1145]: Failed to connect to system bus: No such file or directory
[ 13.475815] elogind[1145]: Failed to fully start up daemon: No such file or directory
Which i took a look internet and looks like it's harmless.
So i don't know why that happens.
Alright i decided to settle up with the dynamic fix to detect the display. Thanks!