You are not logged in.

#1 2023-04-20 15:19:30

mehdi-n
Member
Registered: 2022-05-02
Posts: 14

[solved] notify-send not working in cronjobs

I'm trying to run the below test script as a cronjob:

#!/bin/sh
echo "$(date) cron test" >> ~/tmp/log
notify-send "$(date) cron test"

and in the crontab file I have:

* * * * * export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/1000/bus; export DISPLAY=:0; /home/mehdi/.local/bin/crontest

the script is running every minute and time is printed in the log file, but no notification is displayed.
I tried solutions given in the wiki (installing xuserrun-dbus-git, changing export to env) but no luck.

The only way that I can display notifications is copying the exact value and path of dbus address:

[mehdi@tp ~]$ env | grep DBUS_SESSION_BUS_ADDRESS
DBUS_SESSION_BUS_ADDRESS=unix:path=/tmp/dbus-fXUDeSE4TE,guid=00aa165ac08c0a86dff8d23e64414e19

and putting it in the crontab file. Which only works until I reboot the system. after reboot, the address value is changed and I have to edit the crontab manually again.

Why the /run/user/1000/bus socket is not working? Am I doing something wrong here?

Last edited by mehdi-n (2023-04-21 14:52:48)

Offline

#2 2023-04-20 15:28:53

V1del
Forum Moderator
Registered: 2012-10-16
Posts: 25,104

Re: [solved] notify-send not working in cronjobs

Your DBUS user session bus is already broken if it has that value. Are you running dbus-launch/dbus-run-session during your startup scripts or similar -  which you shouldn't? notfiy-send does btw not care about your display and there's no need to set that nor to try some xrun special stuff. If your DBUS_SESSION_BUS is correct this will just work.

Last edited by V1del (2023-04-20 15:30:27)

Offline

#3 2023-04-20 15:54:36

mehdi-n
Member
Registered: 2022-05-02
Posts: 14

Re: [solved] notify-send not working in cronjobs

I use LARBS configs mostly.
this is my xinitrc:

#!/bin/sh

# xinitrc runs automatically when you run startx.

# There are some small but important commands that need to be run when we start
# the graphical environment. There is a link to this file in ~/.xprofile
# because that file is run automatically if someone uses a display manager
# (login screen) and so they are needed there. To prevent doubling up commands,
# I source them here with the line below.

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

ssh-agent dwm

xprofile:

#!/bin/sh

# This file runs when a DM logs you into a graphical session.
# If you use startx/xinit like a Chad, this file will also be sourced.

xrandr --dpi 96		# Set DPI. User may want to use a larger number for larger screens.
setbg &			# set the background with the `setbg` script
#xrdb ${XDG_CONFIG_HOME:-$HOME/.config}/x11/xresources & xrdbpid=$!	# Uncomment to use Xresources colors/settings on startup

autostart="mpd xcompmgr dunst unclutter pipewire remapd"

for program in $autostart; do
	pidof -sx "$program" || "$program" &
done >/dev/null 2>&1

# Ensure that xrdb has finished running before moving on to start the WM/DE.
[ -n "$xrdbpid" ] && wait "$xrdbpid"

and dbus service status:

[mehdi@tp ~]$ systemctl list-units | grep dbus
  dbus.service                                                                                          loaded active running   D-Bus System Message Bus
  dbus.socket                                                                                           loaded active running   D-Bus System Message Bus Socket

[mehdi@tp ~]$ env | grep DBUS
DBUS_SESSION_BUS_PID=447
DBUS_SESSION_BUS_ADDRESS=unix:path=/tmp/dbus-fXUDeSE4TE,guid=00aa165ac08c0a86dff8d23e64414e19

Offline

#4 2023-04-20 19:30:51

seth
Member
From: Don't DM me only for attention
Registered: 2012-09-03
Posts: 74,307

Re: [solved] notify-send not working in cronjobs

I use LARBS configs mostly.

Is likely the reason why …

this is my xinitrc:

… this is broken. Last link below, blue note about what to include at least.

Also https://gist.github.com/AladW/de1c5676d93d05a5a0e1

Offline

#5 2023-04-21 07:42:18

mehdi-n
Member
Registered: 2022-05-02
Posts: 14

Re: [solved] notify-send not working in cronjobs

… this is broken. Last link below, blue note about what to include at least.

This fixed the notification issue. Thank you.

Although, about the address value in V1del's answer:

Your DBUS user session bus is already broken if it has that value.

I still got the same thing in my env output:

