i have a systemd timer fire a service to do some backups.
I just wanted a notification, popup and sound.
I have managed to add the following to the top of my script, the notify-send works but no mater what i try i can not get sound to play
# 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."
sudo -u greg /usr/bin/play '/home/greg/sounds/winsounds/Windows Message Nudge.wav'
Ok, i had always assumed it did, and i double checked with gpt
Will it run the backup as root ? if not i don’t see how i can use it.
I just want a single command (or as near to) to add to the top of my script. If it means creating separate script and separate services etc just to make a sound then I shan’t worry about it.
sudo -u tdell notify-send test
Error spawning command line “dbus-launch --autolaunch=f839d442d6194ae1b9148eead1d88b39 --binary-syntax --close-stderr”: Child process exited with code 1
sudo -u tdell -E notify-send test
I know nothing about pulseaudio server, but the command works in my shell but if i put it into my backup script that is run via systemd it gives this error
I was hoping for a missing environment variable. I guess I should of tried from a unit.
I’d use aplay before. But I know I’ve had many problems with PA permissions in the past connecting to the local socket. The most common is just refusing connections from root.
sudo -u $USER -E pw-cat -p example.wav Is the same thing?
If gpt would act intentional and on it’s own, it would be a liar.
… it is just not “intelligent” - you have to vet and double check it’s “answers” just like any internet search result …
yep but its great for an old-timer like me who has a terrible memory, especially on linux where most stuff is shell commands. Its a excellent quick answer to some syntax or quick question.
double check it’s “answers”, which is why im posting here today.
You can run your backup service as root, and have it trigger another oneshot service which uses a User= directive to trigger a script that plays the sound.
Yea, possibly. I’ve only just been forced to even look at systemd yesterday because I had to change all my NAS mounts over from fstab to systemd automounts. So any extra units are not as quick and easy as might be for you.
I posted to just ask if there was a single command i could use at the top of my script, but if not then no matter.
I may get bored in a couple of days and revisit this, though; it sounds like something I’d do.
In most desktop use cases, system mode likely is not the right choice
So why have it then?
System mode is around for usage on thin client or embedded setups, where no real local user exists, where access is exclusively via the network, and where state data is flushed on each session termination.