diff options
| author | la-ninpre <leobrekalini@gmail.com> | 2022-06-21 14:12:17 +0300 |
|---|---|---|
| committer | la-ninpre <leobrekalini@gmail.com> | 2022-06-21 14:12:17 +0300 |
| commit | 0747dfdb3aca87d666b2a7d8761a6ffdf48cc90c (patch) | |
| tree | 0568937a95f5c2634fbcc791d9f3051e1eee53e1 | |
| parent | ad09b2c70920cef796cbe6e7c49d5f5a5f5ccbad (diff) | |
| download | dotfiles-0747dfdb3aca87d666b2a7d8761a6ffdf48cc90c.tar.gz dotfiles-0747dfdb3aca87d666b2a7d8761a6ffdf48cc90c.zip | |
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.
| -rw-r--r-- | moc/.config/moc/config | 4 | ||||
| -rwxr-xr-x | moc/.local/bin/mocpnotify | 28 | ||||
| -rwxr-xr-x | moc/.local/bin/mocpnotify-next | 31 | ||||
| -rwxr-xr-x | moc/.local/bin/mocpnotify-stop | 31 |
4 files changed, 88 insertions, 6 deletions
diff --git a/moc/.config/moc/config b/moc/.config/moc/config index 449bc02..aba05bb 100644 --- a/moc/.config/moc/config +++ b/moc/.config/moc/config @@ -668,7 +668,7 @@ Layout1 = directory(0,0,30%,100%):playlist(30%,0,FILL,100%) # # Example: OnSongChange = "/home/jack/.moc/myscript %a %r" # -OnSongChange = "/home/aaoth/.local/bin/mocpnotify next %a %t %d" +OnSongChange = "/home/aaoth/.local/bin/mocpnotify-next %a %t %d" # If RepeatSongChange is 'yes' then MOC will execute the command every time # a song starts playing regardless of whether or not it is just repeating. @@ -678,7 +678,7 @@ OnSongChange = "/home/aaoth/.local/bin/mocpnotify next %a %t %d" # Run the OnStop command (full path, no arguments) when MOC changes state # to stopped (i.e., when user stopped playing or changes a song). -OnStop = "/home/aaoth/.local/bin/mocpnotify stop" +OnStop = "/home/aaoth/.local/bin/mocpnotify-stop" # This option determines which song to play after finishing all the songs # in the queue. Setting this to 'yes' causes MOC to play the song which diff --git a/moc/.local/bin/mocpnotify b/moc/.local/bin/mocpnotify index f3aa72c..4626e22 100755 --- a/moc/.local/bin/mocpnotify +++ b/moc/.local/bin/mocpnotify @@ -1,11 +1,31 @@ -#!/bin/sh +#!/bin/sh -ex -case $1 in +_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" "$2 - $3 [$4]" + 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 - 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 diff --git a/moc/.local/bin/mocpnotify-stop b/moc/.local/bin/mocpnotify-stop new file mode 100755 index 0000000..4626e22 --- /dev/null +++ b/moc/.local/bin/mocpnotify-stop @@ -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 |
