-
Notifications
You must be signed in to change notification settings - Fork 0
/
pa
executable file
·65 lines (55 loc) · 969 Bytes
/
pa
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#!/bin/bash
# a hack-o-script to make my mic work with(out) broken PulseAudio >=1.0
exec 1>/dev/null
exec 2>&1
pa=pulseaudio
pkg=$pa{,-alsa}
app_res() {
do=TERM
[[ -n $1 ]] &&
if [[ -n $(pidof $1) ]]; then
killall -$do $1
if [[ -n $(pidof $1) ]]; then
do=KILL;
app_res;
fi
$1 &
else
$1 &
fi
}
case $1 in
r)
if [[ $(pacman -Qq $pa) == "$pa" ]]; then
$pa -k;
eval sudo pacman -Rdd --noconfirm $pkg;
if [[ -n $(pidof $pa) ]]; then
killall $pa;
fi
sudo rc.d restart alsa;
app_res $2;
else
echo "$pa ain't here" 1>$(tty);
exit 1;
fi
;;
i)
if [[ $(pacman -Qq $pa) != "$pa" ]]; then
eval sudo pacman -S --asdeps --noconfirm $pkg;
$pa -D;
sudo rc.d restart alsa;
app_res $2;
else
echo "$pa is already there" 1>$(tty);
exit 1;
fi
;;
*)
echo "Usage:
i - install $pa
r - remove $pa
You can also add a second arg with a program name so it gets restarted after r/i action.
Example: pa r skype" 1>$(tty)
;;
esac
exit 0