[mehdi@tp ~]$ env | grep dbus
DBUS_SESSION_BUS_ADDRESS=unix:path=/tmp/dbus-DdvPaA05bD,guid=087505912fd910ad4804488f64423a8f

So I'm not sure if there's still a problem in dbus or not.

Offline

#6 2023-04-21 07:50:00

seth
Member
From: Don't DM me only for attention
Registered: 2012-09-03
Posts: 74,307

Re: [solved] notify-send not working in cronjobs

ps aux

The pattern is common for dbus-launch, how do you invokde "startx"? LARBS-based bashrc/profile?

Offline

#7 2023-04-21 09:06:41

mehdi-n
Member
Registered: 2022-05-02
Posts: 14

Re: [solved] notify-send not working in cronjobs

The pattern is common for dbus-launch, how do you invokde "startx"? LARBS-based bashrc/profile?

I found this line in .zprofile:

# 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"
[mehdi@tp ~]$ ps aux | grep startx
mehdi        424  0.0  0.0   7932  4096 tty1     Ss+  10:56   0:00 /bin/sh /usr/bin/startx /home/mehdi/.config/x11/xinitrc

Offline

#8 2023-04-21 11:50:08

seth
Member
From: Don't DM me only for attention
Registered: 2012-09-03
Posts: 74,307

Re: [solved] notify-send not working in cronjobs

"ps aux", not "grep" - all of it.

I found this line in .zprofile:

And this is pretty much why LARBS is not really supported here, you're supposed to know what's going on and not find random stuff in your configuration.
Therefore also better post the entire zprofile, so we can see what other stuff is in there.

Offline

#9 2023-04-21 12:12:29

mehdi-n
Member
Registered: 2022-05-02
Posts: 14

Re: [solved] notify-send not working in cronjobs

sorry. here it is:

