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