Skip to content

Commit 1ece29e

Browse files
Merge pull request #77 from sinapis-amicus/master
quotes prevent glob and word splitting + typos
2 parents ae4908d + f865e24 commit 1ece29e

File tree

2 files changed

+19
-19
lines changed

2 files changed

+19
-19
lines changed

README.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ Download the [bash script](https://github.com/marioortizmanero/polybar-pulseaudi
3030

3131
This script works with PipeWire as well, as long as your system has something like [`pipewire-pulse`](https://archlinux.org/packages/extra/x86_64/pipewire-pulse/).
3232

33-
To be able to switch the default sinks from this script you might need to disable stream target device restore by editing the corresponing line in `/etc/pulse/default.pa` to:
33+
To be able to switch the default sinks from this script you might need to disable stream target device restore by editing the corresponding line in `/etc/pulse/default.pa` to:
3434

3535
```
3636
load-module module-stream-restore restore_device=false
@@ -108,7 +108,7 @@ Options:
108108
extension.
109109
Default: none
110110
--node-nicknames-from <prop>
111-
pactl property to use for node names, unless overriden by
111+
pactl property to use for node names, unless overridden by
112112
--node-nickname. Its possible values are listed under the 'Properties'
113113
key in the output of `pactl list sinks` and `pactl list sources`.
114114
Default: none
@@ -274,4 +274,4 @@ Part of the script and of this README's info was taken from [customlinux.blogspo
274274

275275
## Development
276276

277-
Any PRs and issues are welcome! The tests can be ran with `bats tests.bats`, preferrably with the Dockerfile in this repository.
277+
Any PRs and issues are welcome! The tests can be ran with `bats tests.bats`, preferably with the Dockerfile in this repository.

pulseaudio-control.bash

+16-16
Original file line numberDiff line numberDiff line change
@@ -55,21 +55,21 @@ function getCurNode() {
5555
local curNodeName
5656

5757
curNodeName=$(pactl info | awk "/Default S${SINK_OR_SOURCE}: / {print \$3}")
58-
curNode=$(pactl list s${SINK_OR_SOURCE}s | grep -B 4 -E "Name: $curNodeName\$" | sed -nE "s/^S${SINK_OR_SOURCE} #([0-9]+)$/\1/p")
58+
curNode=$(pactl list "s${SINK_OR_SOURCE}s" | grep -B 4 -E "Name: $curNodeName\$" | sed -nE "s/^S${SINK_OR_SOURCE} #([0-9]+)$/\1/p")
5959
}
6060

6161

6262
# Saves the node passed by parameter's volume into a variable named `VOL_LEVEL`.
6363
function getCurVol() {
64-
VOL_LEVEL=$(pactl list s${SINK_OR_SOURCE}s | grep -A 15 -E "^S${SINK_OR_SOURCE} #$1\$" | grep 'Volume:' | grep -E -v 'Base Volume:' | awk -F : '{print $3; exit}' | grep -o -P '.{0,3}%' | sed 's/.$//' | tr -d ' ')
64+
VOL_LEVEL=$(pactl list "s${SINK_OR_SOURCE}s" | grep -A 15 -E "^S${SINK_OR_SOURCE} #$1\$" | grep 'Volume:' | grep -E -v 'Base Volume:' | awk -F : '{print $3; exit}' | grep -o -P '.{0,3}%' | sed 's/.$//' | tr -d ' ')
6565
}
6666

6767

6868
# Saves the name of the node passed by parameter into a variable named
6969
# `nodeName`.
7070
function getNodeName() {
71-
nodeName=$(pactl list s${SINK_OR_SOURCE}s short | awk -v sink="$1" "{ if (\$1 == sink) {print \$2} }")
72-
portName=$(pactl list s${SINK_OR_SOURCE}s | grep -e "S${SINK_OR_SOURCE} #" -e 'Active Port: ' | sed -n "/^S${SINK_OR_SOURCE} #$1\$/,+1p" | awk '/Active Port: / {print $3}')
71+
nodeName=$(pactl list "s${SINK_OR_SOURCE}s" short | awk -v sink="$1" "{ if (\$1 == sink) {print \$2} }")
72+
portName=$(pactl list "s${SINK_OR_SOURCE}s" | grep -e "S${SINK_OR_SOURCE} #" -e 'Active Port: ' | sed -n "/^S${SINK_OR_SOURCE} #$1\$/,+1p" | awk '/Active Port: / {print $3}')
7373
}
7474

7575

@@ -127,13 +127,13 @@ function getNicknameFromProp() {
127127
break
128128
;;
129129
esac
130-
done < <(pactl list s${SINK_OR_SOURCE}s)
130+
done < <(pactl list "s${SINK_OR_SOURCE}s")
131131
}
132132

133133
# Saves the status of the node passed by parameter into a variable named
134134
# `IS_MUTED`.
135135
function getIsMuted() {
136-
IS_MUTED=$(pactl list s${SINK_OR_SOURCE}s | grep -E "^S${SINK_OR_SOURCE} #$1\$" -A 15 | awk '/Mute: / {print $2}')
136+
IS_MUTED=$(pactl list "s${SINK_OR_SOURCE}s" | grep -E "^S${SINK_OR_SOURCE} #$1\$" -A 15 | awk '/Mute: / {print $2}')
137137
}
138138

139139

@@ -164,9 +164,9 @@ function volUp() {
164164
# increase percentage was 3%, a 99% volume would top at 100% instead
165165
# of 102%. If the volume is above the maximum limit, nothing is done.
166166
if [ "$VOL_LEVEL" -le "$VOLUME_MAX" ] && [ "$VOL_LEVEL" -ge "$maxLimit" ]; then
167-
pactl set-s${SINK_OR_SOURCE}-volume "$curNode" "$VOLUME_MAX%"
167+
pactl "set-s${SINK_OR_SOURCE}-volume" "$curNode" "$VOLUME_MAX%"
168168
elif [ "$VOL_LEVEL" -lt "$maxLimit" ]; then
169-
pactl set-s${SINK_OR_SOURCE}-volume "$curNode" "+$VOLUME_STEP%"
169+
pactl "set-s${SINK_OR_SOURCE}-volume" "$curNode" "+$VOLUME_STEP%"
170170
fi
171171

172172
if [ $OSD = "yes" ]; then showOSD "$curNode"; fi
@@ -181,7 +181,7 @@ function volDown() {
181181
echo "PulseAudio not running"
182182
return 1
183183
fi
184-
pactl set-s${SINK_OR_SOURCE}-volume "$curNode" "-$VOLUME_STEP%"
184+
pactl "set-s${SINK_OR_SOURCE}-volume" "$curNode" "-$VOLUME_STEP%"
185185

186186
if [ $OSD = "yes" ]; then showOSD "$curNode"; fi
187187
if [ $AUTOSYNC = "yes" ]; then volSync; fi
@@ -227,14 +227,14 @@ function volMute() {
227227
if [ "$1" = "toggle" ]; then
228228
getIsMuted "$curNode"
229229
if [ "$IS_MUTED" = "yes" ]; then
230-
pactl set-s${SINK_OR_SOURCE}-mute "$curNode" "no"
230+
pactl "set-s${SINK_OR_SOURCE}-mute" "$curNode" "no"
231231
else
232-
pactl set-s${SINK_OR_SOURCE}-mute "$curNode" "yes"
232+
pactl "set-s${SINK_OR_SOURCE}-mute" "$curNode" "yes"
233233
fi
234234
elif [ "$1" = "mute" ]; then
235-
pactl set-s${SINK_OR_SOURCE}-mute "$curNode" "yes"
235+
pactl "set-s${SINK_OR_SOURCE}-mute" "$curNode" "yes"
236236
elif [ "$1" = "unmute" ]; then
237-
pactl set-s${SINK_OR_SOURCE}-mute "$curNode" "no"
237+
pactl "set-s${SINK_OR_SOURCE}-mute" "$curNode" "no"
238238
fi
239239

240240
if [ $OSD = "yes" ]; then showOSD "$curNode"; fi
@@ -268,7 +268,7 @@ function nextNode() {
268268

269269
nodes[$i]="$index"
270270
i=$((i + 1))
271-
done < <(pactl list short s${SINK_OR_SOURCE}s | sort -n)
271+
done < <(pactl list short "s${SINK_OR_SOURCE}s" | sort -n)
272272

273273
# If the resulting list is empty, nothing is done
274274
if [ ${#nodes[@]} -eq 0 ]; then return; fi
@@ -288,7 +288,7 @@ function nextNode() {
288288
fi
289289

290290
# The new node is set
291-
pactl set-default-s${SINK_OR_SOURCE} "$newNode"
291+
pactl "set-default-s${SINK_OR_SOURCE}" "$newNode"
292292

293293
# Move all audio threads to new node
294294
local inputs
@@ -458,7 +458,7 @@ Options:
458458
extension.
459459
Default: none
460460
--node-nicknames-from <prop>
461-
pactl property to use for node names, unless overriden by
461+
pactl property to use for node names, unless overridden by
462462
--node-nickname. Its possible values are listed under the 'Properties'
463463
key in the output of \`pactl list sinks\` and \`pactl list sources\`.
464464
Default: none

0 commit comments

Comments
 (0)