USER         PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
root           1  2.6  0.1 167492 12312 ?        Ss   15:37   0:01 /sbin/init
root           2  0.0  0.0      0     0 ?        S    15:37   0:00 [kthreadd]
root           3  0.0  0.0      0     0 ?        I<   15:37   0:00 [rcu_gp]
root           4  0.0  0.0      0     0 ?        I<   15:37   0:00 [rcu_par_gp]
root           5  0.0  0.0      0     0 ?        I<   15:37   0:00 [slub_flushwq]
root           6  0.0  0.0      0     0 ?        I<   15:37   0:00 [netns]
root           7  0.0  0.0      0     0 ?        I    15:37   0:00 [kworker/0:0-events]
root           8  0.0  0.0      0     0 ?        I<   15:37   0:00 [kworker/0:0H-events_highpri]
root           9  0.0  0.0      0     0 ?        I    15:37   0:00 [kworker/u16:0-events_power_efficient]
root          10  0.0  0.0      0     0 ?        I<   15:37   0:00 [mm_percpu_wq]
root          11  0.4  0.0      0     0 ?        I    15:37   0:00 [kworker/u16:1-events_unbound]
root          12  0.0  0.0      0     0 ?        I    15:37   0:00 [rcu_tasks_kthread]
root          13  0.0  0.0      0     0 ?        I    15:37   0:00 [rcu_tasks_rude_kthread]
root          14  0.0  0.0      0     0 ?        I    15:37   0:00 [rcu_tasks_trace_kthread]
root          15  0.0  0.0      0     0 ?        S    15:37   0:00 [ksoftirqd/0]
root          16  0.0  0.0      0     0 ?        I    15:37   0:00 [rcu_preempt]
root          17  0.0  0.0      0     0 ?        S    15:37   0:00 [rcub/0]
root          18  0.0  0.0      0     0 ?        S    15:37   0:00 [migration/0]
root          19  0.0  0.0      0     0 ?        S    15:37   0:00 [idle_inject/0]
root          20  0.2  0.0      0     0 ?        I    15:37   0:00 [kworker/0:1-events]
root          21  0.0  0.0      0     0 ?        S    15:37   0:00 [cpuhp/0]
root          22  0.0  0.0      0     0 ?        S    15:37   0:00 [cpuhp/1]
root          23  0.0  0.0      0     0 ?        S    15:37   0:00 [idle_inject/1]
root          24  0.3  0.0      0     0 ?        S    15:37   0:00 [migration/1]
root          25  0.0  0.0      0     0 ?        S    15:37   0:00 [ksoftirqd/1]
root          26  0.0  0.0      0     0 ?        I    15:37   0:00 [kworker/1:0-events]
root          27  0.0  0.0      0     0 ?        I<   15:37   0:00 [kworker/1:0H-events_highpri]
root          28  0.0  0.0      0     0 ?        S    15:37   0:00 [cpuhp/2]
root          29  0.0  0.0      0     0 ?        S    15:37   0:00 [idle_inject/2]
root          30  0.3  0.0      0     0 ?        S    15:37   0:00 [migration/2]
root          31  0.0  0.0      0     0 ?        S    15:37   0:00 [ksoftirqd/2]
root          32  0.0  0.0      0     0 ?        I    15:37   0:00 [kworker/2:0-cgroup_destroy]
root          33  0.0  0.0      0     0 ?        I<   15:37   0:00 [kworker/2:0H-events_highpri]
root          34  0.0  0.0      0     0 ?        S    15:37   0:00 [cpuhp/3]
root          35  0.0  0.0      0     0 ?        S    15:37   0:00 [idle_inject/3]
root          36  0.3  0.0      0     0 ?        S    15:37   0:00 [migration/3]
root          37  0.0  0.0      0     0 ?        S    15:37   0:00 [ksoftirqd/3]
root          38  0.0  0.0      0     0 ?        I    15:37   0:00 [kworker/3:0-rcu_gp]
root          39  0.0  0.0      0     0 ?        I<   15:37   0:00 [kworker/3:0H-events_highpri]
root          40  0.0  0.0      0     0 ?        S    15:37   0:00 [cpuhp/4]
root          41  0.0  0.0      0     0 ?        S    15:37   0:00 [idle_inject/4]
root          42  0.3  0.0      0     0 ?        S    15:37   0:00 [migration/4]
root          43  0.0  0.0      0     0 ?        S    15:37   0:00 [ksoftirqd/4]
root          44  0.7  0.0      0     0 ?        I    15:37   0:00 [kworker/4:0-events]
root          45  0.0  0.0      0     0 ?        I<   15:37   0:00 [kworker/4:0H-events_highpri]
root          46  0.0  0.0      0     0 ?        S    15:37   0:00 [cpuhp/5]
root          47  0.0  0.0      0     0 ?        S    15:37   0:00 [idle_inject/5]
root          48  0.3  0.0      0     0 ?        S    15:37   0:00 [migration/5]
root          49  0.0  0.0      0     0 ?        S    15:37   0:00 [ksoftirqd/5]
root          50  0.0  0.0      0     0 ?        I    15:37   0:00 [kworker/5:0-events]
root          51  0.0  0.0      0     0 ?        I<   15:37   0:00 [kworker/5:0H-events_highpri]
root          52  0.0  0.0      0     0 ?        S    15:37   0:00 [cpuhp/6]
root          53  0.0  0.0      0     0 ?        S    15:37   0:00 [idle_inject/6]
root          54  0.3  0.0      0     0 ?        S    15:37   0:00 [migration/6]
root          55  0.0  0.0      0     0 ?        S    15:37   0:00 [ksoftirqd/6]
root          56  0.0  0.0      0     0 ?        I    15:37   0:00 [kworker/6:0-events]
root          57  0.0  0.0      0     0 ?        I<   15:37   0:00 [kworker/6:0H-events_highpri]
root          58  0.0  0.0      0     0 ?        S    15:37   0:00 [cpuhp/7]
root          59  0.0  0.0      0     0 ?        S    15:37   0:00 [idle_inject/7]
root          60  0.3  0.0      0     0 ?        S    15:37   0:00 [migration/7]
root          61  0.0  0.0      0     0 ?        S    15:37   0:00 [ksoftirqd/7]
root          62  0.0  0.0      0     0 ?        I    15:37   0:00 [kworker/7:0-events]
root          63  0.0  0.0      0     0 ?        I<   15:37   0:00 [kworker/7:0H-events_highpri]
root          64  0.0  0.0      0     0 ?        S    15:37   0:00 [kdevtmpfs]
root          65  0.0  0.0      0     0 ?        I<   15:37   0:00 [inet_frag_wq]
root          66  0.0  0.0      0     0 ?        S    15:37   0:00 [kauditd]
root          67  0.0  0.0      0     0 ?        S    15:37   0:00 [khungtaskd]
root          68  0.0  0.0      0     0 ?        S    15:37   0:00 [oom_reaper]
root          69  0.0  0.0      0     0 ?        I    15:37   0:00 [kworker/u16:2-events_unbound]
root          70  0.0  0.0      0     0 ?        I<   15:37   0:00 [writeback]
root          71  0.0  0.0      0     0 ?        S    15:37   0:00 [kcompactd0]
root          72  0.0  0.0      0     0 ?        SN   15:37   0:00 [ksmd]
root          73  0.0  0.0      0     0 ?        I    15:37   0:00 [kworker/4:1-rcu_gp]
root          74  0.0  0.0      0     0 ?        SN   15:37   0:00 [khugepaged]
root          75  0.0  0.0      0     0 ?        I<   15:37   0:00 [kintegrityd]
root          76  0.0  0.0      0     0 ?        I<   15:37   0:00 [kblockd]
root          77  0.0  0.0      0     0 ?        I<   15:37   0:00 [blkcg_punt_bio]
root          78  0.0  0.0      0     0 ?        I    15:37   0:00 [kworker/3:1-events]
root          79  0.0  0.0      0     0 ?        I<   15:37   0:00 [tpm_dev_wq]
root          80  0.0  0.0      0     0 ?        I<   15:37   0:00 [ata_sff]
root          81  0.0  0.0      0     0 ?        I<   15:37   0:00 [edac-poller]
root          82  0.0  0.0      0     0 ?        I<   15:37   0:00 [devfreq_wq]
root          83  0.0  0.0      0     0 ?        S    15:37   0:00 [watchdogd]
root          84  0.0  0.0      0     0 ?        I<   15:37   0:00 [kworker/4:1H-kblockd]
root          85  0.1  0.0      0     0 ?        S    15:37   0:00 [ksgxd]
root          86  0.0  0.0      0     0 ?        S    15:37   0:00 [kswapd0]
root          87  0.0  0.0      0     0 ?        I    15:37   0:00 [kworker/1:1-ipv6_addrconf]
root          88  0.0  0.0      0     0 ?        I<   15:37   0:00 [kthrotld]
root          89  0.0  0.0      0     0 ?        S    15:37   0:00 [irq/122-pciehp]
root          90  0.0  0.0      0     0 ?        S    15:37   0:00 [irq/124-pciehp]
root          91  0.0  0.0      0     0 ?        S    15:37   0:00 [irq/127-pciehp]
root          92  0.0  0.0      0     0 ?        I    15:37   0:00 [kworker/6:1-events]
root          93  0.1  0.0      0     0 ?        I    15:37   0:00 [kworker/2:1-events]
root          94  0.0  0.0      0     0 ?        I    15:37   0:00 [kworker/5:1-mm_percpu_wq]
root          95  0.0  0.0      0     0 ?        I    15:37   0:00 [kworker/7:1-cgroup_destroy]
root          96  0.0  0.0      0     0 ?        I<   15:37   0:00 [acpi_thermal_pm]
root          97  0.0  0.0      0     0 ?        S    15:37   0:00 [xenbus_probe]
root          98  0.2  0.0      0     0 ?        I    15:37   0:00 [kworker/u16:3-events_unbound]
root          99  0.0  0.0      0     0 ?        S    15:37   0:00 [hwrng]
root         100  0.0  0.0      0     0 ?        I<   15:37   0:00 [mld]
root         101  0.0  0.0      0     0 ?        I<   15:37   0:00 [ipv6_addrconf]
root         108  0.0  0.0      0     0 ?        I<   15:37   0:00 [kstrp]
root         109  0.0  0.0      0     0 ?        I<   15:37   0:00 [zswap1]
root         110  0.0  0.0      0     0 ?        I<   15:37   0:00 [zswap1]
root         111  0.0  0.0      0     0 ?        I<   15:37   0:00 [zswap-shrink]
root         112  0.0  0.0      0     0 ?        I<   15:37   0:00 [kworker/u17:0-rb_allocator]
root         113  0.0  0.0      0     0 ?        I<   15:37   0:00 [charger_manager]
root         130  0.0  0.0      0     0 ?        I<   15:37   0:00 [kworker/5:1H-kblockd]
root         143  0.0  0.0      0     0 ?        I<   15:37   0:00 [kworker/6:1H-kblockd]
root         144  0.0  0.0      0     0 ?        I<   15:37   0:00 [kworker/3:1H-kblockd]
root         145  0.0  0.0      0     0 ?        I<   15:37   0:00 [kworker/2:1H-events_highpri]
root         146  0.0  0.0      0     0 ?        I<   15:37   0:00 [kworker/1:1H-kblockd]
root         147  0.0  0.0      0     0 ?        I<   15:37   0:00 [kworker/7:1H-kblockd]
root         148  0.0  0.0      0     0 ?        I<   15:37   0:00 [kworker/0:1H-events_highpri]
root         149  0.0  0.0      0     0 ?        I    15:37   0:00 [kworker/1:2-mm_percpu_wq]
root         162  0.0  0.0      0     0 ?        I<   15:37   0:00 [nvme-wq]
root         163  0.0  0.0      0     0 ?        I<   15:37   0:00 [nvme-reset-wq]
root         164  0.0  0.0      0     0 ?        I<   15:37   0:00 [nvme-delete-wq]
root         165  0.0  0.0      0     0 ?        I<   15:37   0:00 [nvme-auth-wq]
root         172  0.0  0.0      0     0 ?        I<   15:37   0:00 [ktpacpid]
root         173  0.0  0.0      0     0 ?        I    15:37   0:00 [kworker/2:2-mm_percpu_wq]
root         174  0.0  0.0      0     0 ?        I    15:37   0:00 [kworker/2:3]
root         175  0.0  0.0      0     0 ?        I    15:37   0:00 [kworker/5:2-events]
root         176  0.0  0.0      0     0 ?        I    15:37   0:00 [kworker/7:2]
root         177  0.0  0.0      0     0 ?        I    15:37   0:00 [kworker/7:3-mm_percpu_wq]
root         178  0.0  0.0      0     0 ?        I    15:37   0:00 [kworker/7:4-mm_percpu_wq]
root         179  0.0  0.0      0     0 ?        S    15:37   0:00 [card0-crtc0]
root         180  0.0  0.0      0     0 ?        S    15:37   0:00 [card0-crtc1]
root         181  0.0  0.0      0     0 ?        S    15:37   0:00 [card0-crtc2]
root         182  0.2  0.0      0     0 ?        I    15:37   0:00 [kworker/0:2-events]
root         183  0.0  0.0      0     0 ?        S    15:37   0:00 [scsi_eh_0]
root         184  0.0  0.0      0     0 ?        I<   15:37   0:00 [scsi_tmf_0]
root         185  0.0  0.0      0     0 ?        S    15:37   0:00 [usb-storage]
root         186  0.0  0.0      0     0 ?        I    15:37   0:00 [kworker/4:2-rcu_gp]
root         187  0.0  0.0      0     0 ?        I<   15:37   0:00 [uas]
root         196  0.0  0.0      0     0 ?        S    15:37   0:00 [jbd2/nvme0n1p5-8]
root         197  0.0  0.0      0     0 ?        I<   15:37   0:00 [ext4-rsv-conver]
root         230  0.8  0.1  40544 14840 ?        Ss   15:37   0:00 /usr/lib/systemd/systemd-journald
root         236  0.0  0.0      0     0 ?        I    15:37   0:00 [kworker/6:2-mm_percpu_wq]
root         238  0.1  0.0      0     0 ?        I    15:37   0:00 [kworker/4:3-events]
root         246  0.7  0.1  32908  9728 ?        Ss   15:37   0:00 /usr/lib/systemd/systemd-udevd
root         286  0.0  0.0      0     0 ?        I    15:37   0:00 [kworker/3:2-mm_percpu_wq]
root         290  0.0  0.0      0     0 ?        S    15:37   0:00 [irq/141-mei_me]
root         322  0.0  0.0      0     0 ?        S    15:37   0:00 [jbd2/nvme0n1p7-8]
root         323  0.0  0.0      0     0 ?        I<   15:37   0:00 [ext4-rsv-conver]
root         338  0.0  0.0      0     0 ?        I<   15:37   0:00 [cfg80211]
root         344  0.0  0.0      0     0 ?        I<   15:37   0:00 [cryptd]
root         345  0.0  0.0      0     0 ?        S    15:37   0:00 [irq/159-iwlwifi]
root         347  0.0  0.0      0     0 ?        I    15:37   0:00 [kworker/6:3-kec_query]
root         352  0.0  0.0   7028  2944 ?        Ss   15:37   0:00 /usr/bin/crond -n
dbus         353  0.2  0.0   8880  4736 ?        Ss   15:37   0:00 /usr/bin/dbus-daemon --system --address=systemd: --nofork --nopidfile --systemd-activation --syslog-only
root         354  0.2  0.1  49272  8192 ?        Ss   15:37   0:00 /usr/lib/systemd/systemd-logind
root         355  0.6  0.3 407764 24036 ?        Ssl  15:37   0:00 /usr/bin/NetworkManager --no-daemon
root         357  0.0  0.0      0     0 ?        I<   15:37   0:00 [USBC000:00-con1]
root         358  0.0  0.0      0     0 ?        I    15:37   0:00 [kworker/6:4]
root         362  0.0  0.0  10208  7168 ?        Ss   15:37   0:00 sshd: /usr/bin/sshd -D [listener] 0 of 10-100 startups
root         365  0.0  0.0      0     0 ?        I    15:37   0:00 [kworker/u16:4-flush-259:0]
root         366  0.0  0.0      0     0 ?        I    15:37   0:00 [kworker/4:4]
root         373  0.0  0.0   7784  4992 ?        Ss   15:37   0:00 login -- mehdi
tor          374  2.5  0.6  57676 53056 ?        Ss   15:37   0:00 /usr/bin/tor -f /etc/tor/torrc
root         375  0.0  0.0      0     0 ?        I<   15:37   0:00 [kworker/u17:1]
root         376  0.0  0.0      0     0 ?        I    15:37   0:00 [kworker/1:3-events]
root         398  0.0  0.0      0     0 ?        S    15:37   0:00 [irq/161-rmi4_smbus]
root         399  0.0  0.0      0     0 ?        I<   15:37   0:00 [USBC000:00-con2]
root         403  0.0  0.0      0     0 ?        I    15:37   0:00 [kworker/3:3-cgroup_destroy]
root         404  0.0  0.1  17328 10880 ?        Ss   15:37   0:00 /usr/bin/wpa_supplicant -u -s -O /run/wpa_supplicant
mehdi        423  0.9  0.1  19100 11264 ?        Ss   15:38   0:00 /usr/lib/systemd/systemd --user
mehdi        424  0.0  0.0  23460  5164 ?        S    15:38   0:00 (sd-pam)
mehdi        431  0.2  0.0   7932  4224 tty1     Ss+  15:38   0:00 /bin/sh /usr/bin/startx /home/mehdi/.config/x11/xinitrc
mehdi        437  0.0  0.0   8372  2304 ?        Ss   15:38   0:00 /usr/bin/dbus-daemon --syslog --fork --print-pid 4 --print-address 6 --session
mehdi        467  0.0  0.0   4008  2176 tty1     S+   15:38   0:00 xinit /home/mehdi/.config/x11/xinitrc -- /etc/X11/xinit/xserverrc :0 vt1 -keeptty -auth /tmp/serverauth.ePy2lvlm4K
mehdi        468  2.5  1.1 1537600 87060 tty1    Sl   15:38   0:00 /usr/lib/Xorg -nolisten tcp :0 vt1 -keeptty -auth /tmp/serverauth.ePy2lvlm4K
mehdi        489  0.0  0.0   7932  4224 tty1     S    15:38   0:00 /bin/sh /home/mehdi/.config/x11/xinitrc
mehdi        493  0.0  0.0   7932  2064 tty1     S    15:38   0:00 /bin/sh /home/mehdi/.config/x11/xinitrc
mehdi        494  0.0  0.0   7932  1936 tty1     S    15:38   0:00 /bin/sh /home/mehdi/.config/x11/xinitrc
mehdi        496  0.0  0.0   7932  1936 tty1     S    15:38   0:00 /bin/sh /home/mehdi/.config/x11/xinitrc
mehdi        499  0.0  0.0   7932  2064 tty1     S    15:38   0:00 /bin/sh /home/mehdi/.config/x11/xinitrc
mehdi        500  0.0  0.0   7932  2068 tty1     S    15:38   0:00 /bin/sh /home/mehdi/.config/x11/xinitrc
mehdi        505  0.1  0.0   5304  3072 tty1     S    15:38   0:00 xcompmgr
mehdi        506  0.1  0.1 317140 11704 tty1     Sl   15:38   0:00 dunst
mehdi        507  0.0  0.0   5208  2944 tty1     S    15:38   0:00 unclutter
mehdi        508  0.2  0.2 131308 17408 tty1     Sl   15:38   0:00 pipewire
mehdi        509  0.0  0.0   7800  3456 tty1     S    15:38   0:00 /bin/bash /home/mehdi/.local/bin/remapd
mehdi        516  0.1  0.1  27404 10088 tty1     S    15:38   0:00 dwm
mehdi        522  0.0  0.0   7304  1712 ?        Ss   15:38   0:00 ssh-agent dwm
mehdi        525  1.0  0.4 423264 31872 tty1     Sl   15:38   0:00 /usr/bin/wireplumber
mehdi        534  0.0  0.0  12484  1492 ?        Ssl  15:38   0:00 xcape -e Super_L Escape
mehdi        539  0.0  0.0   7800  1684 tty1     S    15:38   0:00 /bin/bash /home/mehdi/.local/bin/remapd
mehdi        540  0.0  0.0   6952  2944 tty1     S    15:38   0:00 grep -qP -m1 [^un]bind.+\/[^:]+\(usb\) /dev/fd/63
mehdi        542  0.0  0.0  16188  6912 tty1     S    15:38   0:00 udevadm monitor -u -t seat -s input -s usb
mehdi        545  0.0  0.1  26684  8576 ?        Ssl  15:38   0:00 /usr/bin/pipewire-pulse
mehdi        546  0.0  0.0   8372  4480 ?        Ss   15:38   0:00 /usr/bin/dbus-daemon --session --address=systemd: --nofork --nopidfile --systemd-activation --syslog-only
mehdi        551  0.0  0.1 515500 15100 ?        Ssl  15:38   0:00 mpd
mehdi        558  0.0  0.0   4000  2176 tty1     S    15:38   0:00 dwmblocks
mehdi        659  1.0  0.2  36108 18560 ?        Ss   15:38   0:00 st
mehdi        660  1.5  0.0  10736  6648 pts/0    Ss   15:38   0:00 /bin/zsh
root         693  0.0  0.0  32912  5652 ?        S    15:38   0:00 (udev-worker)
mehdi        713  0.0  0.0  10560  3584 pts/0    R+   15:38   0:00 ps aux

