代码: 全选
#!/bin/bash
# mpd 地址;端口;密码
host=localhost; port=6600; password=
csm="`echo -e "password password\\ncurrentsong\\nclose" | nc $host $port`"
export IFS=$'\n'
if echo "$csm" | egrep '^file:'; then
for line in $csm; do
eval "${line//: /=\"}\"" 2>/dev/null
done
### 如果一切正常,以下变量将被赋值:
### file, Time, Artist, Title, Album, Track, Date, Pos, Id
notify-send -t 2000 "$Artist - $Album" "$Title"
fi
netcat (The GNU Netcat) 0.7.1
Copyright (C) 2002 - 2003 Giovanni Giacobbi
This program comes with NO WARRANTY, to the extent permitted by law.
You may redistribute copies of this program under the terms of
the GNU General Public License.
For more information about these matters, see the file named COPYING.
Original idea and design by Avian Research <hobbit@avian.org>,
Written by Giovanni Giacobbi <giovanni@giacobbi.net>.