Home > linux, python > setting the volume from the command line

setting the volume from the command line

I have a laptop where the default volume is weak. On the system tray the volume is on 100% but it’s still weak. So far I started the program “pavucontrol”, which is a GUI application, and there I set the volume to 150% (that’s the maximum). However, if I watch a youtube video and pause it, in pavucontrol the volume falls back to 100%, so I need to adjust it after each pause.

I found a command line program that allows one to set the volume. It’s independent of pavucontrol. So I made a script that runs automatically when the graphical interface comes up:

#!/usr/bin/env bash

# from http://askubuntu.com/questions/44680
# listing current volume:
#     pacmd list-sinks | grep volume

cmd="pacmd set-sink-volume 0 100000"
echo "#" $cmd

First list your sinks with “pacmd list-sinks”. I only had one, hence the id 0. The value 100000 is the volume (on my system it’s equivalent to 153%). Value 65535 is volume 100%.

Tip from here.

Update (20160604)
I made a wrapper script around pacmd; you can find it here on GitHub. Its usage is very simple. Do you want to increase the volume? Just call “volume.py 140%” and you are done.

  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: