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
  • 492
  • 2
  • 7
  • 20

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,904
  • I might try clementine, but it would be even better if it could be set globally, (such as in pulseaudio), so it doesn't matter if I play music in the web browser (youtube music video or annoyingly loud ad), stream through spotify, or play local music with clementine. – user50849 Oct 30 '14 at 08:47
  • Yep, I see your point ;) – hytromo Oct 30 '14 at 08:49
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
  • 31,947
  • While that's an interesting idea, this assumes that machine hibernates, which it often doesn't in my case. I suppose I could write up the relevant script myself if I could ask pacmd for "is anything currently playing?", but I see no easy way to do that in pacmd --help. – user50849 Oct 30 '14 at 11:03