forked from ViktorNova/mixxx-now-playing
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmixxx-now-playing.sh
executable file
·46 lines (37 loc) · 1017 Bytes
/
mixxx-now-playing.sh
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
#!/usr/bin/env bash
TXTFILE=~/mixxx-now-playing.txt
touch $TXTFILE
# TODO: fail here if the file is not writeable
echo " " > $TXTFILE
OS=`uname`
echo "Detected OS: $OS"
while true; do
while pgrep -i mixxx > /dev/null; do
if [ $OS == "Linux" ]; then
xdotool search --name "\| Mixxx" getwindowname |
cut -d\| -f1 |
sed 's/,/ -/' |
awk '{ print tolower($0) }' |
ascii2uni -aU -q|
awk '{ print toupper($0) }' |
sed 's/$/ /' > $TXTFILE
elif [ $OS == "Darwin" ]; then
python -c "
import Quartz
print(Quartz.CGWindowListCopyWindowInfo(Quartz.kCGWindowListExcludeDesktopElements|Quartz.kCGWindowListOptionAll,Quartz.kCGNullWindowID))
" |
grep "| Mixxx" |
cut -d'"' -f 2 |
cut -d\| -f1 |
sed 's/,/ -/' |
awk '{ print tolower($0) }' |
ascii2uni -aU -q|
awk '{ print toupper($0) }' |
sed 's/$/ /' > $TXTFILE
fi
# TODO: don't write the file if the value is the same (better for disk I/O)
# TODO: unify write command for both OSs
sleep 5
done
sleep 60
done