Artix Linux Forum

Artix Linux => Applications & Software => Topic started by: hekuran on 30 August 2021, 14:14:06

Title: Notification from Cronjobs not working
Post by: hekuran on 30 August 2021, 14:14:06
This https://wiki.archlinux.org/title/Cron#Running_X.org_server-based_applications  says that,
to have notifications from a cronjob,  you have to specify `DBUS_SESSION_BUS_ADDRESS` and `DISPLAY` variables.
The `DISPLAY` variable is easy, it is allways ':0'
But the problem is `DBUS_SESSION_BUS_ADDRESS`. Doing this in a terminal:
Code: [Select]
$ echo $DBUS_SESSION_BUS_ADDRESS
unix:abstract=/tmp/dbus-TmOWK21wNR,guid=1770ea5d0622fa8ebc76a544612cc0ad
the variable is different every login, so i cant specify it in the crontab.

Now, https://wiki.archlinux.org/title/Cron#Running_X.org_server-based_applications says that dbus var should be like this:
Code: [Select]
export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/$(id -u $USER)/bus
but in Artix it will be this:
Code: [Select]
export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/$(id -u $USER)/bus-1
but this doesnt work, because it is not true, because like i said doing this in a terminal:
Code: [Select]
$ echo $DBUS_SESSION_BUS_ADDRESS
unix:abstract=/tmp/dbus-TmOWK21wNR,guid=1770ea5d0622fa8ebc76a544612cc0ad
tells you the real value.
so to have it always the same, i wrote this in my zprofile:
Code: [Select]
export DBUS_SESSION_BUS_ADDRESS='unix:path=/run/user/1000/bus-1'
But, that breaks dunst = doesn't run

# Temporary fix:
writing this in my `zprofie`:
Code: [Select]
export DBUS_SESSION_BUS_ADDRESS="unix:abstract=/tmp/dbus-TmOWK21wNR,guid=1770ea5d0622fa8ebc76a544612cc0ad"
and then having this in my crontab
Code: [Select]
* * * * * export DBUS_SESSION_BUS_ADDRESS="unix:abstract=/tmp/dbus-TmOWK21wNR,guid=1770ea5d0622fa8ebc76a544612cc0ad"; export DISPLAY=':0'; notify-send "beep bop"
...then it works, BUT like i said earlier, every login the dbus variable will change, so the crontab will not have the real vaule.
and just donig only this:
Code: [Select]
* * * * * export DISPLAY=':0'; notify-send "beep bop"
does not work.
Title: Re: Notification from Cronjobs not working
Post by: strajder on 30 August 2021, 14:26:38
What X program do you need to run with cron?

Conceptually, cron is meant for programs which don't interact with the user and are highly automated (for example, mail check). X programs don't fit that purpose.

If you want to notify the user from a cronjob, you can do something like:
Code: [Select]
        /usr/bin/env DISPLAY=:0 /usr/bin/notify-send -i $ICON "$TITLE" "$MESSAGE"
This is a line from my mail checking script, which I have in my crontab.
Title: Re: Notification from Cronjobs not working
Post by: hekuran on 30 August 2021, 14:38:37
accidentaly i pressed post instead of preview, sorry.
@strajder  please read my OriginalPost again, cause i have allot of other info.
Title: Re: Notification from Cronjobs not working
Post by: hekuran on 30 August 2021, 14:49:26
additional info
first my zprofile runs, then my xprofile, and then my xinitrc (well first xinit but first it sources xprofile before running itself)
XINITRC:
Code: [Select]
# export STATUSBAR="i3blocks" # Uncomment this line when using i3.

if [ -f "${XDG_CONFIG_HOME:-$HOME/.config}/x11/xprofile" ]; then
. "${XDG_CONFIG_HOME:-$HOME/.config}/x11/xprofile"
else
. "$HOME/.xprofile"
fi

# ssh-agent dwm
# ssh-agent i3
eval $(dbus-launch --sh-syntax --exit-with-session)
dbus-launch --exit-with-session dwm

