❱sudo systemctl start backup-notify
Job for backup-notify.service failed because the control process exited with error code.
See "systemctl status backup-notify.service" and "journalctl -xeu backup-notify.service" for details.
1
❱journalctl -xeu backup-notify.service
Aug 22 23:17:49 greg-venusseries systemd[1]: backup-notify.service: Failed with result 'exit-code'.
░░ Subject: Unit failed
░░ Defined-By: systemd
░░ Support: https://forum.manjaro.org/c/support
░░
░░ The unit backup-notify.service has entered the 'failed' state with result 'exit-code'.
Aug 22 23:17:49 greg-venusseries systemd[1]: Failed to start Play notification.
░░ Subject: A start job for unit backup-notify.service has failed
░░ Defined-By: systemd
░░ Support: https://forum.manjaro.org/c/support
░░
░░ A start job for unit backup-notify.service has finished with a failure.
░░
░░ The job identifier is 752242 and the job result is failed.
I tried putting the /usr/bin/systemctl start backup-notify.service into a regularly executing, service run, test script, just to see what might happen.
but it still give the same kind of error.
❱systemctl status backup-notify
× backup-notify.service - Play notification
Loaded: loaded (/etc/systemd/system/backup-notify.service; static)
Active: failed (Result: exit-code) since Thu 2024-08-22 23:12:58 BST; 18s ago
Invocation: f095e78d1ccd47818d4ec4f71bac5946
Process: 663481 ExecStart=/home/greg/bash/notify-send-service.sh (code=exited, status=136)
Main PID: 663481 (code=exited, status=136)
Mem peak: 3.6M
CPU: 28ms
Aug 22 23:12:58 greg-venusseries systemd[1]: Starting Play notification...
Aug 22 23:12:58 greg-venusseries notify-send-service.sh[663483]: Cannot autolaunch D-Bus without X11 $DISPLAY
Aug 22 23:12:58 greg-venusseries notify-send-service.sh[663481]: /home/greg/bash/notify-send-service.sh: line 4: 663484 Floating point exception(core dumped) /usr/bin/pla>
Aug 22 23:12:58 greg-venusseries systemd[1]: backup-notify.service: Main process exited, code=exited, status=136/n/a
Aug 22 23:12:58 greg-venusseries systemd[1]: backup-notify.service: Failed with result 'exit-code'.
Aug 22 23:12:58 greg-venusseries systemd[1]: Failed to start Play notification.
Not sure about this. My initial thought is that it’s something to do with the file.
I get a different error, but I’m using a different file. It seems there’s no sound device configured in the environment the service runs the script in.
play FAIL sox: Sorry, there is no default audio device configured
I’ve had a quick look, but I’m not sure how to solve that atm.
sorry, but i tried taking out the notify-send all together but it still errors.
❱cat ~/bash/notify-send-service.sh
#!/usr/bin/bash
# /usr/bin/notify-send "Backup Started" "BTRFS backup has started." &
/usr/bin/play '/home/greg/sounds/winsounds/Windows Message Nudge.wav'
⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼ /home/greg ⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼
❱sudo systemctl start backup-notify
Job for backup-notify.service failed because the control process exited with error code.
See "systemctl status backup-notify.service" and "journalctl -xeu backup-notify.service" for details.
1
⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼ /home/greg ⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼
❱systemctl status backup-notify.service
× backup-notify.service - Play notification
Loaded: loaded (/etc/systemd/system/backup-notify.service; static)
Active: failed (Result: exit-code) since Fri 2024-08-23 13:16:54 BST; 11s ago
Invocation: c3fc9790f1eb40b8a39c2d62a8e5f4ce
Process: 855300 ExecStart=/home/greg/bash/notify-send-service.sh (code=exited, status=136)
Main PID: 855300 (code=exited, status=136)
Mem peak: 2.9M
CPU: 26ms
Aug 23 13:16:54 greg-venusseries systemd[1]: Starting Play notification...
Aug 23 13:16:54 greg-venusseries notify-send-service.sh[855300]: /home/greg/bash/notify-send-service.sh: line 4: 855304 Floating point exception(core dumped) /usr/bin/pla>
Aug 23 13:16:54 greg-venusseries systemd[1]: backup-notify.service: Main process exited, code=exited, status=136/n/a
Aug 23 13:16:54 greg-venusseries systemd[1]: backup-notify.service: Failed with result 'exit-code'.
Aug 23 13:16:54 greg-venusseries systemd[1]: Failed to start Play notification.
3
⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼ /home/greg ⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼
❱journalctl -xeu backup-notify.service
Aug 23 13:16:41 greg-venusseries systemd[1]: backup-notify.service: Failed with result 'exit-code'.
░░ Subject: Unit failed
░░ Defined-By: systemd
░░ Support: https://forum.manjaro.org/c/support
░░
░░ The unit backup-notify.service has entered the 'failed' state with result 'exit-code'.
Aug 23 13:16:41 greg-venusseries systemd[1]: Failed to start Play notification.
░░ Subject: A start job for unit backup-notify.service has failed
░░ Defined-By: systemd
░░ Support: https://forum.manjaro.org/c/support
░░
░░ A start job for unit backup-notify.service has finished with a failure.
░░
░░ The job identifier is 972229 and the job result is failed.
Aug 23 13:16:54 greg-venusseries systemd[1]: Starting Play notification...
░░ Subject: A start job for unit backup-notify.service has begun execution
░░ Defined-By: systemd
░░ Support: https://forum.manjaro.org/c/support
░░
░░ A start job for unit backup-notify.service has begun execution.
░░
░░ The job identifier is 972524.
Aug 23 13:16:54 greg-venusseries notify-send-service.sh[855300]: /home/greg/bash/notify-send-service.sh: line 4: 855304 Floating point exception(core dumped) /usr/bin/pla>
Aug 23 13:16:54 greg-venusseries systemd[1]: backup-notify.service: Main process exited, code=exited, status=136/n/a
░░ Subject: Unit process exited
░░ Defined-By: systemd
░░ Support: https://forum.manjaro.org/c/support
░░
░░ An ExecStart= process belonging to unit backup-notify.service has exited.
░░
░░ The process' exit code is 'exited' and its exit status is 136.
Aug 23 13:16:54 greg-venusseries systemd[1]: backup-notify.service: Failed with result 'exit-code'.
░░ Subject: Unit failed
░░ Defined-By: systemd
░░ Support: https://forum.manjaro.org/c/support
░░
░░ The unit backup-notify.service has entered the 'failed' state with result 'exit-code'.
Aug 23 13:16:54 greg-venusseries systemd[1]: Failed to start Play notification.
░░ Subject: A start job for unit backup-notify.service has failed
░░ Defined-By: systemd
░░ Support: https://forum.manjaro.org/c/support
░░
░░ A start job for unit backup-notify.service has finished with a failure.
░░
░░ The job identifier is 972524 and the job result is failed.
So i decided to try copying the links and suggestions on the second post on this thread.
I created a user service in .config/systemd/user/backup-notify.service
First i run the script manually to make sure it works.
It works manually fine. (I have tried paplay & aplay)
Below is some info on what iv created for this test.
⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼ /home/greg ⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼
❱cat /home/greg/bash/notify-send-service.sh
#!/usr/bin/bash
# /usr/bin/notify-send "Backup Started" "BTRFS backup has started." &
/usr/bin/play '/home/greg/sounds/winsounds/Windows Message Nudge.wav'
⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼ /home/greg ⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼
❱lll .config/systemd/user/backup-notify.service
Permissions Size User Group Date Modified Date Created Name
.rw-r--r-- 154 greg greg 26 Aug 22:01 26 Aug 21:49 .config/systemd/user/backup-notify.service
⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼ /home/greg ⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼
❱systemctl --user cat backup-notify.service
# /home/greg/.config/systemd/user/backup-notify.service
[Unit]
Description=Play notification
[Service]
Type=simple
ExecStart=/home/greg/bash/notify-send-service.sh
[Install]
WantedBy=default.target
But when i try to start the service
⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼ /home/greg ⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼
❱systemctl --user start backup-notify.service
⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼ /home/greg ⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼
❱systemctl --user status backup-notify.service
× backup-notify.service - Play notification
Loaded: loaded (/home/greg/.config/systemd/user/backup-notify.service; enabled; preset: enabled)
Active: failed (Result: exit-code) since Mon 2024-08-26 22:25:00 BST; 8s ago
Duration: 6ms
Invocation: 6856aea10a6149c4b4d523f37e5cb803
Process: 687191 ExecStart=/home/greg/bash/notify-send-service.sh (code=exited, status=216/GROUP)
Main PID: 687191 (code=exited, status=216/GROUP)
Mem peak: 1.4M
CPU: 6ms
Aug 26 22:25:00 greg-venusseries systemd[902]: Started Play notification.
Aug 26 22:25:00 greg-venusseries (rvice.sh)[687191]: backup-notify.service: Failed to determine supplementary groups: Operation not permitted
Aug 26 22:25:00 greg-venusseries (rvice.sh)[687191]: backup-notify.service: Failed at step GROUP spawning /home/greg/bash/notify-send-service.sh: Operation not permitted
Aug 26 22:25:00 greg-venusseries systemd[902]: backup-notify.service: Main process exited, code=exited, status=216/GROUP
Aug 26 22:25:00 greg-venusseries systemd[902]: backup-notify.service: Failed with result 'exit-code'.
3
⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼ /home/greg ⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼
❱journalctl --user -u backup-notify.service
Aug 26 22:25:00 greg-venusseries systemd[902]: Started Play notification.
Aug 26 22:25:00 greg-venusseries (rvice.sh)[687191]: backup-notify.service: Failed to determine supplementary groups: Operation not permitted
Aug 26 22:25:00 greg-venusseries (rvice.sh)[687191]: backup-notify.service: Failed at step GROUP spawning /home/greg/bash/notify-send-service.sh: Operation not permitted
Aug 26 22:25:00 greg-venusseries systemd[902]: backup-notify.service: Main process exited, code=exited, status=216/GROUP
Aug 26 22:25:00 greg-venusseries systemd[902]: backup-notify.service: Failed with result 'exit-code'.
I’ve tried both ways (a root service run as user, and a user service) a few times, I can’t get it working, and I can’t find much on the net. The pop-up works but not the sound, I guess the systemd devs didn’t expect people to use audio. The environment is not the same as the normal user environment.
I can’t get @MrLavender’s suggestion to work either, though it seems like it should work on gnome.
It might have something to do with pipewire. When I use play in a user service (not a root service run as the user), it shows some output and tries to play something, but it screws up my sound (just repeating whatever was already playing at the time) until I restart pipewire and then the service fails much like when using a root service run as the user (no default audio device).
So it looks like you’ll have to leave it for now, unless someone knows how to workaround the issue.
What I can find suggests this is caused by a User= directive in the user service. However what you posted doesn’t contain one, so
This script created the errors, but you did not shared the content of it. So you did you get lost in your tests? Keep in mind that you need to reload the deamon if you changed service files or use systemctl edit --user --full testaudio.service to edit a user service. The error looks like as you had a User= in your user service file.
A simple script and a user service with the type oneshot plays audio without problems on my system. I use pipewire startet with a user service for audio.
yea, cool. I was sure i had tried with both User= and no User= but removing it does seem to have got me to the point where i can execute the following and it will make a sound.
systemctl --user start backup-notify.service
But i cant figure out where i can put that command or how it should be? Iv tried putting it in the main backup script that is executed by a normal service. (so i can keep the sound together with the notify-send command)
i tried all sorts of commands to execute it at the top of my backup script, im just guessing now.
>cat /home/greg/bash/btrfs-non-incrimental-backup.sh
#!/bin/bash
su -c "systemctl --user start backup-notify.service" -s /bin/bash greg
systemctl --user start backup-notify.service
sudo -u greg systemctl --user start backup-notify.service
# Set environment variables to allow notify-send to work
export DISPLAY=:0
export DBUS_SESSION_BUS_ADDRESS="unix:path=/run/user/1000/bus"
# Send notification as the logged-in user
sudo -u greg DISPLAY=$DISPLAY DBUS_SESSION_BUS_ADDRESS=$DBUS_SESSION_BUS_ADDRESS notify-send "Backup Started" "BTRFS backup has started."
exit
The notify-send works but no sound.
>journalctl -u btrfs-backup-to-ssd.service --since -1h
venusseries su[927981]: (to greg) root on none
Aug 27 17:50:33 greg-venusseries su[927981]: pam_unix(su:session): session opened for user greg(uid=1000) by (uid=0)
Aug 27 17:50:33 greg-venusseries systemctl[927983]: Failed to connect to bus: No medium found
Aug 27 17:50:33 greg-venusseries su[927981]: pam_unix(su:session): session closed for user greg
Aug 27 17:50:33 greg-venusseries systemctl[927984]: Failed to connect to bus: No medium found
Aug 27 17:50:33 greg-venusseries sudo[927985]: root : PWD=/ ; USER=greg ; COMMAND=/usr/bin/systemctl --user start backup-notify.service
Aug 27 17:50:33 greg-venusseries sudo[927985]: pam_systemd_home(sudo:session): New sd-bus connection (system-bus-pam-systemd-home-927985) opened.
Aug 27 17:50:33 greg-venusseries sudo[927985]: pam_unix(sudo:session): session opened for user greg(uid=1000) by (uid=0)
Aug 27 17:50:33 greg-venusseries btrfs-non-incrimental-backup.sh[927987]: Failed to connect to bus: No medium found
Aug 27 17:50:33 greg-venusseries sudo[927985]: pam_unix(sudo:session): session closed for user greg
Aug 27 17:50:33 greg-venusseries sudo[927988]: root : PWD=/ ; USER=greg ; ENV=DISPLAY=:0 DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/1000/bus ; COMMAND=/usr/bin/noti>
Aug 27 17:50:33 greg-venusseries sudo[927988]: pam_systemd_home(sudo:session): New sd-bus connection (system-bus-pam-systemd-home-927988) opened.
Aug 27 17:50:33 greg-venusseries sudo[927988]: pam_unix(sudo:session): session opened for user greg(uid=1000) by (uid=0)
Aug 27 17:50:33 greg-venusseries sudo[927988]: pam_unix(sudo:session): session closed for user greg
Aug 27 17:50:33 greg-venusseries systemd[1]: btrfs-backup-to-ssd.service: Deactivated successfully.
Aug 27 17:50:33 greg-venusseries systemd[1]: Finished Btrfs Backup to SSD.
where and how should i execute this user service ?
This will not work. Forget the user service. The user service can only be used if started form the user environment. But you are trying to start it form a system service that runs as root.
My example works only for user services, that are started manual or via a user timer.
Just a question, why not play the sound as root? Of course it depends on the sound software infrastructure you use and it needs to be configured to allow other users, it often runs only for one user that logged in first. It is weakens the security of your sound setup, since other local users can play sound, but on most systems, it doesn’t really matter.
Thx for your time and help. Its all getting way past my comfort zone now. I can live without a notification sound, if I had known what a cluster-f**k it was going to be I wouldn’t have started with the notification, I just thought that that would be the easy part, how wrong I was ^^
Now I just have to clean up all the littered code snippets, services & timers that i scattered all of the place while trying to figure this. I’m sure i can clean it up (famous last words).