aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorHsieh Chin Fan <pham@topo.tw>2023-02-28 23:11:08 +0800
committerHsieh Chin Fan <pham@topo.tw>2023-02-28 23:32:17 +0800
commit4b5abb8a21658623be26e1ad03712e65cae5a415 (patch)
treedcf7511a6013c62d103d5bf92e2e2b83be180fec
parentfadb9706c50894058d71738d4dfc508c6922ee9a (diff)
Add ncmpcpp layout
ref: https://radumirea.com/blog/ncmpcpp-with-album-art
-rw-r--r--mpd/ncmpcpp/config4
-rwxr-xr-xmpd/ncmpcpp/cover.sh18
-rwxr-xr-xmpd/ncmpcpp/cover_obs.sh21
-rw-r--r--mpd/ncmpcpp/default_cover.pngbin0 -> 42425 bytes
-rw-r--r--mpd/ncmpcpp/tsession32
5 files changed, 74 insertions, 1 deletions
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"
10mpd_crossfade_time = "2" 10mpd_crossfade_time = "2"
11 11
12### Script ### 12### Script ###
13execute_on_song_change="~/.config/ncmpcpp/scripts/album-art" 13#execute_on_song_change="~/.config/ncmpcpp/scripts/album-art"
14execute_on_song_change = "~/.ncmpcpp/cover_obs.sh"
14 15
15### Behaviour ### 16### Behaviour ###
16message_delay_time = 1 17message_delay_time = 1
@@ -91,3 +92,4 @@ lines_scrolled = "2"
91 92
92system_encoding = "utf-8" 93system_encoding = "utf-8"
93regular_expressions = "extended" 94regular_expressions = "extended"
95
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 @@
1#!/bin/bash
2
3source "`ueberzug library`"
4COVER="/tmp/album_cover.png"
5
6function add_cover {
7 ImageLayer::add [identifier]="img" [x]="2" [y]="1" [path]="$COVER"
8}
9
10ImageLayer 0< <(
11if [ ! -f "$COVER" ]; then
12 cp "$HOME/.ncmpcpp/default_cover.png" "$COVER"
13fi
14#rerender image when changed
15while inotifywait -q -q -e close_write "$COVER"; do
16 add_cover
17done
18)
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 @@
1#!/bin/bash
2
3COVER="/tmp/album_cover.png"
4COVER_SIZE="400"
5
6#path to current song
7file="$MUSIC_DIR/$(mpc --format %file% current)"
8album="${file%/*}"
9#search for cover image
10#use embedded image if present, otherwise take it from the current folder
11err=$(ffmpeg -loglevel 16 -y -i "$file" -an -vcodec copy $EMB_COVER 2>&1)
12if [ "$err" != "" ]; then
13 art=$(find "$album" -maxdepth 1 | grep -m 1 ".*\.\(jpg\|png\|gif\|bmp\)")
14else
15 art=$EMB_COVER
16fi
17if [ "$art" = "" ]; then
18 art="$HOME/.ncmpcpp/default_cover.png"
19fi
20#copy and resize image to destination
21ffmpeg -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
--- /dev/null
+++ b/mpd/ncmpcpp/default_cover.png
Binary files 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 @@
1neww
2set -g status off
3
4#image pane; run cover script, disable text output and remove prompt
5send-keys "stty -echo" C-m
6send-keys "tput civis -- invisible" C-m
7send-keys "export PS1=''" C-m
8send-keys "clear" C-m
9send-keys "~/.ncmpcpp/cover.sh " C-m
10
11#catalog pane; run instance of ncmpcpp
12split-window -v
13select-pane -t 1
14send-keys "ncmpcpp --config='~/.ncmpcpp/catalog.conf'" C-m
15send-keys 1
16
17#visualizer pane; run instance of ncmpcpp in visualizer mode
18select-pane -t 0
19split-window -h
20send-keys "ncmpcpp --config='~/.ncmpcpp/visualizer.conf'" C-m
21send-keys 8
22send-keys u
23
24#resize image and visualizer pane to fit image
25resize-pane -t 0 -x 49 -y 23
26resize-pane -t 1 -y 23
27
28#hook for keeping the image pane size constant
29set-hook client-resized 'resize-pane -t 0 -x 49 -y 23'
30
31#focus on catalog pane
32select-pane -t 2 \ No newline at end of file