How to bring back drum roll sound in Ubuntu 17.10 when system is ready for user to log in

In Ubuntu 16.04, when I powered on my computer, the drum roll sound would be played right before I was presented with the Login interface. After I upgraded to Ubuntu 17.10 the drum roll sound is no longer being played. I did some research on the web and tried the following, which enabled the drum roll sound to be played, but only after I had logged in.

I launched Startup Applications Preferences and added an item that contained the following.

/usr/bin/canberra-gtk-play --id="desktop-login" -f /usr/share/sounds/ubuntu/stereo/system-ready.ogg

But this only enabled the sound to be played after I had already logged in.

I also tried

/usr/bin/canberra-gtk-play --id="system-ready" -f /usr/share/sounds/ubuntu/stereo/system-ready.ogg

But that had the same effect as the other attempt; the drum roll sound played only after I had logged in.

So I am asking whether anyone has found a way to enable the drum roll sound to play before the user has logged in, when the user is presented with the login dialog.

I also tried --id="system-bootup" which should have brought up the drum roll sound much earlier. But even with that setting, the drum roll sound was not played until after I logged in.


Solution 1:

Here is a way using a systemd user unit running from the gdm user's home directory.

  • Save the following file as /var/lib/gdm3/.config/systemd/user/drumroll.service:

    [Unit]
    Description=Drumroll
    Requires=pulseaudio.socket
    After=systemd-user-sessions.service
    
    [Service]
    Type=simple
    Restart=no
    ExecStart=/usr/bin/paplay /usr/share/sounds/ubuntu/stereo/system-ready.ogg
    
    [Install]
    WantedBy=default.target
    

The above systemd unit should make sure that pulseaudio has been started in the gdm user context and execute the paplay command (I haven't tried canberra-gtk-play, but I would think it works as well).

After=systemd-user-sessions.service will make the service start only after the system is ready for user logins. (see http://manpages.ubuntu.com/manpages/artful/man8/systemd-user-sessions.service.8.html)

  • Then execute:

    $ sudo mkdir -p /var/lib/gdm3/.config/systemd/user/default.target.wants
    $ sudo ln -s /var/lib/gdm3/.config/systemd/user/drumroll.service /var/lib/gdm3/.config/systemd/user/default.target.wants/drumroll.service
    $ sudo chown gdm:gdm /var/lib/gdm3/.config/systemd/user/{drumroll.service,default.target.wants}
    

Those last commands make the unit start automatically when the systemd session of the gdm user is started.

  • Reboot to test.

To check for errors is a little bit tricky, because systemctl has the restriction to connect to either the system session or the calling user's session. To make gdm the calling user is easy with sudo, but some environment needs to be set up to make it possible to connect to its systemd user session:

$ sudo -u gdm XDG_RUNTIME_DIR="/run/user/$(id -u gdm)" DBUS_SESSION_BUS_ADDRESS="unix:path=${XDG_RUNTIME_DIR}/bus" systemctl --user status drumroll
● drumroll.service - Drumroll
   Loaded: loaded (/var/lib/gdm3/.config/systemd/user/drumroll.service; enabled; vendor preset: enabled)
   Active: inactive (dead) since Tue 2018-06-26 23:35:05 CEST; 36min ago
  Process: 1238 ExecStart=/usr/bin/paplay /usr/share/sounds/ubuntu/stereo/system-ready.ogg (code=exited, status=0/SUCCES
 Main PID: 1238 (code=exited, status=0/SUCCESS)

I haven't tried this with 17.10, but 18.04, but I don't see a reason it wouldn't work as well on 17.10.