]> git.sev.monster Git - dotfiles.git/blame - bin/mpc-notify
clean .zprofile vars, update zsh opts, fix dpass
[dotfiles.git] / bin / mpc-notify
CommitLineData
d2e125bc 1#!/bin/sh
bd5d1156 2#TODO: help
3mpc=mpc
4dest=org.freedesktop.Notifications
5opath=/org/freedesktop/Notifications
6meth=$dest.Notify
7idfile=~/tmp/mpc-notify.id
8
9notify() {
10 replaces_id=0
11 if [ -e $idfile ]; then
12 replaces_id=`cat $idfile`
13 fi
14 echo $(expr "$(gdbus call --session \
15 --dest $dest --object-path $opath --method $meth \
16 mpc $replaces_id audio-volume-high "${1:-$out1}" "${2:-$out2}" '[]' \
17 '{"urgency": <byte 0>}' 3000)" : '(uint32 \([0-9]*\),)') > $idfile
18}
19
20getoutput() {
21 #TODO test if not playing for some commands
22 #if mpc -f '' status | awk 'NR==2' | grep -v '^\[playing\]'; then
23 case "$1" in
24 current)
25 out1=`$mpc -f %artist% current`
26 out2="`$mpc -f %title% current`\n`mpc -f %album% current`";;
27 status) out1=`$mpc current`
28 out2=`$mpc -f '%album% (%date%)' status`;;
29 *) return 1;;
30 esac
31 if [ -z "$out1$out2" ]; then
32 out1='Stopped'
33 fi
34}
35
36cmd=${1:-current}
37case "$cmd" in
38 -d|--daemon|idle|idleloop)
39 cmd=${2:-current}
40 $mpc idleloop player | while read -r x; do
41 getoutput $cmd
42 notify "$out1" "$out2"
43 done
44 return;;
45 *) getoutput $cmd || return 1;;
46esac
47notify "$out1" "$out2"
This page took 0.035325 seconds and 4 git commands to generate.