Startup Volume Script

Hairyplotter

Sometimes while listening to music or watching a movie on my laptop, I will shut the computer down and forget to lower the volume. So I wrote a small script and placed it in ~/.kde/Autostart to lower the volume to 30 if the current volume is higher than 30.

#!/bin/bash

# Is the current volume level greater than 30
if [ `aumix -q | grep vol | cut -d' ' -f3` -gt 30 ]; then
# YES, so lower the volume to 30
  aumix -v 30
fi

  1. Open up kwrite and paste the following:

    Code:

    #!/bin/bash
    if [ `aumix -q | grep vol | cut -d' ' -f3` -gt 30 ]; then
      aumix -v 30
    fi

  2. Select "File" -> "Save As" then type in:
    ~/.kde/Autostart/volume.sh
  3. Click "Save"
  4. Open Konsole then type:
    chmod u+x ~/.kde/Autostart/volume.sh
  5. Press <enter> and your all set.

Depending on how loud you want the volume to be by default, you can adjust it by changing the 30 in line 2 and 3 of the code above.

An alternate version of the script was also posted in the original forum thread by Woo58.

#!/bin/bash
if [ `aumix -q | grep vol | awk '{ print $3
}'` \> "30," ]; then aumix -v 30
fi

PCLinuxOS Wiki

Top | Next