LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Blogs > linux-related notes
User Name
Password

Notices


Just annotations of little "how to's", so I know I can find how to do something I've already done when I need to do it again, in case I don't remember anymore, which is not unlikely. Hopefully they can be useful to others, but I can't guarantee that it will work, or that it won't even make things worse.
Rate this Entry

Bash script to create a unified pactl-rexima-amixer command

Posted 06-23-2019 at 11:32 PM by the dsc
Updated 06-23-2019 at 11:39 PM by the dsc

For reasons I don't fully comprehend, every now and then, one or more of these tools won't work, but hopefully at least one will. In order to preserve openbox' rc.xml key bindings, I came up with this script that "unifies" simple commands to lower or increase the volume:
Code:
 #!/bin/bash
rexima vol ${1} && exit 0
pactl set-sink-volume 0 ${1}% && exit 0 
pactl set-sink-volume 1 ${1}% && exit 0
val=${1#+} ; val=${val#-} 
amixer -q sset Master ${val}%$(echo $1 | sed 's|[0-9]||g')
Basically, if any command succeeds, the script exits, and goes to the next if a command fails. The amixer command has all that sed stuff and string manipulation because that was how I managed to take a +N or -N input and transform it into N%+ or N%- respectively.

I don't quite get the whole pactl sink thing, it also seem to have alternated between "1" and "0" for it to work at some point.

I named it "volset," you can name it whatever you want. The syntax is just the script name followed by a number, alone for an absolute percent volume, or preceded by + or - to add or subtract a percentage.
Posted in Uncategorized
Views 468 Comments 0
« Prev     Main     Next »
Total Comments 0

Comments

 

  



All times are GMT -5. The time now is 11:24 PM.

Main Menu
Advertisement
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration