User talk:Wolfdogg

From ArchWiki
Jump to: navigation, search

volnoti on KDE using alsamixer

The only program that worked for a HP laptop to control the volume correctly on KDE.

@todo this script is for alsamixer, and kde, more needs to be added to support other environments

create a script /usr/local/bin/ This script will be called by another script placed in autostart.

insert the following contents in this script


#this script is made for volnoti

# Configuration
STEP="2"    # Anything you like.
UNIT="dB"   # dB, %, etc.

# Set volume
SETVOL="/usr/bin/amixer -qc 0 set Master"
SETHEADPHONE="/usr/bin/amixer -qc 0 set Headphone"

case "$1" in
          $SETVOL $STEP$UNIT+
          $SETVOL $STEP$UNIT-
          $SETVOL toggle

# Get current volume and state
VOLUME=$(amixer get Master | grep 'Mono:' | cut -d ' ' -f 6 | sed -e 's/[^0-9]//g')
STATE=$(amixer get Master | grep 'Mono:' | grep -o "\[off\]")

# Show volume with volnoti
if  -n $STATE ; then
  volnoti-show -m
  volnoti-show $VOLUME
  # If headphone is being used, mute is treated a bit differently when muted.  Make sure headphones follows master mute.
  amixer -c 0 set Headphone unmute
  amixer -c 0 set Speaker unmute
  amixer -qc 0 set Speaker 100%

exit 0

Note, the broken line above is this, i guess the wiki mishandles brackets in code

if -n $STATE ; then

ok, so its creating a link here too, ok let me spell it out for you

if left bracket, left bracket, -n $STATE right bracket, right bracket; then

save this script then set permissions

#chown root:users /usr/local/bin/
#chmod 755 /usr/local/bin/


install xbindkeys so that you can control volume with your keyboard

pacman -S xbindkeys

Logged in as user, create a xbindkeys config file ~/.xbindkeysrc with the following information for xbindkeys. This example sets the volume to the f7 (mute), f8 (vol down), and f9(vol up) keys

# increase volume
"sh /usr/local/bin/ up"
   m:0x0 + c:75

# Decrease volume
"sh /usr/local/bin/ down"
   m:0x0 + c:74

# Toggle mute
"sh /usr/local/bin/ mute"
   m:0x0 + c:73

#"amixer set Master playback 1+"


Logged in as user create the kde autostart script in ~/.kde4/Autostart. Name it anything e.g.


Save this script. Next time kde starts, it will run this script since its located in the autostart folder. It will call xbindkeys and volnoti, which will be waiting for keypresses to control alsamixer.