corz.org uses cookies to remember that you've seen this notice explaining that corz.org uses cookies, okay!
corz.org text viewer..
[currently viewing: / public/ linux/ usr/ local/ bin/ signux.sh - raw]
username="USERNAME"
password="PASSWORD"
url="http://mydomain.com/path/to/amp.php"
xmms_file=/tmp/xmms-info
piping=`cat $xmms_file` >&2
if [ -s "$piping" ]; then
printf "\nno update performed\ncouldn't locate named pipe: $xmms_file\n\n" >&2
exit 1
fi
bitrate=`cat $xmms_file | grep 'Current bitrate' | sed -e 's/^.*: //'`
frequency=`cat $xmms_file | grep 'Samping Frequency' | sed -e 's/^.*: //'`
song_time=`cat $xmms_file | grep '^Time' | sed -e 's/^.*: //'`
frequency=`expr $frequency / 1000`
bitrate=`expr $bitrate / 1000`
play_status="${song_time}m | ${bitrate}kb/s | ${frequency}KHz"
pause_status='paused for thought'
stopped_status='stopped for peace'
uTu=`cat /proc/uptime | awk 'BEGIN { FS = "." } { print $(NF-2) }'`
playing=`cat $xmms_file | grep 'Status' | sed -e 's/^.*: //'`
title=`cat $xmms_file | grep '^Title' | sed -e 's/^.*: //'`
length=`cat $xmms_file | grep '^uSecTime' | sed -e 's/^.*: //'`
length=`expr $length / 1000`
pos=`cat $xmms_file | grep '^uSecPosition' | sed -e 's/^.*: //'`
pos=`expr $pos / 1000`
file_path=`cat $xmms_file | grep '^File' | sed -e 's/^: //'`
dir=`echo $file_path | awk 'BEGIN { FS = "/" } { print $(NF-1) }'`
puter_type=`cat /proc/cpuinfo | grep '^model name' | sed -e 's/^.*: //'`
puter_speed=`cat /proc/cpuinfo | grep 'cpu MHz' | sed -e 's/^.*: //'`
case "$playing" in
'Playing')
status=$play_status
;;
'Paused')
status=$pause_status
;;
'Stopped')
status=$stopped_status
;;
*)
status='no status given'
;;
esac
url_encode () {
echo "$@" | awk '
BEGIN {
split ("1 2 3 4 5 6 7 8 9 A B C D E F", hexit, " ")
hexit [0] = 0
for (i = 1 ; i <= 255 ; ++i) ord[ sprintf ("%c", i) "" ] = i + 0
} {
encoded = ""
for (i = 1 ; i <= length ($0) ; ++i) {
c = substr ($0, i, 1)
if ( c ~ /[a-zA-Z0-9.-]/ ) {
encoded = encoded c
} else {
lo = ord[c] % 16
hi = int (ord[c] / 16);
encoded = encoded "%" hexit [hi] hexit [lo]
}
}
}
END {
printf ("%s", encoded)
}
'
}
title=`url_encode $title`
status=`url_encode $status`
data="user=$username&pass=$password&playing=$playing&uptime=$uTu&length=$length&pos=$pos&title=$title&status=$status&dir=$dir"
curl -d "$data" $url
exit 0
Welcome to corz.org!
Since switching hosts (I hope you are alright, Ed! Wherever you are …) quite a few things seems to be wonky.
Juggling two energetic boys (of very different ages) on Coronavirus lockdown, I'm unlikely to have them all fixed any time soon. Mail me! to prioritise!