From 0747dfdb3aca87d666b2a7d8761a6ffdf48cc90c Mon Sep 17 00:00:00 2001 From: la-ninpre Date: Tue, 21 Jun 2022 14:12:17 +0300 Subject: moc: fix onstop script not working also add writing current playing song info to textfiles in /tmp so that they can be used in, say, obs. --- moc/.local/bin/mocpnotify-next | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100755 moc/.local/bin/mocpnotify-next (limited to 'moc/.local/bin/mocpnotify-next') diff --git a/moc/.local/bin/mocpnotify-next b/moc/.local/bin/mocpnotify-next new file mode 100755 index 0000000..4626e22 --- /dev/null +++ b/moc/.local/bin/mocpnotify-next @@ -0,0 +1,31 @@ +#!/bin/sh -ex + +_mocp_args="-M $HOME/.config/moc" +_mocp_tmp="/tmp/mocp" +[ -d "$_mocp_tmp" ] || mkdir -p "$_mocp_tmp" + +_mocp_write() { + mocp $_mocp_args -Q "%$1" > "$_mocp_tmp/$1.txt" +} + +_mocp_clear() { + echo "no song playing" > "$_mocp_tmp/song.txt" + echo "" > "$_mocp_tmp/artist.txt" + echo "" > "$_mocp_tmp/album.txt" +} + +case $(basename $0 | cut -d- -f2) in + "next") + notify-send -a mocp -t 3000 "now playing" "$1 - $2 [$3]" + _mocp_write artist + _mocp_write album + _mocp_write song + ;; + "stop") + notify-send -a mocp -t 3000 "mocp" "stopped playing" + _mocp_clear + ;; + *) + #passthrough + ;; +esac -- cgit v1.2.3