XPROFILE:
Code: [Select]
#!/bin/sh

# Fix Gnome Apps Slow  Start due to failing services
# Add this when you include flatpak in your system
# dbus-update-activation-environment --systemd DBUS_SESSION_BUS_ADDRESS DISPLAY XAUTHORITY

#xrdb ${XDG_CONFIG_HOME:-$HOME/.config}/x11/xresources & # Uncomment to use Xresources colors/settings on startup
lxpolkit & # ask you for root pw
remaps & # run the remaps script, switching caps/esc and more; check it for more info
xcompmgr & # xcompmgr for transparency
dunst & # dunst for notifications
xset r rate 300 50 & # Speed xrate up
unclutter & # Remove mouse when idle
{ mpd && sb-music ;} & # music player
{ fuego-only ; setbg ;} & # resolution and background
light -N 10 & light -S 100 &
redshift -l 42.66:21.16 -t 6500:3000 >/dev/null 2>&1 &
mpv --no-audio-display --volume=50 "$XDG_DATA_HOME"/win_XP_Startup.mp3 >/dev/null 2>&1 &
/usr/lib/kdeconnectd & #KDE-Connect app for phones
#xset b 50 21 120 #nice beep

# This line autostarts an instance of Pulseaudio that does not exit on idle.
# This is "necessary" on Artix due to a current bug between PA and
# Chromium-based browsers where they fail to start PA and use dummy output.
pidof -s runit &&
! pidof -s pulseaudio >/dev/null 2>&1 &&
setsid -f pulseaudio --start --exit-idle-time=-1 >/dev/null 2>&1
# vim: ts=8 sw=8
Title: Re: Notification from Cronjobs not working
Post by: strajder on 30 August 2021, 14:50:29
From man 5 crontab:
Quote
       An active line in a crontab is either an environment setting or a cron command.  An environment setting is of the form:
[...]
       The format of a cron command is similar to the V7 standard, with a number of upward-compatible extensions.  Each line has five time-and-date fields followed by a username (if this
       is  the system crontab file), and followed by a command.  Commands are executed by cron(8) when the 'minute', 'hour', and 'month of the year' fields match the current time, and at
       least one of the two 'day' fields ('day of month', or 'day of week') match the current time (see "Note" below).
Note "a command", not "multiple commands".

Next, it is best to use /usr/bin/env instead of export, in order not to pollute the environment of subsequent commands.

Also see: https://askubuntu.com/a/205698
Title: Re: Notification from Cronjobs not working
Post by: hekuran on 30 August 2021, 15:11:11
@strajder
Quote
Note "a command", not "multiple commands".
but i am using only one command (notify-send "beep bop"), what do you mean?

Quote
Next, it is best to use /usr/bin/env instead of export, in order not to pollute the environment of subsequent commands.
so should my crontab look like this:
Code: [Select]
* * * * * /usr/bin/env DISPLAY=:0 /usr/bin/notify-send "beep bop"
because i have tried that and it did not work.
Title: Re: Notification from Cronjobs not working
Post by: strajder on 30 August 2021, 15:18:13
Code: [Select]
* * * * * /usr/bin/env DISPLAY=:0 /usr/bin/notify-send "beep bop"
because i have tried that and it did not work.
This command works for me. It sends a notification every minute.

Can you post your /var/log/crond.log (use paste.artixlinux.org)?
Title: Re: Notification from Cronjobs not working
Post by: hekuran on 30 August 2021, 15:32:23
Quote
This command works for me. It sends a notification every minute.
Really? it has never worked for me. Even in arch, i always had to write it with the dbus env var also.

here is the log:  https://paste.artixlinux.org/view/raw/c60a9015
Title: Re: Notification from Cronjobs not working
Post by: strajder on 30 August 2021, 15:38:50
Do you have an X session running when testing? This requires a running X session (on :0).

What happens when you do
Code: [Select]
$ notify-send Test
from a terminal emulator under X?

