Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- # finds the active sink for pulse audio and increments the volume. useful when you have multiple audio outputs and have a key bound to vol-up and down
- osd='yes'
- inc=5
- capvol='yes'
- maxvol='200'
- active_sink=`pacmd list-sinks |awk '/* index:/{print $3}'`
- limit=$(expr 100 - ${inc})
- maxlimit=$(expr ${maxvol} - ${inc})
- function volUp {
- preVol=`pacmd list-sinks |grep -A 15 'index: '${active_sink}'' |awk '/volume: 0:/{ print $3}'|sed s/.$//`
- if [ ${capvol} = 'yes' ]
- then
- if [ ${preVol} -le 100 -a ${preVol} -ge ${limit} ]
- then
- pactl set-sink-volume ${active_sink} -- 100%
- elif [ ${preVol} -lt ${limit} ]
- then
- pactl set-sink-volume ${active_sink} -- +${inc}%
- fi
- elif [ ${preVol} -le ${maxvol} -a ${preVol} -ge ${maxlimit} ]
- then
- pactl set-sink-volume ${active_sink} -- ${maxvol}%
- elif [ ${preVol} -lt ${maxlimit} ]
- then
- pactl set-sink-volume ${active_sink} -- +${inc}%
- fi
- curVol=`pacmd list-sinks |grep -A 15 'index: '${active_sink}'' |awk '/volume: 0:/{ print $3}'|sed s/.$//`
- if [ ${osd} = 'yes' ]
- then
- qdbus org.kde.kded /modules/kosd showVolume ${curVol} 0
- fi
- }
- function volDown {
- pactl set-sink-volume ${active_sink} -- -${inc}%
- curVol=`pacmd list-sinks |grep -A 15 'index: '${active_sink}'' |awk '/volume: 0:/{ print $3}'|sed s/.$//`
- if [ ${osd} = 'yes' ]
- then
- qdbus org.kde.kded /modules/kosd showVolume ${curVol} 0
- fi
- }
- function volMute {
- case "$1" in
- mute)
- pactl set-sink-mute ${active_sink} 1
- curVol=0
- status=1
- ;;
- unmute)
- pactl set-sink-mute ${active_sink} 0
- curVol=`pacmd list-sinks |grep -A 15 'index: '${active_sink}'' |awk '/volume: 0:/{ print $3}'|sed s/.$//`
- status=0
- ;;
- esac
- if [ ${osd} = 'yes' ]
- then
- qdbus org.kde.kded /modules/kosd showVolume ${curVol} ${status}
- fi
- }
- function volMuteStatus {
- curStatus=`pacmd list-sinks |grep -A 15 'index: '${active_sink}'' |awk '/muted/{ print $2}'`
- if [ ${curStatus} = 'yes' ]
- then
- volMute unmute
- else
- volMute mute
- fi
- }
- case "$1" in
- --up)
- volUp
- ;;
- --down)
- volDown
- ;;
- --togmute)
- volMuteStatus
- ;;
- --mute)
- volMute mute
- ;;
- --unmute)
- volMute unmute
- ;;
- esac
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement