all repos — dotfiles @ 0747dfdb3aca87d666b2a7d8761a6ffdf48cc90c

personal dotfiles

moc/.local/bin/mocpnotify-next (view raw)

 1#!/bin/sh -ex
 2
 3_mocp_args="-M $HOME/.config/moc"
 4_mocp_tmp="/tmp/mocp"
 5[ -d "$_mocp_tmp" ] || mkdir -p "$_mocp_tmp"
 6
 7_mocp_write() {
 8    mocp $_mocp_args -Q "%$1" > "$_mocp_tmp/$1.txt"
 9}
10
11_mocp_clear() {
12    echo "no song playing" > "$_mocp_tmp/song.txt"
13    echo "" > "$_mocp_tmp/artist.txt"
14    echo "" > "$_mocp_tmp/album.txt"
15}
16
17case $(basename $0 | cut -d- -f2) in
18    "next")
19        notify-send -a mocp -t 3000 "now playing" "$1 - $2 [$3]"
20        _mocp_write artist
21        _mocp_write album
22        _mocp_write song
23        ;;
24    "stop")
25        notify-send -a mocp -t 3000 "mocp" "stopped playing"
26        _mocp_clear
27        ;;
28    *)
29        #passthrough
30        ;;
31esac