4

How do you configure Ubuntu 14.04 to play a short sound just before it suspends?

I bought a laptop which I later found had no visible status LEDs when the lid was closed. On past laptops, I've had problems with buggy ACPI drivers being sometimes unable to suspend, leading me to put a still-running laptop into a travel bag, causing the battery to die and the bag to get dangerously hot.

So, just for my peace of mind, I'd like to configure it to play a chime to give me an audible indication that the suspend function was engaged.

Cerin
  • 6,485

1 Answers1

0

You could create a two-line script:

#!/bin/bash
aplay ~/Music/suspend_sound.wav
qdbus com.canonical.Unity /com/canonical/Unity/Session com.canonical.Unity.Session.Suspend

Note, that aplay has limited set of types it supports (voc, wav, raw or au), so make sure you use sound file with appropriate format. The qdbus call is specific for Unity desktop, although you can use other dbus calls to suspend from other desktops. In Ubuntu 16.04 , you can use systemctl suspend for that as well. See the related post about suspending via commands: https://askubuntu.com/a/1795/295286

Sergiy Kolodyazhnyy
  • 105,154
  • 20
  • 279
  • 497