Edit: Also make sure you have both dbus and dbus-<your_init> installed and the dbus service setup and running for your init. I use 66, so I have dbus-suite66 installed. You should also probably ditch that dbus-launch line.

Edit 2: This is my .xinitrc (https://git.sr.ht/~strahinja/dotfiles/tree/master/item/.xinitrc). I use dwm. It needs to end with an exec line.
Title: Re: Notification from Cronjobs not working
Post by: hekuran on 30 August 2021, 15:52:59
yes of course, i am using dwm

i installed artix lxde runit

so it has cronie installed and enabled by default
Title: Re: Notification from Cronjobs not working
Post by: strajder on 30 August 2021, 15:55:21
Install dbus-runit package and setup the dbus service under runit.
Title: Re: Notification from Cronjobs not working
Post by: hekuran on 30 August 2021, 16:33:33
@strajder  sorry but i dont understand you. i said that i have it installed, and enabled.

but anyhow, i re-did it
Code: [Select]
sudo pacman -S dbus-runit
sudo ln -sf /etc/runit/sv/cronie /run/runit/service/
sudo sv restart cronie

still not successful.
Title: Re: Notification from Cronjobs not working
Post by: strajder on 30 August 2021, 16:47:05
And my other questions?
Title: Re: Notification from Cronjobs not working
Post by: hekuran on 30 August 2021, 17:18:07
@strajder bruh which?
the x session one?
well yes, i am running dwm, so yes when i run, in my terminal `notify-send Test` it works. i have mentioned this in my OP.

and if you mean, your xinit, which i just now saw, yes i know that. but i have been told, in the artix wiki and artix telegram group that  i should use `dbus-launch --exit-with-session dwm` instead of `exec dwm`.
doesnt make a diff though anyhow.
Title: Re: Notification from Cronjobs not working
Post by: strajder on 30 August 2021, 17:27:02
and if you mean, your xinit, which i just now saw, yes i know that. but i have been told, in the artix wiki and artix telegram group that  i should use `dbus-launch --exit-with-session dwm` instead of `exec dwm`.
Link?

https://wiki.archlinux.org/title/Xinit#xinitrc
Quote
Long-running programs started before the window manager, such as a screensaver and wallpaper application, must either fork themselves or be run in the background by appending an & sign. Otherwise, the script would halt and wait for each program to exit before executing the window manager or desktop environment. Note that some programs should instead not be forked, to avoid race bugs, as is the case of xrdb. Prepending exec will replace the script process with the window manager process, so that X does not exit even if this process forks to the background.

https://dwm.suckless.org/tutorial/
Quote
Launching
To launch dwm, ideally you should setup a ~/.xinitrc with at least exec dwm.
Title: Re: Notification from Cronjobs not working
Post by: Artist on 30 August 2021, 17:33:33
The info from the x-session needs to be available to the cronjob script.
So you might run this as a script at your x-session login:
Code: [Select]
echo 'export DBUS_SESSION_BUS_ADDRESS='$DBUS_SESSION_BUS_ADDRESS > /tmp/dsba
chmod +x /tmp/dsba
And in the crontob script run /tmp/dsba before sending out the notification
Title: Re: Notification from Cronjobs not working
Post by: strajder on 30 August 2021, 17:38:09
This doesn't explain how the line:
Code: [Select]
* * * * * /usr/bin/env DISPLAY=:0 /usr/bin/notify-send "beep bop"
works on my system, but not for the OP. I don't have any complicated setup with DBUS_SESSION_BUS_ADDRESS.
Title: Re: Notification from Cronjobs not working
Post by: hekuran on 30 August 2021, 17:51:52
@strajder  why link it? did you even read https://forum.artixlinux.org/index.php/topic,2988.msg19398.html#msg19398  ? ? ?
i have posted all important stuff.
Quote
This doesn't explain how the line works on my system, but not for the OP.
that is indeed a mystery!!!   :D  :D

@Artist  that is a very nice trick!

Right now, i am trying to make it work, `cp -f /usr/share/dbus-1/session.conf .config/dbus-session.conf` and then change
one important lie:
Code: [Select]
$ diff /usr/share/dbus-1/session.conf .config/dbus-session.conf
15c15
<   <listen>unix:tmpdir=/tmp</listen>
---
>   <listen>unix:path=/tmp/dbus-dontchange</listen>
as i was told by carlos in the artix telegram group.
if that wont work, @Artist  i will use your method.
Thanks a lot
Title: Re: Notification from Cronjobs not working
Post by: strajder on 30 August 2021, 17:58:41

i have been told, in the artix wiki and artix telegram group that  i should use `dbus-launch --exit-with-session dwm` instead of `exec dwm`.
Where in the Artix wiki? Provide a link.

I repeat:
https://wiki.archlinux.org/title/Xinit#xinitrc
Quote
Long-running programs started before the window manager, such as a screensaver and wallpaper application, must either fork themselves or be run in the background by appending an & sign. Otherwise, the script would halt and wait for each program to exit before executing the window manager or desktop environment. Note that some programs should instead not be forked, to avoid race bugs, as is the case of xrdb. Prepending exec will replace the script process with the window manager process, so that X does not exit even if this process forks to the background.

https://dwm.suckless.org/tutorial/
Quote
Launching
To launch dwm, ideally you should setup a ~/.xinitrc with at least exec dwm.
Title: Re: Notification from Cronjobs not working
Post by: hekuran on 30 August 2021, 18:09:11
@strajder  aaaah i thought u wanted to link my xprofile file, thats why i said i have posted it.
for dbus launch
https://wiki.artixlinux.org/Main/Troubleshooting#My_file_manager_.2F_application_cannot_perform_elevated_privileges_tasks
and a few times in the telegram group.

For cron in archlinux wiki
https://wiki.archlinux.org/title/Cron#Running_X.org_server-based_applications

And for what you have repeated (archwiki and suckless link):
Yes i have always done it like that, but it didnt work, so i tried sbus-lauch, which also did not work, thats why i said that it did not matter.
Title: Re: Notification from Cronjobs not working
Post by: strajder on 30 August 2021, 18:11:02
https://wiki.artixlinux.org/Main/Troubleshooting#My_file_manager_.2F_application_cannot_perform_elevated_privileges_tasks
Quote
Make sure your desktop session is started with dbus-launch in ~/.xinitrc
dwm is not a desktop session. It is a window manager.

Yes i have always done it like that, but it didnt work, so i tried sbus-lauch, which also did not work, thats why i said that it did not matter.
The logical conclusion would be to revert to exec, as it was proven to be unrelated to the problem.
Title: Re: Notification from Cronjobs not working
Post by: strajder on 30 August 2021, 19:10:03
From what I could see on my system, the variable DBUS_SESSION_BUS_ADDRESS is not set at all.

I'm using Autostart X at login (https://wiki.archlinux.org/title/Xinit#Autostart_X_at_login) that is, I don't use a Display Manager (https://wiki.archlinux.org/title/Display_manager). When my system starts, I get a getty "Login:" prompt. From there on, I have this in my .profile (https://git.sr.ht/~strahinja/dotfiles/tree/master/item/profile.d/profile) (since now I'm using mksh (https://www.mirbsd.org/mksh.htm):
Code: [Select]
if [ $(echo $0 | sed 's/^\(.\).*$/\1/g;1q') == "-" ]; then
unicode_start
pkill gpg
startx
fi
which starts X session for me. My .xinitrc (https://git.sr.ht/~strahinja/dotfiles/tree/master/item/.xinitrc) then execs dwm. I'm using no Desktop Environment (https://wiki.archlinux.org/title/Desktop_environment).

I am running 66 process supervision suite, and have the dbus service in the "default" tree, activated at startup.

It could be that the dbus service under 66 is configured differently than runit. I never used runit, so I don't know. What is the output of
Code: [Select]
$ ps aux | grep dbus
on your system? Are you using a DM?

I have:
Code: [Select]
root       741  0.0  0.0   2832  1028 ?        S    11:26   0:00 s6-supervise default-dbus
root       748  0.0  0.0   2832  1088 ?        S    11:26   0:00 s6-supervise default-dbus-log
s6log      861  0.0  0.0   2836  1020 ?        Ss   11:26   0:00 s6-log -d3 n3 T s1000000 /var/log/66/dbus
dbus       904  0.0  0.0   4672  3632 ?        Ss   11:26   0:00 dbus-daemon --system --nofork --nopidfile
strajder  1451  0.0  0.0   5280  1936 ?        S    11:26   0:00 dbus-launch --autolaunch=ad6e6c3f13375c49b5f732615fc877d6 --binary-syntax --close-stderr
strajder  1454  0.0  0.0   4184  2076 ?        Ss   11:26   0:00 /usr/bin/dbus-daemon --syslog-only --fork --print-pid 5 --print-address 7 --session
strajder  9214  0.0  0.0   9624  2308 pts/6    S+   19:11   0:00 grep dbus
Title: Re: Notification from Cronjobs not working
Post by: hekuran on 30 August 2021, 20:27:49
Code: [Select]
$ ps aux | grep dbus
root      1326  0.0  0.0   2404  1128 ?        Ss   20:01   0:00 runsvdir -P /run/runit/service log: ctivating service name='org.freedesktop.RealtimeKit1' requested by ':1.8' (uid=1000 pid=1733 comm="pulseaudio --start --exit-idle-time=-1 ") (using servicehelper) dbus-daemon[1494]: [system] Successfully activated service 'org.freedesktop.RealtimeKit1' dbus-daemon[1494]: [system] Successfully activated service 'org.freedesktop.PolicyKit1' *** debug [daemon/old_main.c(159)]: selected 1 times .
root      1490  0.0  0.0   2252   724 ?        Ss   20:01   0:00 runsv dbus
dbus      1494  0.0  0.0   4476  3516 ?        S    20:01   0:00 dbus-daemon --system --nofork --nopidfile
nix       1615  0.0  0.0   4316  2396 ?        Ss   20:03   0:00 /usr/bin/dbus-daemon --syslog --fork --print-pid 4 --print-address 6 --session
nix       1876  0.0  0.0   4184  2856 ?        S    20:04   0:00 /usr/bin/dbus-daemon --config-file=/usr/share/defaults/at-spi2/accessibility.conf --nofork --print-address 3
nix       3436  0.0  0.0   8964  2384 pts/0    S+   20:19   0:00 grep --color=auto dbus

well, we're very similar, i also do not use a desktop enviroment, nor a display(login) manager. i autostart from my profile, here is my zprofile:
Code: [Select]
#!/bin/zsh

# profile file. Runs on login. Environmental variables are set here.

# If you don't plan on reverting to bash, you can remove the link in ~/.profile
# to clean up.

# Adds `~/.local/bin` to $PATH
export PATH="$PATH:${$(find ~/.local/bin -type d -printf %p:)%%:}"

unsetopt PROMPT_SP

# Default programs:
export EDITOR="nvim"
export TERMINAL="st"
export BROWSER="ff"
export READER="zathura"
export FILE="vu"

# ~/ Clean-up:
export XDG_CONFIG_HOME="$HOME/.config"
export XDG_DATA_HOME="$HOME/.local/share"
export XDG_CACHE_HOME="$HOME/.cache"
export XINITRC="${XDG_CONFIG_HOME:-$HOME/.config}/x11/xinitrc"
export XAUTHORITY="$XDG_RUNTIME_DIR/Xauthority" # This line will break some DMs.
export NOTMUCH_CONFIG="${XDG_CONFIG_HOME:-$HOME/.config}/notmuch-config"
export GTK2_RC_FILES="${XDG_CONFIG_HOME:-$HOME/.config}/gtk-2.0/gtkrc-2.0"
export LESSHISTFILE="-"
export WGETRC="${XDG_CONFIG_HOME:-$HOME/.config}/wget/wgetrc"
export INPUTRC="${XDG_CONFIG_HOME:-$HOME/.config}/shell/inputrc"
export ZDOTDIR="${XDG_CONFIG_HOME:-$HOME/.config}/zsh"
#export ALSA_CONFIG_PATH="$XDG_CONFIG_HOME/alsa/asoundrc"
export GNUPGHOME="${XDG_DATA_HOME:-$HOME/.local/share}/gnupg"
export WINEPREFIX="${XDG_DATA_HOME:-$HOME/.local/share}/wineprefixes/default"
export KODI_DATA="${XDG_DATA_HOME:-$HOME/.local/share}/kodi"
export PASSWORD_STORE_DIR="${XDG_DATA_HOME:-$HOME/.local/share}/password-store"
export TMUX_TMPDIR="$XDG_RUNTIME_DIR"
export ANDROID_SDK_HOME="${XDG_CONFIG_HOME:-$HOME/.config}/android"
export CARGO_HOME="${XDG_DATA_HOME:-$HOME/.local/share}/cargo"
export GOPATH="${XDG_DATA_HOME:-$HOME/.local/share}/go"
export ANSIBLE_CONFIG="${XDG_CONFIG_HOME:-$HOME/.config}/ansible/ansible.cfg"
export UNISON="${XDG_DATA_HOME:-$HOME/.local/share}/unison"
export HISTFILE="${XDG_DATA_HOME:-$HOME/.local/share}/history"
export WEECHAT_HOME="${XDG_CONFIG_HOME:-$HOME/.config}/weechat"
export MBSYNCRC="${XDG_CONFIG_HOME:-$HOME/.config}/mbsync/config"
export ELECTRUMDIR="${XDG_DATA_HOME:-$HOME/.local/share}/electrum"

# Other program settings:
export MANPAGER="nvim -c 'set ft=man'"
export DICS="/usr/share/stardict/dic/"
export SUDO_ASKPASS="$HOME/.local/bin/dmenupass"
export FZF_DEFAULT_OPTS="--layout=reverse --height 40%"
export LESS=-R
export LESS_TERMCAP_mb="$(printf '%b' '')"
export LESS_TERMCAP_md="$(printf '%b' '')"
export LESS_TERMCAP_me="$(printf '%b' '')"
export LESS_TERMCAP_so="$(printf '%b' '')"
export LESS_TERMCAP_se="$(printf '%b' '')"
export LESS_TERMCAP_us="$(printf '%b' '')"
export LESS_TERMCAP_ue="$(printf '%b' '')"
export LESSOPEN="| /usr/bin/highlight -O ansi %s 2>/dev/null"
export QT_QPA_PLATFORMTHEME="qt5ct" # Have QT use gtk2 theme.
export MOZ_USE_XINPUT2="1" # Mozilla smooth scrolling/touchpads.
export AWT_TOOLKIT="MToolkit wmname LG3D" #May have to install wmname
export _JAVA_AWT_WM_NONREPARENTING=1 # Fix for Java applications in dwm

# This is the list for lf icons:
. ${XDG_CONFIG_HOME:-$HOME/.config}/shell/lf-icons

export FONTPREVIEW_BG_COLOR="#282828"
export FONTPREVIEW_FG_COLOR="#ebdbb2"
export FONTPREVIEW_PREVIEW_TEXT="ilIrnmo0Oalbgq\nABCDEFGHIJKLM\nNOPQRSTUVWXYZ\nabcdefghijklm\nnopqrstuvwxyz\n1234567890~^*+-_\n!@#$%&()[]{}/|\\\\"
export PF_INFO="ascii title os host kernel uptime pkgs wm shell term res memory palette"
#setterm --bfreq=40 --blength=100

test ! -f ${XDG_CONFIG_HOME:-$HOME/.config}/shell/shortcutrc && shortcuts >/dev/null 2>&1 &

if yay -Qs libxft-bgra >/dev/null 2>&1; then
# Start graphical server on user's current tty if not already running.
[ "$(tty)" = "/dev/tty1" ] && ! pidof -s Xorg >/dev/null 2>&1 && exec startx "$XINITRC"
else
echo "\033[31mIMPORTANT\033[0m: Note that \033[32m\`libxft-bgra\`\033[0m must be installed for this build of dwm.
Please run:
\033[32myay -S libxft-bgra-git\033[0m
and replace \`libxft\`. Afterwards, you may start the graphical server by running \`startx\`."
fi

# Switch escape and caps if tty and no passwd required:
sudo -n loadkeys ${XDG_DATA_HOME:-$HOME/.local/share}/larbs/ttymaps.kmap 2>/dev/null
though i only autostartx when im on tty1
i really dont know, maybe its cause of suite66...., though that should be irrelevant.
Title: Re: Notification from Cronjobs not working
Post by: strajder on 30 August 2021, 20:41:07
There are differences, the most obvious being the number of dbus-daemon processes and the lack of the one calling /usr/share/defaults/at-spi2/accessibility.conf on my side. runit ( @Artist ? ) and 66 ( @ndowens ) maintainers could perhaps take a look at this. (I'm happy with 66 state of things dbus-wise, but maybe runit could use some updates.)
Title: Re: Notification from Cronjobs not working
Post by: hekuran on 31 August 2021, 20:08:02
# report
i have implemented https://forum.artixlinux.org/index.php/topic,2988.msg19413.html#msg19413 from @Artist
relevant (last 2lines) xinitrc :
Code: [Select]
echo 'export DBUS_SESSION_BUS_ADDRESS='$DBUS_SESSION_BUS_ADDRESS > /tmp/dsba ; chmod +x /tmp/dsba
exec dwm

crontab -l
Code: [Select]
* * * * * source /tmp/dsba; cronbat
1 10,14,18,22 * * * source /tmp/dsba; newsup
2 10,18 * * * source /tmp/dsba; checkup

in contrast to @strajder , i am not using the $DISPLAY variable at all, ony the dbus env var. idk what is happening, im happy that it works now, though i would like to know how.
@strajder  is using only the $DISPLAY env var, without the dbus env var. the opposite...??
Title: Re: Notification from Cronjobs not working
Post by: Artist on 13 September 2021, 15:39:16
For me using runit and only the DISPLAY variable this worked for quite a while until one day it stopped. Not sure if this was because of an update or a mnaual change. Later I switched to s6 where using only the DISPLAY variable also did not work. There seems not enough info yet to narrow the cause down to one single component.
Title: Re: Notification from Cronjobs not working
Post by: strajder on 13 September 2021, 18:56:07
An alternative way to show notification from a cronjob would be to write to a file from a cronjob, and have entr (http://eradman.com/entrproject) running on autostart ("cool autostart (https://dwm.suckless.org/patches/cool_autostart/)" in dwm), calling notify-send when the file changes.

Edit: Something like:
Code: [Select]
echo ~/notification | entr -cps 'xargs notify-send <~/notification'
Title: Re: Notification from Cronjobs not working
Post by: cfd on 31 May 2024, 07:12:03
In case '/run/user/1000/bus' is missing set 'unix:runtime=yes' in /etc/dbus-1/session-local.conf

Quote from: /etc/dbus-1/session-local.conf
<!DOCTYPE busconfig PUBLIC "-//freedesktop//DTD D-Bus Bus Configuration 1.0//EN"
 "http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd">
<busconfig>
        <listen>unix:runtime=yes</listen>
</busconfig>


bonus edit:
cron or whoever should then be able to connect to dbus w/o explicitly passing $DBUS_SESSION_BUS_ADDRESS


read here: https://dbus.freedesktop.org/doc/dbus-specification.html