improve beetag usability
authorIan Kelling <ian@iankelling.org>
Sun, 26 Feb 2023 06:50:08 +0000 (01:50 -0500)
committerIan Kelling <ian@iankelling.org>
Sun, 26 Feb 2023 06:50:08 +0000 (01:50 -0500)
beet-data
brc2
subdir_files/.local/share/konsole/profileian.profile

index b41b05bf4c5a4856cf2f04f7500c76f40f9866b3..a9903080679dd17a6e4aeeb945bc044d50ee6c94 100644 (file)
--- a/beet-data
+++ b/beet-data
@@ -45,7 +45,8 @@ common_genres=(
   # like power glove
   darkwave
   hardcore
-  instrumental
+  # nonvocal / instrumental
+  nv
   latin
   metal
   # mq = mac quale. similar to the mr robot soundtracks.
diff --git a/brc2 b/brc2
index a8a2de76a3a7ee83dd071229b23a7a3292ebef8f..12586845d49bad0468673dd5d041ae5463830367 100644 (file)
--- a/brc2
+++ b/brc2
@@ -583,11 +583,12 @@ EOF
 # ret next
 beetag() {
   local last_genre_i fstring tag id char new_item char_i genre tag remove doplay i j random
-  local do_rare_genres read_wait help line lsout tmp ls_line
+  local do_rare_genres read_wait help line lsout tmp ls_line skip_lookback
   local escape_char escaped_input expected_input skip_input_regex
   local -a pl_tags buttons button_map ids tags rare_genres tmp_tags initial_ls ls_lines
   local -A button_i
-  local -i i j volume scrolled id_count line_int skip_start pre_j_count head_count
+  local -i i j volume scrolled id_count line_int skip_start pre_j_count head_count skip_lookback
+  local -i overflow_lines overflow
 
 
   escape_char=$(printf "\u1b")
@@ -641,15 +642,15 @@ beetag() {
   # for reusing later, so we can pickup where we left off in a playlist.
 
   # shellcheck disable=SC2016 # obvious reason
-  mapfile -t initial_ls < <(beet ls -f '$id %ifdef{rating,$rating }'"$fstring"'$genre | $artist - $album - $title   $length' "$@" | { if $random; then sort -R; else cat; fi; } )
+  mapfile -t initial_ls < <(beet ls -f '%ifdef{rating,$rating }'"$fstring"'$genre | $artist - $album - $title   $length  $id' "$@" | { if $random; then sort -R; else cat; fi; } )
   j=0
   # i only care to see the head of the list.
-  head_count=$(( LINES - 14 ))
+  head_count=$(( LINES - 20 ))
   for line in "${initial_ls[@]}"; do
-    id="${line%% *}"
+    id="${line##* }"
     ids+=("$id")
-    ls_line="${line#* }"
-    ls_line="$ls_line   $id"
+    right_pad="${line%% |*}"
+    ls_line="$(printf %-11s "$right_pad")${line#$right_pad}"
     ls_lines+=("$ls_line")
     if (( j < head_count )); then
       echo "$ls_line"
@@ -779,29 +780,12 @@ beetag() {
           expected_input=true
           read -rsn2 escaped_input
           skip_input_regex="^[0-9]+$"
-          skip_back=false
           case $escaped_input in
             '[D')
-              # skip backward
-              if (( j == 0 )); then
-                echo "no earlier songs"
-                continue
-              fi
-              skip_back=true
-              {
-                line_int=0
-                for (( i=j-1; i >= 0; i-- )); do
-                  echo "$line_int | ${ls_lines[i]}"
-                  line_int+=1
-                done
-              } | less -F
-              scrolled+=$j
-              ;;
-            '[C')
-              # skip forward, but show the last few songs anyways.
+              skip_lookback=5
               skip_start=0
-              if (( j - 3 > skip_start )); then
-                skip_start=$(( j - 3 ))
+              if (( j - skip_lookback > skip_start )); then
+                skip_start=$(( j - skip_lookback ))
               fi
               {
                 line_int=0
@@ -816,25 +800,49 @@ beetag() {
               } | less -F
               scrolled+=$(( id_count - skip_start - 1 ))
               ;;
+            '[C')
+              # skip forward, but show the last few songs anyways.
+              skip_start=0
+              skip_lookback=3
+              if (( j - skip_lookback > skip_start )); then
+                skip_start=$(( j - skip_lookback ))
+              fi
+              line_int=0
+              overflow_lines=$LINES
+              for (( i=skip_start; i < overflow_lines - 1; i++ )); do
+                ls_line="${ls_lines[i]}"
+                overflow=$(( ${#ls_line} / ( COLUMNS - 1 ) ))
+                overflow_lines=$(( overflow_lines - overflow ))
+                if (( i == j )); then
+                  echo "  * $ls_line"
+                  continue
+                fi
+                echo "$line_int | $ls_line"
+                line_int+=1
+              done
+              scrolled+=$(( id_count - skip_start - 1 ))
+              ;;
             *)
               expected_input=false
               ;;
           esac
           if $expected_input; then
             read -r skip_input
+            case skip_input in
+              q)
+                kill %%; wait %% 2>/dev/null ||:
+                return
+                ;;
+            esac
             if [[ $skip_input =~ $skip_input_regex ]]; then
-              if $skip_back; then
-                j=$(( j - skip_input - 2 ))
-              else
-                pre_j_count=$(( j - skip_start ))
-                j=$(( j + skip_input - pre_j_count ))
-                if (( skip_input < pre_j_count )); then
-                  j=$(( j - 1 ))
-                fi
+              pre_j_count=$(( j - skip_start ))
+              j=$(( j + skip_input - pre_j_count ))
+              if (( skip_input < pre_j_count )); then
+                j=$(( j - 1 ))
               fi
-              kill %%; wait %% 2>/dev/null ||:
-              break
             fi
+            kill %%; wait %% 2>/dev/null ||:
+            break
           fi
           ;;
       esac
index d9d34c6994c3c443d5a1995debf5c0d3c0df9cec..747c3b6b2b39ac506993ebfb98c0b05b69f8a0d3 100644 (file)
@@ -1,6 +1,6 @@
 [Appearance]
-ColorScheme=Linux
-Font=DejaVu Sans Mono,12,-1,5,50,0,0,0,0,0,Book
+ColorScheme=BlackOnWhite
+Font=DejaVu Sans Mono,12,-1,5,50,0,0,0,0,0
 
 [General]
 LocalTabTitleFormat=%w