zprofile:

#!/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 TERMINAL_PROG="st"
export BROWSER="librewolf"

# Change the default crypto/weather monitor sites.
# export CRYPTOURL="rate.sx"
# export WTTRURL="wttr.in"

# ~/ 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/x11/xinitrc"
#export XAUTHORITY="$XDG_RUNTIME_DIR/Xauthority" # This line will break some DMs.
export NOTMUCH_CONFIG="$XDG_CONFIG_HOME/notmuch-config"
export GTK2_RC_FILES="$XDG_CONFIG_HOME/gtk-2.0/gtkrc-2.0"
export WGETRC="$XDG_CONFIG_HOME/wget/wgetrc"
export INPUTRC="$XDG_CONFIG_HOME/shell/inputrc"
export ZDOTDIR="$XDG_CONFIG_HOME/zsh"
#export GNUPGHOME="$XDG_DATA_HOME/gnupg"
export WINEPREFIX="$XDG_DATA_HOME/wineprefixes/default"
export KODI_DATA="$XDG_DATA_HOME/kodi"
export PASSWORD_STORE_DIR="$XDG_DATA_HOME/password-store"
export TMUX_TMPDIR="$XDG_RUNTIME_DIR"
export ANDROID_SDK_HOME="$XDG_CONFIG_HOME/android"
export CARGO_HOME="$XDG_DATA_HOME/cargo"
export GOPATH="$XDG_DATA_HOME/go"
export ANSIBLE_CONFIG="$XDG_CONFIG_HOME/ansible/ansible.cfg"
export UNISON="$XDG_DATA_HOME/unison"
export HISTFILE="$XDG_DATA_HOME/history"
export MBSYNCRC="$XDG_CONFIG_HOME/mbsync/config"
export ELECTRUMDIR="$XDG_DATA_HOME/electrum"
export PYTHONSTARTUP="$XDG_CONFIG_HOME/python/pythonrc"
export SQLITE_HISTORY="$XDG_DATA_HOME/sqlite_history"

