From 71ca28742ac4f93ab2401eaee8e78471c023cd4b Mon Sep 17 00:00:00 2001 From: Hsieh Chin Fan Date: Thu, 7 Nov 2024 11:32:27 +0800 Subject: Update --- mpd/ncmpcpp/.gitignore | 1 - mpd/ncmpcpp/bindings | 46 -------- mpd/ncmpcpp/config | 95 --------------- mpd/ncmpcpp/config.bak | 66 ----------- mpd/ncmpcpp/cover.sh | 18 --- mpd/ncmpcpp/cover_obs.sh | 21 ---- mpd/ncmpcpp/default_cover.png | Bin 42425 -> 0 bytes mpd/ncmpcpp/scripts/album-art | 248 ---------------------------------------- mpd/ncmpcpp/scripts/music.png | Bin 113344 -> 0 bytes mpd/ncmpcpp/scripts/ncmpcpp-art | 22 ---- mpd/ncmpcpp/tsession | 32 ------ 11 files changed, 549 deletions(-) delete mode 100644 mpd/ncmpcpp/.gitignore delete mode 100644 mpd/ncmpcpp/bindings delete mode 100644 mpd/ncmpcpp/config delete mode 100644 mpd/ncmpcpp/config.bak delete mode 100755 mpd/ncmpcpp/cover.sh delete mode 100755 mpd/ncmpcpp/cover_obs.sh delete mode 100644 mpd/ncmpcpp/default_cover.png delete mode 100755 mpd/ncmpcpp/scripts/album-art delete mode 100644 mpd/ncmpcpp/scripts/music.png delete mode 100755 mpd/ncmpcpp/scripts/ncmpcpp-art delete mode 100644 mpd/ncmpcpp/tsession (limited to 'mpd/ncmpcpp') diff --git a/mpd/ncmpcpp/.gitignore b/mpd/ncmpcpp/.gitignore deleted file mode 100644 index 397b4a7..0000000 --- a/mpd/ncmpcpp/.gitignore +++ /dev/null @@ -1 +0,0 @@ -*.log diff --git a/mpd/ncmpcpp/bindings b/mpd/ncmpcpp/bindings deleted file mode 100644 index d035f7f..0000000 --- a/mpd/ncmpcpp/bindings +++ /dev/null @@ -1,46 +0,0 @@ -# the t key isn't used and it's easier to press than /, so lets use it -def_key "t" - find -def_key "t" - find_item_forward - -def_key "+" - show_clock -def_key "=" - volume_up - -def_key "j" - scroll_down -def_key "k" - scroll_up - -def_key "ctrl-u" - page_up -def_key "ctrl-d" - page_down - -def_key "h" - previous_column -def_key "l" - next_column - -def_key "." - show_lyrics - -def_key "n" - next_found_item -def_key "N" - previous_found_item - -def_key "J" - move_sort_order_down -def_key "K" - move_sort_order_up - -def_key "g" - move_home -def_key "G" - move_end - -def_key "0" - replay_song diff --git a/mpd/ncmpcpp/config b/mpd/ncmpcpp/config deleted file mode 100644 index e818015..0000000 --- a/mpd/ncmpcpp/config +++ /dev/null @@ -1,95 +0,0 @@ -## Copyright (C) 2020-2021 Aditya Shakya -## Everyone is permitted to copy and distribute copies of this file under GNU-GPL3 - -### Directories ### -ncmpcpp_directory = ~/.config/ncmpcpp/ -lyrics_directory = ~/.config/ncmpcpp/lyrics -mpd_music_dir = ~/Music -mpd_host = "localhost" -mpd_port = "6600" -mpd_crossfade_time = "2" - -### Script ### -#execute_on_song_change="~/.config/ncmpcpp/scripts/album-art" -#execute_on_song_change = "~/.ncmpcpp/cover_obs.sh" - -### Behaviour ### -message_delay_time = 1 -autocenter_mode = "yes" -centered_cursor = "yes" -ignore_leading_the = "yes" -playlist_disable_highlight_delay = 2 -allow_for_physical_item_deletion = "no" - -### Visualizer ### -#visualizer_data_source = /tmp/mpd.fifo -#visualizer_output_name = "mpd_visualizer" -#visualizer_in_stereo = "yes" -#visualizer_look = " " -visualizer_type = "spectrum" - -### Appearance ### -playlist_display_mode = "columns" -colors_enabled = "yes" -#user_interface = classic -user_interface = alternative -volume_color = "white" - -### Window ### -song_window_title_format = "Music Player" -#song_window_title_format = "{%a - }{%t}|{%f}" -statusbar_visibility = "no" -header_visibility = "no" -titles_visibility = "yes" - -### Progress bar ### -progressbar_look = "▂▂▂" -progressbar_color = "black" -progressbar_elapsed_color = "yellow" - -### Alternative UI ### -alternative_ui_separator_color = "blue" -alternative_header_first_line_format = $b$5$/b $b$8{%t}|{%f}$/b $/b -alternative_header_second_line_format = {$b{$2 %a$9}{ - $7 %b$9}{ ($2%y$9)}}|{%D} - -### Song list ### -song_status_format = "$7%t" -song_list_format = " $4%t$9 $7$R%a$9 $2%l$9 " -song_library_format = {{%a - %t} (%b)}|{%f} -song_columns_list_format = "(35)[blue]{t} (30)[green]{a} (6)[cyan]{lr}" - -### Colors ### -main_window_color = "blue" -state_line_color = "black" -current_item_prefix = "$(blue)$r" -current_item_suffix = "$/r$(end)" -current_item_inactive_column_prefix = red -current_item_inactive_column_suffix = red -now_playing_prefix = "$4 " -selected_item_prefix = "* " - -color1 = "white" -color2 = "red" - -### Layout ### -startup_screen = visualizer -startup_slave_screen = playlist -startup_slave_screen_focus = yes -locked_screen_width_part = 25 - -### Misc ### -default_place_to_search_in = "database" - -display_bitrate = "no" -enable_window_title = "yes" -follow_now_playing_lyrics = "yes" -empty_tag_marker = "" - -cyclic_scrolling = "yes" -header_text_scrolling = "yes" -jump_to_now_playing_song_at_start = "yes" -lines_scrolled = "2" - -system_encoding = "utf-8" -regular_expressions = "extended" - diff --git a/mpd/ncmpcpp/config.bak b/mpd/ncmpcpp/config.bak deleted file mode 100644 index eb3fff6..0000000 --- a/mpd/ncmpcpp/config.bak +++ /dev/null @@ -1,66 +0,0 @@ -## Copyright (C) 2020-2021 Aditya Shakya -## Everyone is permitted to copy and distribute copies of this file under GNU-GPL3 - -### Directories ### -ncmpcpp_directory = ~/.ncmpcpp -lyrics_directory = ~/.ncmpcpp/lyrics -mpd_music_dir = ~/Music -mpd_host = "localhost" -mpd_port = "6600" -mpd_crossfade_time = "2" - -### Script ### -execute_on_song_change = "kunst --size 60x60 --silent" - -### Behaviour ### -message_delay_time = 1 -autocenter_mode = "yes" -centered_cursor = "yes" -ignore_leading_the = "yes" -playlist_disable_highlight_delay = 2 -allow_for_physical_item_deletion = "no" - -### Visualizer ### -visualizer_data_source = /tmp/mpd.fifo -visualizer_output_name = "mpd_visualizer" -visualizer_in_stereo = "yes" -visualizer_look = ●● -visualizer_type = "ellipse" - -### Appearance ### -playlist_display_mode = "columns" -colors_enabled = "yes" -#user_interface = classic -user_interface = alternative -volume_color = "white" - -### Window ### -song_window_title_format = "{%a - }{%t}|{%f}" -statusbar_visibility = "no" -header_visibility = "no" -titles_visibility = "no" - -### Progress bar ### -progressbar_look = "▂▂▂" -progressbar_color = "black" -progressbar_elapsed_color = "yellow" - -### Alternative UI ### -alternative_ui_separator_color = "black" -alternative_header_first_line_format = $b$5$/b $b$8{%t}|{%f}$/b $/b -alternative_header_second_line_format = {$b{$2 %a$9}{ - $7 %b$9}{ ($2%y$9)}}|{%D} - -### Song list ### -song_status_format = "$7%t" -song_list_format = " %t $R%a %l " -song_library_format = {{%a - %t} (%b)}|{%f} -song_columns_list_format = "(53)[white]{tr} (45)[blue]{a}" - -### Colors ### -main_window_color = "blue" -current_item_prefix = "$(blue)$r" -current_item_suffix = "$/r$(end)" -current_item_inactive_column_prefix = red -current_item_inactive_column_suffix = red -color1 = "white" -color2 = "red" diff --git a/mpd/ncmpcpp/cover.sh b/mpd/ncmpcpp/cover.sh deleted file mode 100755 index 8fe8d4d..0000000 --- a/mpd/ncmpcpp/cover.sh +++ /dev/null @@ -1,18 +0,0 @@ -#!/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 deleted file mode 100755 index 032bd08..0000000 --- a/mpd/ncmpcpp/cover_obs.sh +++ /dev/null @@ -1,21 +0,0 @@ -#!/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 deleted file mode 100644 index c02d40b..0000000 Binary files a/mpd/ncmpcpp/default_cover.png and /dev/null differ diff --git a/mpd/ncmpcpp/scripts/album-art b/mpd/ncmpcpp/scripts/album-art deleted file mode 100755 index d852f34..0000000 --- a/mpd/ncmpcpp/scripts/album-art +++ /dev/null @@ -1,248 +0,0 @@ -#!/usr/bin/env bash - -## Copyright (C) 2020-2021 Aditya Shakya -## Everyone is permitted to copy and distribute copies of this file under GNU-GPL3 - -## Cover art script for ncmpcpp - -# SETTINGS -music_library="$HOME/Music" -padding_top=3 -padding_bottom=0 -padding_right=0 -max_width=40 -reserved_playlist_cols=31 -reserved_cols_in_percent="false" -force_square="true" -square_alignment="top" -left_aligned="true" -padding_left=0 - -# Only set this if the geometries are wrong or ncmpcpp shouts at you to do it. -# Visually select/highlight a character on your terminal, zoom in an image -# editor and count how many pixels a character's width and height are. -font_height= -font_width= - -main() { - kill_previous_instances >/dev/null 2>&1 - find_cover_image >/dev/null 2>&1 - display_cover_image 2>/dev/null - dunstify -u low --replace=69 -i "$cover_path" "$(mpc current)" - detect_window_resizes >/dev/null 2>&1 -} - -# ==== Main functions ========================================================= - -kill_previous_instances() { - script_name=$(basename "$0") - for pid in $(pidof -x "$script_name"); do - if [ "$pid" != $$ ]; then - kill -15 "$pid" - fi - done -} - -find_cover_image() { - - # First we check if the audio file has an embedded album art - ext="$(mpc --format %file% current | sed 's/^.*\.//')" - if [ "$ext" = "flac" ]; then - # since FFMPEG cannot export embedded FLAC art we use metaflac - metaflac --export-picture-to=/tmp/mpd_cover.jpg \ - "$(mpc --format "$music_library"/%file% current)" && - cover_path="/tmp/mpd_cover.jpg" && return - else - ffmpeg -y -i "$(mpc --format "$music_library"/%file% | head -n 1)" \ - /tmp/mpd_cover.jpg && - cover_path="/tmp/mpd_cover.jpg" && return - fi - - # If no embedded art was found we look inside the music file's directory - album="$(mpc --format %album% current)" - file="$(mpc --format %file% current)" - album_dir="${file%/*}" - album_dir="$music_library/$album_dir" - found_covers="$(find "$album_dir" -type d -exec find {} -maxdepth 1 -type f \ - -iregex ".*/.*\(${album}\|cover\|folder\|artwork\|front\).*[.]\\(jpe?g\|png\|gif\|bmp\)" \; )" - cover_path="$(echo "$found_covers" | head -n1)" - if [ -n "$cover_path" ]; then - return - fi - - # If we still failed to find a cover image, we use the fallback - if [ -z "$cover_path" ]; then - cover_path="$HOME/.ncmpcpp/scripts/music.png" - fi -} - -display_cover_image() { - compute_geometry - - send_to_ueberzug \ - action "add" \ - identifier "mpd_cover" \ - path "$cover_path" \ - x "$ueber_left" \ - y "$padding_top" \ - height "$ueber_height" \ - width "$ueber_width" \ - synchronously_draw "True" \ - scaler "forced_cover" \ - scaling_position_x "0.5" -} - -detect_window_resizes() { - { - trap 'display_cover_image' WINCH - while :; do sleep .1; done - } & -} - - -# ==== Helper functions ========================================================= - -compute_geometry() { - unset LINES COLUMNS # Required in order for tput to work in a script - term_lines=$(tput lines) - term_cols=$(tput cols) - if [ -z "$font_height" ] || [ -z "$font_height" ]; then - guess_font_size - fi - - ueber_height=$(( term_lines - padding_top - padding_bottom )) - # Because Ueberzug uses characters as a unit we must multiply - # the line count (height) by the font size ratio in order to - # obtain an equivalent width in column count - ueber_width=$(( ueber_height * font_height / font_width )) - ueber_left=$(( term_cols - ueber_width - padding_right )) - - if [ "$left_aligned" = "true" ]; then - compute_geometry_left_aligned - else - compute_geometry_right_aligned - fi - - apply_force_square_setting -} - -compute_geometry_left_aligned() { - ueber_left=$padding_left - max_width_chars=$(( term_cols * max_width / 100 )) - if [ "$max_width" != 0 ] && - [ $(( ueber_width + padding_right + padding_left )) -gt "$max_width_chars" ]; then - ueber_width=$(( max_width_chars - padding_left - padding_right )) - fi -} - -compute_geometry_right_aligned() { - if [ "$reserved_cols_in_percent" = "true" ]; then - ueber_left_percent=$(printf "%.0f\n" $(calc "$ueber_left" / "$term_cols" '*' 100)) - if [ "$ueber_left_percent" -lt "$reserved_playlist_cols" ]; then - ueber_left=$(( term_cols * reserved_playlist_cols / 100 )) - ueber_width=$(( term_cols - ueber_left - padding_right )) - fi - else - if [ "$ueber_left" -lt "$reserved_playlist_cols" ]; then - ueber_left=$reserved_playlist_cols - ueber_width=$(( term_cols - ueber_left - padding_right )) - fi - - fi - - if [ "$max_width" != 0 ] && [ "$ueber_width" -gt "$max_width" ]; then - ueber_width=$max_width - ueber_left=$(( term_cols - ueber_width - padding_right )) - fi -} - -apply_force_square_setting() { - if [ $force_square = "true" ]; then - ueber_height=$(( ueber_width * font_width / font_height )) - case "$square_alignment" in - center) - area=$(( term_lines - padding_top - padding_bottom )) - padding_top=$(( padding_top + area / 2 - ueber_height / 2 )) - ;; - bottom) - padding_top=$(( term_lines - padding_bottom - ueber_height )) - ;; - *) ;; - esac - fi -} - -guess_font_size() { - # A font width and height estimate is required to - # properly compute the cover width (in columns). - # We are reproducing the arithmetic used by Ueberzug - # to guess font size. - # https://github.com/seebye/ueberzug/blob/master/ueberzug/terminal.py#L24 - - guess_terminal_pixelsize - - approx_font_width=$(( term_width / term_cols )) - approx_font_height=$(( term_height / term_lines )) - - term_xpadding=$(( ( - approx_font_width * term_cols + term_width ) / 2 )) - term_ypadding=$(( ( - approx_font_height * term_lines + term_height ) / 2 )) - - font_width=$(( (term_width - 2 * term_xpadding) / term_cols )) - font_height=$(( (term_height - 2 * term_ypadding) / term_lines )) -} - -guess_terminal_pixelsize() { - # We are re-using the same Python snippet that - # Ueberzug utilizes to retrieve terminal window size. - # https://github.com/seebye/ueberzug/blob/master/ueberzug/terminal.py#L10 - - python < "$FIFO_UEBERZUG" - - IFS=${old_IFS} -} - -main diff --git a/mpd/ncmpcpp/scripts/music.png b/mpd/ncmpcpp/scripts/music.png deleted file mode 100644 index 3ded333..0000000 Binary files a/mpd/ncmpcpp/scripts/music.png and /dev/null differ diff --git a/mpd/ncmpcpp/scripts/ncmpcpp-art b/mpd/ncmpcpp/scripts/ncmpcpp-art deleted file mode 100755 index 38d34c1..0000000 --- a/mpd/ncmpcpp/scripts/ncmpcpp-art +++ /dev/null @@ -1,22 +0,0 @@ -#!/usr/bin/env bash - -## Copyright (C) 2020-2021 Aditya Shakya -## Everyone is permitted to copy and distribute copies of this file under GNU-GPL3 - -export FIFO_UEBERZUG="/tmp/mpd-ueberzug-${PPID}" - -cleanup() { - rm "$FIFO_UEBERZUG" 2>/dev/null - rm /tmp/mpd_cover.jpg 2>/dev/null - pkill -P $$ 2>/dev/null - pkill album-art -} - -pkill -P $$ 2>/dev/null -rm "$FIFO_UEBERZUG" 2>/dev/null -mkfifo "$FIFO_UEBERZUG" >/dev/null -trap cleanup EXIT 2>/dev/null -tail --follow "$FIFO_UEBERZUG" | ueberzug layer --silent --parser simple >/dev/null 2>&1 & - -ncmpcpp -c ~/.ncmpcpp/config-art -cleanup diff --git a/mpd/ncmpcpp/tsession b/mpd/ncmpcpp/tsession deleted file mode 100644 index e34d4b8..0000000 --- a/mpd/ncmpcpp/tsession +++ /dev/null @@ -1,32 +0,0 @@ -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