1

Scenario: I play loud music. I leave the computer for an hour. I come back, and resume the music, not remembering that the volume is set to "full".

Question: Is there something a can install, such as a pulseaudio plugin, that will allow me to specify:

Given that no audio has been played for A seconds, and the volume is above B, when audio begins playback, play it at volume C, gradually increasing volume back to B over a time of D seconds.

It would be strongly preferable if this could be done "globally", so it doesn't matter what the source of the sound is.

user50849
  • 512

2 Answers2

0

You can install a music player that has such a feature.

To my knowledge, Clementine has this feature and it is available from the Ubuntu Software Center!

hytromo
  • 4,891
0

One option is to mute --- or lower --- the volume of your system on suspend (or resume), with a script. That means you have to crack it up manually after resume, but...

The command that set the volume should be something like:

pacmd set-sink-volume 0 20000

(pacmd is in the package pulseaudio-utils), where the 0 is the default sink (sound output) and the volume is a 16-bit number (from 0 to 65535); more details in this answer. You have to experiment to find the command that works for your system.

To make that automatic at suspend/resume time, you can use the same technique explained in this post: (I did not test it --- but it should work).

  1. edit/create the file

    gksudo gedit /etc/pm/sleep.d/02_shush

  2. Put this content in it:

    #!/bin/sh
    
    # set the volume low on suspend and resume. Change the command to suite your 
    # system. You can do that just in suspend OR resume or whatever; edit to your 
    # taste...
    
    case "$1" in
        resume|thaw)
            # this command(s) will be executed at resume time
            pacmd set-sink-volume 0 20000 > /dev/null
        ;;
        suspend|hibernate)
            # this command(s) will be executed before suspend
            pacmd set-sink-volume 0 20000 > /dev/null
        ;;
    esac
    
  3. save and exit

  4. make it executable:

    sudo chmod 755 /etc/pm/sleep.d/02_shush

Rmano
  • 32,167