# Other program settings:
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' '[1;31m')"
export LESS_TERMCAP_md="$(printf '%b' '[1;36m')"
export LESS_TERMCAP_me="$(printf '%b' '[0m')"
export LESS_TERMCAP_so="$(printf '%b' '[01;44;33m')"
export LESS_TERMCAP_se="$(printf '%b' '[0m')"
export LESS_TERMCAP_us="$(printf '%b' '[1;32m')"
export LESS_TERMCAP_ue="$(printf '%b' '[0m')"
export LESSOPEN="| /usr/bin/highlight -O ansi %s 2>/dev/null"
export QT_QPA_PLATFORMTHEME="gtk2" # 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

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

# 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"

# 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

Offline

#10 2023-04-21 14:37:39

seth
Member
From: Don't DM me only for attention
Registered: 2012-09-03
Posts: 74,307

Re: [solved] notify-send not working in cronjobs

No dbus-launch and no other sign of the environment being set, you'll have to ask the LARBS devs where they might set that.
But to be sure:

This fixed the notification issue. Thank you.

If you're still using

* * * * * export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/1000/bus; export DISPLAY=:0; /home/mehdi/.local/bin/crontest

that means the dbus socket cannot be "/tmp/dbus-DdvPaA05bD,guid=087505912fd910ad4804488f64423a8f"

mehdi        489  0.0  0.0   7932  4224 tty1     S    15:38   0:00 /bin/sh /home/mehdi/.config/x11/xinitrc
mehdi        493  0.0  0.0   7932  2064 tty1     S    15:38   0:00 /bin/sh /home/mehdi/.config/x11/xinitrc
mehdi        494  0.0  0.0   7932  1936 tty1     S    15:38   0:00 /bin/sh /home/mehdi/.config/x11/xinitrc
mehdi        496  0.0  0.0   7932  1936 tty1     S    15:38   0:00 /bin/sh /home/mehdi/.config/x11/xinitrc
mehdi        499  0.0  0.0   7932  2064 tty1     S    15:38   0:00 /bin/sh /home/mehdi/.config/x11/xinitrc
mehdi        500  0.0  0.0   7932  2068 tty1     S    15:38   0:00 /bin/sh /home/mehdi/.config/x11/xinitrc

looks weird but might be due to "/bin/sh /usr/bin/startx /home/mehdi/.config/x11/xinitrc"
And since there's a lot of bash being used, better also post the bashrc's and profiles you got from LARBS (though still: ask there or just don't use that and configure the system properly)

Offline

#11 2023-04-21 14:51:35

mehdi-n
Member
Registered: 2022-05-02
Posts: 14

Re: [solved] notify-send not working in cronjobs

Ok. Thanks for your help. I will mark the topic as solved.
Also here are bash rc and profiles
bashrc:

#
# ~/.bashrc
#

# If not running interactively, don't do anything
[[ $- != *i* ]] && return

alias ls='ls --color=auto'
alias grep='grep --color=auto'
PS1='[\u@\h \W]\$ '

[ -f ~/.fzf.bash ] && source ~/.fzf.bash
. "/home/mehdi/.local/share/cargo/env"

.bash_profile:

#
# ~/.bash_profile
#

[[ -f ~/.bashrc ]] && . ~/.bashrc
. "/home/mehdi/.local/share/cargo/env"

.zshrc

# Lines configured by zsh-newuser-install
HISTFILE=~/.histfile
HISTSIZE=1000
SAVEHIST=1000
setopt autocd extendedglob
unsetopt beep
bindkey -v
# End of lines configured by zsh-newuser-install
# The following lines were added by compinstall
zstyle :compinstall filename '/home/mehdi/.zshrc'

autoload -Uz compinit
compinit
# End of lines added by compinstall
#
# aliases
alias ls='ls --color=auto'
alias grep='grep --color=auto'
alias v='nvim'
alias g='git'
alias p='sudo pacman'

eval "$(starship init zsh)"


[ -f ~/.fzf.zsh ] && source ~/.fzf.zsh

export PASSWORD_STORE_DIR=/home/mehdi/.local/share/password-store/

Offline

#12 2023-04-21 15:05:33

seth
Member
From: Don't DM me only for attention
Registered: 2012-09-03
Posts: 74,307

Re: [solved] notify-send not working in cronjobs

To be absolutely sure, please post the fixed xinitrc.

Offline

#13 2023-04-21 16:18:35

mehdi-n
Member
Registered: 2022-05-02
Posts: 14

Re: [solved] notify-send not working in cronjobs

based on this note in the wiki page:

Note: At the very least, ensure that the last if block in /etc/X11/xinit/xinitrc is present in your ~/.xinitrc file to ensure that the scripts in /etc/X11/xinit/xinitrc.d are sourced.

I just added the last if block to my xinitrc:

#!/bin/sh

# xinitrc runs automatically when you run startx.

# There are some small but important commands that need to be run when we start
# the graphical environment. There is a link to this file in ~/.xprofile
# because that file is run automatically if someone uses a display manager
# (login screen) and so they are needed there. To prevent doubling up commands,
# I source them here with the line below.

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

if [ -d /etc/X11/xinit/xinitrc.d ] ; then
 for f in /etc/X11/xinit/xinitrc.d/?*.sh ; do
  [ -x "$f" ] && . "$f"
 done
 unset f
fi

ssh-agent dwm

Offline

#14 2023-04-21 16:31:27

seth
Member
From: Don't DM me only for attention
Registered: 2012-09-03
Posts: 74,307

Re: [solved] notify-send not working in cronjobs

Try to do so ahead of teh xprofile include.

Offline

Board footer

Powered by FluxBB