How do I get a startup sound to play using systemd and aplay?

Viewed 330

I am trying to create a systemd unit to play a sound on boot with aplay. My systemd unit is

[Unit]
Description=Startup Sound
After=sound.target
Requires=sound.target

[Service]
Type=oneshot
User=test
ExecStart=/bin/zsh /home/test/startup_sound.sh
StandardOutput=journal

[Install]
WantedBy=multi-user.target

The shell script is

amixer set Master 100%
aplay /home/test/smb_coin.wav

When I run the shell script everything works fine. When I start the service it does not play the sound but the systemctl status shows this

ā— startup_sound.service - Startup Sound
     Loaded: loaded (/etc/systemd/system/startup_sound.service; enabled; vendor preset: disabled)
     Active: inactive (dead) since Mon 2021-02-01 21:27:30 CST; 14s ago
    Process: 19264 ExecStart=/bin/zsh /home/test/startup_sound.sh (code=exited, status=0/SUCCESS)
   Main PID: 19264 (code=exited, status=0/SUCCESS)

Feb 01 21:27:29 Gemini zsh[19265]: Simple mixer control 'Master',0
Feb 01 21:27:29 Gemini zsh[19265]:   Capabilities: pvolume pswitch
Feb 01 21:27:29 Gemini zsh[19265]:   Playback channels: Front Left - Front Right
Feb 01 21:27:29 Gemini zsh[19265]:   Limits: Playback 0 - 87
Feb 01 21:27:29 Gemini zsh[19265]:   Mono:
Feb 01 21:27:29 Gemini zsh[19265]:   Front Left: Playback 87 [100%] [0.00dB] [on]
Feb 01 21:27:29 Gemini zsh[19265]:   Front Right: Playback 87 [100%] [0.00dB] [on]
Feb 01 21:27:29 Gemini zsh[19267]: Playing WAVE '/home/test/smb_coin.wav' : Signed 16 bit Little Endian, Rate 22050 Hz, Mono
Feb 01 21:27:30 Gemini systemd[1]: startup_sound.service: Succeeded.
Feb 01 21:27:30 Gemini systemd[1]: Finished Startup Sound.

Any ideas on how I can get this working? I am using Manjaro and Gnome.

0 Answers
Related