├── INSTALL ├── MIT ├── Makefile ├── README.md ├── common ├── config.skel ├── pulseaudio-ctl.in └── zsh-completion └── doc └── pulseaudio-ctl.1 /INSTALL: -------------------------------------------------------------------------------- 1 | DEPENDENCIES 2 | bash>4.0 3 | bc 4 | coreutils 5 | gawk 6 | grep 7 | libpulse 8 | pulseaudio>=4.0 9 | 10 | BUILDING 11 | Setup the via a make. 12 | 13 | $ make 14 | 15 | Running a `make install` as root will distribute the files to 16 | the file system. 17 | 18 | USE A DISTRO PROVIDED PACKAGE 19 | ARCH LINUX 20 | Arch users may build the package directly with the provided 21 | PKGBUILD: https://aur.archlinux.org/packages/pulseaudio-ctl 22 | -------------------------------------------------------------------------------- /MIT: -------------------------------------------------------------------------------- 1 | Copyright (c) 2013-2021 graysky 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 4 | 5 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 6 | 7 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 8 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | VERSION = 1.70 2 | PN = pulseaudio-ctl 3 | 4 | PREFIX ?= /usr 5 | BINDIR = $(PREFIX)/bin 6 | MANDIR = $(PREFIX)/share/man/man1 7 | SKELDIR = $(PREFIX)/share/$(PN) 8 | ZSHDIR = $(PREFIX)/share/zsh/site-functions 9 | RM = rm 10 | Q = @ 11 | 12 | all: common/$(PN) doc/$(PN).1 13 | 14 | common/$(PN): common/$(PN).in 15 | $(Q)echo -e '\033[1;32mSetting version\033[0m' 16 | $(Q)sed -e 's/@VERSION@/'$(VERSION)'/' common/$(PN).in >common/$(PN) 17 | $(Q)sed -i common/$(PN) -e 's|@SKELDIR@|'$(SKELDIR)'|' 18 | 19 | doc/$(PN).1: doc/$(PN).1 20 | 21 | clean: 22 | $(RM) -f common/$(PN) 23 | $(RM) -f doc/$(PN).1 24 | 25 | install-bin: 26 | $(Q)echo -e '\033[1;32mInstalling main script and config...\033[0m' 27 | install -Dm755 common/$(PN) "$(DESTDIR)$(BINDIR)/$(PN)" 28 | install -Dm644 common/config.skel "$(DESTDIR)$(SKELDIR)/config.skel" 29 | install -p -dm755 "$(DESTDIR)$(ZSHDIR)" 30 | install -Dm644 common/zsh-completion "$(DESTDIR)$(ZSHDIR)/_pulseaudio-ctl" 31 | 32 | install-man: 33 | $(Q)echo -e '\033[1;32mInstalling manpage...\033[0m' 34 | install -Dm644 doc/$(PN).1 "$(DESTDIR)$(MANDIR)/$(PN).1" 35 | 36 | uninstall: 37 | $(RM) "$(DESTDIR)$(BINDIR)/$(PN)" 38 | $(RM) "$(DESTDIR)$(MANDIR)/$(PN).1" 39 | $(RM) -rf "$(DESTDIR)$(SKELDIR)" 40 | $(RM) "$(DESTDIR)$(ZSHDIR)/_pulseaudio-ctl" 41 | 42 | install: all install-bin install-man 43 | 44 | .PHONY: all clean install-bin install-man uninstall 45 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Pulseaudio-ctl 2 | Simple bash script to allow for control of pulseaudio without alsautils. Simply map the following to keyboard shortcuts in your DE or WM. Xfce4 allows for this under Settings > Keyboard > Application Shortcuts. 3 | 4 | /usr/bin/pulseaudio-ctl mute ==> Toggle status of mute 5 | /usr/bin/pulseaudio-ctl mute-input ==> Toggle status of mute for mic 6 | /usr/bin/pulseaudio-ctl up ==> Increase vol by 5 % 7 | /usr/bin/pulseaudio-ctl up 25 ==> Increase vol by 25 % 8 | /usr/bin/pulseaudio-ctl down ==> Decrease vol by 5 % 9 | /usr/bin/pulseaudio-ctl down 50 ==> Decrease vol by 50 % 10 | /usr/bin/pulseaudio-ctl set 40 ==> Set vol to 40% 11 | /usr/bin/pulseaudio-ctl atmost 30 ==> Set vol to 30% if current higher than that 12 | 13 | ## Configuration 14 | A config file resides in ~/.config/pulseaudio-ctl/config and allows for some options including: 15 | 16 | Example: 17 | ```bash 18 | # The default setting is for pulseaudio-ctl to NOT increase to volume level 19 | # above 100 % but Some users may wish exceed this level. If this describes 20 | # your use case, uncomment the UPPER_THRESHOLD variable below setting it to 21 | # the new upper threshold. 22 | # 23 | UPPER_THRESHOLD=150 24 | 25 | # Push output through libnotify. Set to any value to enable this feature 26 | # and note that you must have /usr/bin/notify-send to use this. On Arch 27 | # libnotify provides this. Other distros may not name it as such. 28 | NOTIFY=yes 29 | 30 | # Show a graphical progress-bar type visualization of the volume level in 31 | # libnotify. No setting or commented out will show a simply percentage but 32 | # a setting will convert the percentage to a progress-bar in libnotify. 33 | # 34 | BARCHART=yes 35 | 36 | # Use KDE OSD notification. Set to any value to enable this feature. 37 | KDE_OSD=yes 38 | ``` 39 | 40 | If config file isn't present script uses default value 100 for the UPPER_THRESHOLD and notifications are disabled by default. 41 | 42 | ## Links 43 | AUR package: https://aur.archlinux.org/packages/pulseaudio-ctl 44 | -------------------------------------------------------------------------------- /common/config.skel: -------------------------------------------------------------------------------- 1 | # 2 | # $HOME/.config/pulseaudio-ctl/config 3 | # 4 | 5 | # The default setting is for pulseaudio-ctl to NOT increase to volume level 6 | # above 100 % but Some users may wish exceed this level. If this describes 7 | # your use case, uncomment the UPPER_THRESHOLD variable below setting it to 8 | # the new upper threshold. 9 | # 10 | #UPPER_THRESHOLD=150 11 | 12 | # Push output through libnotify. Set to any value to enable this feature 13 | # and note that you must have /usr/bin/notify-send to use this. On Arch 14 | # libnotify provides this. Other distros may not name it as such. 15 | # 16 | #NOTIFY=yes 17 | 18 | # Show a graphical progress-bar type visualization of the volume level in 19 | # libnotify. No setting or commented out will show a simply percentage but 20 | # a setting will convert the percentage to a progress-bar in libnotify. 21 | # 22 | #BARCHART=yes 23 | 24 | # Use KDE OSD notification. Set to any value to enable this feature. 25 | #KDE_OSD=yes 26 | -------------------------------------------------------------------------------- /common/pulseaudio-ctl.in: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # pulseaudio-ctl 4 | # 5 | # simple control of pulseaudio vol+/vol-/mute from the shell 6 | # or more practically, from DE shortcut keys 7 | # 8 | # by graysky 9 | # https://github.com/graysky2/pulseaudio-ctl 10 | 11 | VERS="@VERSION@" 12 | SKEL="@SKELDIR@/config.skel" 13 | CONFIG="${XDG_CONFIG_HOME:-$HOME/.config}/pulseaudio-ctl/config" 14 | LANG=C 15 | 16 | BLD="\e[01m" 17 | BLU="\e[01;34m" 18 | RED="\e[01;31m" 19 | NRM="\e[00m" 20 | GRN="\e[01;32m" 21 | 22 | command -v sed >/dev/null 2>&1 || { 23 | echo "I require sed but it's not installed. Aborting." >&2 24 | exit 1; } 25 | 26 | command -v awk >/dev/null 2>&1 || { 27 | echo "I require awk but it's not installed. Aborting." >&2 28 | exit 1; } 29 | 30 | command -v pactl >/dev/null 2>&1 || { 31 | echo "I require pactl but it's not installed. Aborting." >&2 32 | exit 1; } 33 | 34 | command -v pacmd >/dev/null 2>&1 || { 35 | echo "I require pacmd but it's not installed. Aborting." >&2 36 | exit 1; } 37 | 38 | # really crude pactl version check since commands are different for different 39 | # versions of pactl. sorry users of PA <5 40 | PAVERSION=$(pactl --version | grep pactl | sed 's/^pactl \([0-9]*\.[0-9]\).*/\1/') 41 | if [[ ${PAVERSION%%.*} -lt 5 ]]; then 42 | # really old versions 43 | PCV=0 44 | elif [[ 1 -eq "$(echo "${PAVERSION} > 10.9" | bc)" ]]; then 45 | # since v11, they reverted the -- requirement 46 | PCV=2 47 | elif [[ 1 -eq "$(echo "${PAVERSION} > 5.1" | bc)" ]]; then 48 | # version is upstream 5.99.2 or higher 49 | PCV=2 50 | elif [[ 1 -eq "$(echo "${PAVERSION} < 5.1" | bc)" ]]; then 51 | # version is upstream 5.0 52 | PCV=1 53 | fi 54 | 55 | # stop if the above failed to set a value for PCV 56 | if [[ -z $PCV ]]; then 57 | echo -e ${BLD}"Cannot determine which version of pactl is installed. ${RED}Aborting."${NRM} 58 | exit 1 59 | fi 60 | 61 | is_integer() { 62 | if [[ "$1" =~ ^[0-9]+$ ]]; then 63 | echo 1; 64 | else 65 | echo 0; 66 | fi 67 | } 68 | 69 | makeconfig() { 70 | if [[ ! -f "$SKEL" ]]; then 71 | echo -e "${RED}$SKEL is missing. Reinstall this package to continue."${NRM} 72 | exit 1 73 | fi 74 | 75 | if [[ ! -f "$CONFIG" ]]; then 76 | echo -e ${BLD}'------------------------------------------------------------'${NRM} 77 | echo -e ${BLD}' No config file found so creating a fresh one in:'${NRM} 78 | echo -e ${BLD}${BLU}" $CONFIG"${NRM} 79 | echo 80 | echo -e ${BLD}" Edit this file if desired."${NRM} 81 | echo -e ${BLD}'------------------------------------------------------------'${NRM} 82 | install -Dm644 "$SKEL" "$CONFIG" 83 | fi 84 | } 85 | 86 | checkconfig() { 87 | if [[ ! -f "$CONFIG" ]]; then 88 | makeconfig 89 | else 90 | source "$CONFIG" 91 | if [[ -n "$UPPER_THRESHOLD" ]]; then 92 | [[ $(is_integer "$UPPER_THRESHOLD") == '1' ]] || UPPER_THRESHOLD=100 93 | else 94 | UPPER_THRESHOLD=100 95 | fi 96 | fi 97 | 98 | case "${NOTIFY,,}" in 99 | y|yes|true|t|on|1|enabled|enable|use) 100 | USEN=1 101 | command -v notify-send >/dev/null 2>&1 || { 102 | echo "You wish to use notifications but I require notify-send but it's not installed." >&2 103 | echo "Modify $CONFIG or install the package that provides it. Aborting." >&2 104 | exit 1; } 105 | ;; 106 | *) 107 | USEN=0 108 | ;; 109 | esac 110 | 111 | case "${BARCHART,,}" in 112 | y|yes|true|t|on|1|enabled|enable|use) 113 | USEB=1 114 | ;; 115 | *) 116 | USEB=0 117 | ;; 118 | esac 119 | 120 | case "${KDE_OSD,,}" in 121 | y|yes|true|t|on|1|enabled|enable|use) 122 | USEK=1 123 | command -v dbus-send >/dev/null 2>&1 || { 124 | echo "You wish to use KDE OSD notifications but I require dbus-send but it's not installed." >&2 125 | echo "Modify $CONFIG or install the package that provides it. Aborting." >&2 126 | exit 1; } 127 | ;; 128 | *) 129 | USEK=0 130 | ;; 131 | esac 132 | 133 | } 134 | 135 | refreshcurvol() { 136 | [[ $PCV -eq 0 ]] && 137 | CURVOL=$(pacmd list-sinks|grep -A 15 '* index'| awk '/volume: /{ print $3 }' | grep -m 1 % |sed 's/[%|,]//g') || 138 | CURVOL=$(pacmd list-sinks|grep -A 15 '* index'| awk '/volume: /{ print $5 }' | grep -m 1 % |sed 's/[%|,]//g') 139 | } 140 | 141 | refreshsrcvol() { 142 | [[ $PCV -eq 0 ]] && 143 | SRCVOL=$(pacmd list-sources|grep -A 15 '* index'| awk '/volume: /{ print $3 }' | grep -m 1 % |sed 's/[%|,]//g') || 144 | SRCVOL=$(pacmd list-sources|grep -A 15 '* index'| awk '/volume: /{ print $5 }' | grep -m 1 % |sed 's/[%|,]//g') 145 | } 146 | 147 | refreshbarvolperc() { 148 | # calculates the volume percentage based on UPPER_THRESHOLD 149 | # for proper display in the bar 150 | UPPER_THRESHOLD_AWARE_VOL=$CURVOL*100/$UPPER_THRESHOLD 151 | } 152 | 153 | setup() { 154 | SINK=$(pacmd list-sinks|awk '/\* index:/{ print $3 }') 155 | SOURCE=$(pacmd list-sources|awk '/\* index:/{ print $3 }') 156 | MUTED=$(pacmd list-sinks|grep -A 15 '* index'|awk '/muted:/{ print $2 }') 157 | SOURCE_MUTED=$(pacmd list-sources|grep -A 15 '* index'|awk '/muted:/{ print $2 }') 158 | 159 | refreshcurvol # sets CURVOL ahead of integer check 160 | 161 | # check that extracted vars are integers 162 | declare -A VARS_TO_CHECK 163 | VARS_TO_CHECK=([SINK]="default sink" [SOURCE]="default source" [CURVOL]="current volume") 164 | for v in "${!VARS_TO_CHECK[@]}"; do 165 | if [[ -n "${!v}" ]]; then 166 | [[ $(is_integer "${!v}") == '1' ]] || echo -e "${RED}Cannot determine ${VARS_TO_CHECK[$v]}."${NRM} 167 | else 168 | return 0 169 | fi 170 | done 171 | } 172 | 173 | kde_osd() { 174 | dbus-send --session --dest="org.kde.plasmashell" --type="method_call" "/org/kde/osdService" "org.kde.osdService.volumeChanged" "int32:$1" "int32:$UPPER_THRESHOLD" 175 | } 176 | 177 | kde_osd_mic() { 178 | dbus-send --session --dest="org.kde.plasmashell" --type="method_call" "/org/kde/osdService" "org.kde.osdService.mediaPlayerVolumeChanged" "int32:$1" "string:" "string:audio-input-microphone" 179 | } 180 | 181 | checkconfig 182 | setup 183 | # checks if exist a valid $2 184 | PERC=5 185 | [[ -n "$2" ]] && [[ $(is_integer "${2%%%}") == '1' ]] && PERC=${2%%%} 186 | 187 | case "$1" in 188 | U|u|[U,u]p) 189 | # raise volume by $PERC % or set it to the upper threshold 190 | # in cases where external apps have pushed it above 191 | [[ "$(( $PERC + $CURVOL ))" -gt "$UPPER_THRESHOLD" ]] && PERC="$(( $UPPER_THRESHOLD - $CURVOL ))" 192 | [[ "$CURVOL" -ge $UPPER_THRESHOLD ]] && pactl set-sink-volume "$SINK" $UPPER_THRESHOLD% || 193 | case "$PCV" in 194 | 0|1) pactl set-sink-volume "$SINK" -- +$PERC% ;; 195 | 2) pactl set-sink-volume "$SINK" +$PERC% ;; 196 | esac 197 | 198 | refreshcurvol 199 | refreshbarvolperc 200 | if [[ $USEN -eq 1 ]]; then 201 | [[ $USEB -eq 1 ]] && 202 | notify-send -a pulseaudio-ctl -t 1000 -i multimedia-volume-control --hint=int:transient:1 --hint=int:value:$UPPER_THRESHOLD_AWARE_VOL --hint=string:synchronous:volume "Volume up $PERC %" "" || 203 | notify-send -a pulseaudio-ctl -t 1000 --hint=int:transient:1 "Volume up $PERC%" "Current is $CURVOL %" --icon=multimedia-volume-control 204 | fi 205 | [[ $USEK -eq 1 ]] && 206 | kde_osd $CURVOL 207 | ;; 208 | D|d|[D,d]own|[D,d]o) 209 | # lowers volume by $PERC % 210 | [[ "$PERC" -gt "$CURVOL" ]] && PERC="$CURVOL" 211 | [[ "$CURVOL" -le 0 ]] && exit 0 || 212 | case "$PCV" in 213 | 0|1) pactl set-sink-volume "$SINK" -- -$PERC% ;; 214 | 2) pactl set-sink-volume "$SINK" -$PERC% ;; 215 | esac 216 | refreshcurvol 217 | refreshbarvolperc 218 | if [[ $USEN -eq 1 ]]; then 219 | [[ $USEB -eq 1 ]] && 220 | notify-send -a pulseaudio-ctl -t 1000 -i multimedia-volume-control --hint=int:transient:1 --hint=int:value:$UPPER_THRESHOLD_AWARE_VOL --hint=string:synchronous:volume "Volume down $PERC %" "" || 221 | notify-send -a pulseaudio-ctl -t 1000 --hint=int:transient:1 "Volume down $PERC%" "Current is $CURVOL %" --icon=multimedia-volume-control 222 | fi 223 | [[ $USEK -eq 1 ]] && 224 | kde_osd $CURVOL 225 | ;; 226 | M|m|[M,m]u|[M,m]ute) 227 | # mutes/unmutes the volume entirely 228 | NEW_MUTE=toggle 229 | if [[ $2 == 'no' || $2 == 'yes' || $2 == 'toggle' ]]; then 230 | NEW_MUTE="$2" 231 | fi 232 | pactl set-sink-mute "$SINK" "$NEW_MUTE" 233 | MUTED=$(pacmd list-sinks|grep -A 15 '* index'|awk '/muted:/{ print $2 }') 234 | [[ $USEN -eq 1 ]] && 235 | notify-send -a pulseaudio-ctl -t 1000 --hint=int:transient:1 "Mute toggle" "Muted: $MUTED" --icon=audio-volume-muted 236 | if [[ $USEK -eq 1 ]]; then 237 | if [[ $MUTED == "yes" ]]; then 238 | kde_osd 0 239 | else 240 | refreshcurvol 241 | kde_osd $CURVOL 242 | fi 243 | fi 244 | ;; 245 | [M,m]i|[M,m]ute-[I,i]nput) 246 | # mutes/umutes the microphone entirely 247 | NEW_MUTE=toggle 248 | if [[ $2 == 'no' || $2 == 'yes' || $2 == 'toggle' ]]; then 249 | NEW_MUTE="$2" 250 | fi 251 | pactl set-source-mute "$SOURCE" "$NEW_MUTE" 252 | SOURCE_MUTED=$(pacmd list-sources|grep -A 15 '* index'|awk '/muted:/{ print $2 }') 253 | [[ $USEN -eq 1 ]] && 254 | notify-send -a pulseaudio-ctl -t 1000 --hint=int:transient:1 "Mute toggle" "Muted: $SOURCE_MUTED" --icon=audio-volume-muted 255 | if [[ $USEK -eq 1 ]]; then 256 | if [[ $SOURCE_MUTED == "yes" ]]; then 257 | kde_osd_mic 0 258 | else 259 | refreshsrcvol 260 | kde_osd_mic $SRCVOL 261 | fi 262 | fi 263 | ;; 264 | set) 265 | NEWVOL="${2%%%}" 266 | [[ "$NEWVOL" -gt $UPPER_THRESHOLD ]] && exit 0 || 267 | [[ "$NEWVOL" -le 0 ]] && exit 0 || 268 | case "$PCV" in 269 | 0|1) pactl set-sink-volume "$SINK" -- $NEWVOL% ;; 270 | 2) pactl set-sink-volume "$SINK" $NEWVOL% ;; 271 | esac 272 | refreshcurvol 273 | [[ $USEN -eq 1 ]] && 274 | notify-send -a pulseaudio-ctl -t 1000 --hint=int:transient:1 "Volume set" "Level: $CURVOL" --icon=multimedia-volume-control 275 | [[ $USEK -eq 1 ]] && 276 | kde_osd $CURVOL 277 | ;; 278 | atmost) 279 | NEWVOL="${2%%%}" 280 | [[ "$CURVOL" -le "$NEWVOL" ]] && exit 0 || 281 | [[ "$NEWVOL" -ge $UPPER_THRESHOLD ]] && exit 0 || 282 | [[ "$NEWVOL" -le 0 ]] && exit 0 || 283 | case "$PCV" in 284 | 0|1) pactl set-sink-volume "$SINK" -- $NEWVOL% ;; 285 | 2) pactl set-sink-volume "$SINK" $NEWVOL% ;; 286 | esac 287 | refreshcurvol 288 | [[ $USEN -eq 1 ]] && 289 | notify-send -a pulseaudio-ctl -t 1000 --hint=int:transient:1 "Atmost set" "Level: $CURVOL" --icon=multimedia-volume-control 290 | [[ $USEK -eq 1 ]] && 291 | kde_osd $CURVOL 292 | ;; 293 | C|c|[C,c]urrent) 294 | # useful only for scripting 295 | echo $CURVOL% 296 | ;; 297 | [F,f]s|[F,f]ull-[S,s]tatus) 298 | # useful for scripting. 299 | # returns current volume and sink and source mute state 300 | echo $CURVOL $MUTED $SOURCE_MUTED 301 | ;; 302 | *) 303 | # send to notify-send if enabled 304 | [[ $USEN -eq 1 ]] && 305 | notify-send -a pulseaudio-ctl -t 8000 --hint=int:transient:1 "Pulseaudio Settings" "Volume level : $CURVOL %\nIs sink muted : $MUTED\nIs source muted : $SOURCE_MUTED\nDetected sink : $SINK\nDetected source : $SOURCE" --icon=multimedia-volume-control 306 | # add pretty colors for mute status for CLI only 307 | [[ "$MUTED" = "yes" ]] && MUTED="${NRM}${RED}$MUTED${NRM}" || 308 | MUTED="${NRM}${GRN}$MUTED${NRM}" 309 | [[ "$SOURCE_MUTED" = "yes" ]] && SOURCE_MUTED="${NRM}${RED}$SOURCE_MUTED${NRM}" || 310 | SOURCE_MUTED="${NRM}${GRN}$SOURCE_MUTED${NRM}" 311 | 312 | echo -e "${BLD}pulseaudio-ctl v$VERS${NRM}" 313 | echo 314 | echo -e " ${BLD}$0 ${NRM}${BLU}{up,down,mute,mute-input,set,atmost,full-status}${NRM} [n]" 315 | echo 316 | echo -e " ${BLD}Where ${NRM}${BLU}up${NRM}${BLD} and ${NRM}${BLU}down${NRM}${BLD} adjust volume in ±5 % increments${NRM}" 317 | echo -e " ${BLD}Where ${NRM}${BLU}up${NRM}${BLD} and ${NRM}${BLU}down${NRM}${BLD} [n] adjust volume in ±n % increments${NRM}" 318 | echo -e " ${BLD}Where ${NRM}${BLU}mute${NRM}${BLD} toggles the mute status on/off${NRM}" 319 | echo -e " ${BLD}Where ${NRM}${BLU}mute-input${NRM}${BLD} toggles the input status on/off${NRM}" 320 | echo -e " ${BLD}Where ${NRM}${BLU}set${NRM}${BLD} set the volume to [n] %${NRM}" 321 | echo -e " ${BLD}Where ${NRM}${BLU}atmost${NRM}${BLD} only takes effect if current volume is higher than [n]${NRM}" 322 | echo -e " ${BLD}Where ${NRM}${BLU}full-status${NRM}${BLD} prints volume level, sink and source mute state to stdout${NRM}" 323 | echo 324 | echo -e " ${BLD}Optionally, redefine an upper threshold in ${NRM}${BLU}$CONFIG${NRM}" 325 | echo 326 | echo -e " ${BLD}Volume level : ${NRM}${RED}$CURVOL %${NRM}" 327 | echo -e " ${BLD}Is sink muted : $MUTED" 328 | echo -e " ${BLD}Is source muted : $SOURCE_MUTED" 329 | echo -e " ${BLD}Detected sink : ${NRM}${BLU}$SINK${NRM}" 330 | echo -e " ${BLD}Detected source : ${NRM}${BLU}$SOURCE${NRM}" 331 | ;; 332 | esac 333 | 334 | exit 0 335 | 336 | # vim:set ts=8 sts=2 sw=2 et: 337 | -------------------------------------------------------------------------------- /common/zsh-completion: -------------------------------------------------------------------------------- 1 | #compdef pulseaudio-ctl 2 | 3 | _pulseaudio-ctl() { 4 | local -a options 5 | 6 | options=('up:increase volume by 5%' 7 | 'down:decrease volume by 5%' 8 | 'mute:toggle the mute status on/off' 9 | 'mute-input:toggles the input status on/off' 10 | 'set:set the volume to [n] %' 11 | 'atmost:only takes effect if current volume is higher than [n]' 12 | 'full-status:print current volume, sink mute state amd source mute state to stdout') 13 | 14 | _describe 'options' options 15 | } 16 | 17 | _pulseaudio-ctl 18 | -------------------------------------------------------------------------------- /doc/pulseaudio-ctl.1: -------------------------------------------------------------------------------- 1 | .\" Text automatically generated by txt2man 2 | .TH pulseaudio-ctl 1 "25 March 2017" "" "" 3 | .SH NAME 4 | \fBpulseaudio-ctl \fP- Control pulseaudio's basic functions such as the master volume level and mute status from a mapped key. 5 | \fB 6 | .SH SYNOPSIS 7 | .nf 8 | .fam C 9 | \fBpulseaudio-ctl\fP [\fIoption1\fP] [\fIoption2\fP] 10 | 11 | .fam T 12 | .fi 13 | .fam T 14 | .fi 15 | .SH DESCRIPTION 16 | Recommended usage of \fBpulseaudio-ctl\fP is to map a call to the script (see below) to a single keypress for easy access to change mute status or quickly adjust master volume levels. Many keyboards have keys specific to these particular actions and many if not all DE or WMs offer the ability to natively map a script call to a keypress or combo of key presses. For example, xfce4 allows for this under Settings > Keyboard > Application Shortcuts. 17 | .SH CONFIG 18 | .TP 19 | .B 20 | Persistent options are stored in $HOME/.config/\fBpulseaudio-ctl\fP/config which is sufficiently commented for users to understand. 21 | Inspect this file and uncomment those that suit your needs. 22 | .SH OPTIONS 23 | .TP 24 | .B 25 | up 26 | Adjust master volume up by 5 % (default) or up by another value defined as the 2nd token 27 | .TP 28 | .B 29 | down 30 | Adjust master volume down by 5 % (default) or down by another value defined as the 2nd token 31 | .TP 32 | .B 33 | mute 34 | Set the mute status of the master volume to the value defined in the 2nd token. Toggle by default. 35 | .TP 36 | .B 37 | mute-input 38 | Set the mute status of the input device (microphone for example) to the value defined in the 2nd token. Toggle by default. 39 | .TP 40 | .B 41 | set 42 | Set the master volume level to the number specified as the 2nd token 43 | .TP 44 | .B 45 | atmost 46 | Like the 'set' option only takes effect if the current volume is higher than the 2nd token 47 | .TP 48 | .B 49 | current 50 | Print the current volume level to STDOUT 51 | .TP 52 | .B 53 | full-status 54 | Print the current volume level, the sink mute state and the source mute state to STDOUT 55 | .SH EXAMPLES 56 | Increase vol level by 5 % 57 | .PP 58 | .nf 59 | .fam C 60 | /usr/bin/pulseaudio-ctl up 61 | 62 | .fam T 63 | .fi 64 | Increase vol level by 25 % 65 | .PP 66 | .nf 67 | .fam C 68 | /usr/bin/pulseaudio-ctl up 25 69 | 70 | .fam T 71 | .fi 72 | Toogle mute current output 73 | .PP 74 | .nf 75 | .fam C 76 | /usr/bin/pulseaudio-ctl mute 77 | 78 | .fam T 79 | .fi 80 | Unmute current output 81 | .PP 82 | .nf 83 | .fam C 84 | /usr/bin/pulseaudio-ctl mute no 85 | 86 | .fam T 87 | .fi 88 | Set current vol level to 85 % 89 | .PP 90 | .nf 91 | .fam C 92 | /usr/bin/pulseaudio-ctl set 85 93 | 94 | .fam T 95 | .fi 96 | .SH CONTRIBUTE 97 | Should you wish to contribute to this code, please fork and send a pull request. Source is freely available on github: https://github.com/graysky2/\fBpulseaudio-ctl\fP 98 | .SH BUGS 99 | None known 100 | .SH AUTHOR 101 | graysky (graysky AT archlinux DOT us) 102 | --------------------------------------------------------------------------------