From 4b5abb8a21658623be26e1ad03712e65cae5a415 Mon Sep 17 00:00:00 2001 From: Hsieh Chin Fan Date: Tue, 28 Feb 2023 23:11:08 +0800 Subject: Add ncmpcpp layout ref: https://radumirea.com/blog/ncmpcpp-with-album-art --- mpd/ncmpcpp/config | 4 +++- mpd/ncmpcpp/cover.sh | 18 ++++++++++++++++++ mpd/ncmpcpp/cover_obs.sh | 21 +++++++++++++++++++++ mpd/ncmpcpp/default_cover.png | Bin 0 -> 42425 bytes mpd/ncmpcpp/tsession | 32 ++++++++++++++++++++++++++++++++ 5 files changed, 74 insertions(+), 1 deletion(-) create mode 100755 mpd/ncmpcpp/cover.sh create mode 100755 mpd/ncmpcpp/cover_obs.sh create mode 100644 mpd/ncmpcpp/default_cover.png create mode 100644 mpd/ncmpcpp/tsession (limited to 'mpd/ncmpcpp') diff --git a/mpd/ncmpcpp/config b/mpd/ncmpcpp/config index 87deeb0..6814e2a 100644 --- a/mpd/ncmpcpp/config +++ b/mpd/ncmpcpp/config @@ -10,7 +10,8 @@ mpd_port = "6600" mpd_crossfade_time = "2" ### Script ### -execute_on_song_change="~/.config/ncmpcpp/scripts/album-art" +#execute_on_song_change="~/.config/ncmpcpp/scripts/album-art" +execute_on_song_change = "~/.ncmpcpp/cover_obs.sh" ### Behaviour ### message_delay_time = 1 @@ -91,3 +92,4 @@ lines_scrolled = "2" system_encoding = "utf-8" regular_expressions = "extended" + diff --git a/mpd/ncmpcpp/cover.sh b/mpd/ncmpcpp/cover.sh new file mode 100755 index 0000000..8fe8d4d --- /dev/null +++ b/mpd/ncmpcpp/cover.sh @@ -0,0 +1,18 @@ +#!/bin/bash + +source "`ueberzug library`" +COVER="/tmp/album_cover.png" + +function add_cover { + ImageLayer::add [identifier]="img" [x]="2" [y]="1" [path]="$COVER" +} + +ImageLayer 0< <( +if [ ! -f "$COVER" ]; then + cp "$HOME/.ncmpcpp/default_cover.png" "$COVER" +fi +#rerender image when changed +while inotifywait -q -q -e close_write "$COVER"; do + add_cover +done +) diff --git a/mpd/ncmpcpp/cover_obs.sh b/mpd/ncmpcpp/cover_obs.sh new file mode 100755 index 0000000..032bd08 --- /dev/null +++ b/mpd/ncmpcpp/cover_obs.sh @@ -0,0 +1,21 @@ +#!/bin/bash + +COVER="/tmp/album_cover.png" +COVER_SIZE="400" + +#path to current song +file="$MUSIC_DIR/$(mpc --format %file% current)" +album="${file%/*}" +#search for cover image +#use embedded image if present, otherwise take it from the current folder +err=$(ffmpeg -loglevel 16 -y -i "$file" -an -vcodec copy $EMB_COVER 2>&1) +if [ "$err" != "" ]; then + art=$(find "$album" -maxdepth 1 | grep -m 1 ".*\.\(jpg\|png\|gif\|bmp\)") +else + art=$EMB_COVER +fi +if [ "$art" = "" ]; then + art="$HOME/.ncmpcpp/default_cover.png" +fi +#copy and resize image to destination +ffmpeg -loglevel 0 -y -i "$art" -vf "scale=$COVER_SIZE:-1" "$COVER" \ No newline at end of file diff --git a/mpd/ncmpcpp/default_cover.png b/mpd/ncmpcpp/default_cover.png new file mode 100644 index 0000000..c02d40b Binary files /dev/null and b/mpd/ncmpcpp/default_cover.png differ diff --git a/mpd/ncmpcpp/tsession b/mpd/ncmpcpp/tsession new file mode 100644 index 0000000..e34d4b8 --- /dev/null +++ b/mpd/ncmpcpp/tsession @@ -0,0 +1,32 @@ +neww +set -g status off + +#image pane; run cover script, disable text output and remove prompt +send-keys "stty -echo" C-m +send-keys "tput civis -- invisible" C-m +send-keys "export PS1=''" C-m +send-keys "clear" C-m +send-keys "~/.ncmpcpp/cover.sh " C-m + +#catalog pane; run instance of ncmpcpp +split-window -v +select-pane -t 1 +send-keys "ncmpcpp --config='~/.ncmpcpp/catalog.conf'" C-m +send-keys 1 + +#visualizer pane; run instance of ncmpcpp in visualizer mode +select-pane -t 0 +split-window -h +send-keys "ncmpcpp --config='~/.ncmpcpp/visualizer.conf'" C-m +send-keys 8 +send-keys u + +#resize image and visualizer pane to fit image +resize-pane -t 0 -x 49 -y 23 +resize-pane -t 1 -y 23 + +#hook for keeping the image pane size constant +set-hook client-resized 'resize-pane -t 0 -x 49 -y 23' + +#focus on catalog pane +select-pane -t 2 \ No newline at end of file -- cgit v1.2.3-70-g09d2