ncmpcppで楽曲変更時に通知
ncmpcppは楽曲変更時に任意のコマンドを実行する機能がある
ウェブラジオ内での楽曲の変更は対応していない
code:conf
execute_on_song_change = "# 任意のコマンド"
実行時に楽曲の情報を取得し,通知するコマンドを自作すれば良い
PATHの通ったディレクトリに配置
自作したやつ
code:sh
#!/bin/sh -eu
# mpd管理下のディレクトリの抽出
music_dir=$(grep ^music_directory "${HOME}"/.config/mpd/mpd.conf | cut -d"\"" -f2)
# 再生中の曲の相対パスを抽出
current_song=$(mpc current -f "%file%")
# ディレクトリのみ抽出
song_path=$(dirname "${current_song}")
# カバーアートまでの絶対パス
img_dir="${music_dir}/${song_path}/Folder.jpg"
notify-send "$(mpc status)" -i "${img_dir}" &
上記のコマンドではnotify-sendを使っているがwebhookを使えばdiscordとかにも通知を送れる
tmuxで上手いことやれば端末内で通知を送ることも可能かもしれない
参考
https://wiki.archlinux.jp/index.php/Ncmpcpp
#ncmpcpp #shellscript #備忘録