udpate code to mark watched files as active in rofi

This commit is contained in:
ksyasuda 2022-01-06 13:42:54 -08:00
parent 952519de8b
commit a8e4e87197

31
ani-cli
View File

@ -343,28 +343,35 @@ generate_inputlist() {
if [[ "${directory// /}" == "" ]]; then if [[ "${directory// /}" == "" ]]; then
continue continue
fi fi
if [[ "$outstr" == "" ]]; then [ "$outstr" = "" ] && outstr="$directory" || outstr="$outstr|$directory"
outstr="$directory"
else
outstr="$outstr|$directory"
fi
done <<< "$(find "$1" -maxdepth 1 -type d | sed "s|$1/||" | tail -n +2 | sort -V)" done <<< "$(find "$1" -maxdepth 1 -type d | sed "s|$1/||" | tail -n +2 | sort -V)"
log "DIRS: $outstr" 1> /dev/stderr log "DIRS: $outstr" 1> /dev/stderr
while read -r filename; do while read -r filename; do
if [[ "${filename// /}" == "" ]]; then if [[ "${filename// /}" == "" ]]; then
continue continue
fi fi
if [[ "$outstr" == "" ]]; then [ "$outstr" = "" ] && outstr="$filename" || outstr="$outstr|$filename"
outstr="$filename"
else
outstr="$outstr|$filename"
fi
done <<< "$(find "$1" -maxdepth 1 -type f | sed "s|$1/||" | grep -E "$playable$" | sort -V)" done <<< "$(find "$1" -maxdepth 1 -type f | sed "s|$1/||" | grep -E "$playable$" | sort -V)"
log "DIRS + FILES: $outstr" 1> /dev/stderr log "DIRS + FILES: $outstr" 1> /dev/stderr
outstr="$outstr|Back|Quit" outstr="$outstr|Back|Quit"
printf "%s\n" "$outstr" printf "%s\n" "$outstr"
} }
generate_file_watchedlist() {
search_dir="$1"
watched=""
cnt=0
while read -r filename; do
if ! check_db "file" "$search_dir/$filename" "$filename"; then
log "$filename watched before... adding to list" 1> /dev/stderr
[ "$watched" = "" ] && watched="$cnt" || watched="$watched, $cnt"
fi
((++cnt))
done <<< "$(find "$search_dir" -maxdepth 1 -type f | sed "s|$search_dir/||" | grep -E "$playable$" | sort -V)"
log "WATCHED LIST: $watched" 1> /dev/stderr
printf "%s\n" "$watched"
}
# recursive function for finding path to video file given a starting directory # recursive function for finding path to video file given a starting directory
find_media() { find_media() {
inp="$1" inp="$1"
@ -380,8 +387,10 @@ find_media() {
span=$(generate_span "Current directory: $inp") span=$(generate_span "Current directory: $inp")
inputlist=$(generate_inputlist "$inp") inputlist=$(generate_inputlist "$inp")
watched_files=$(generate_file_watchedlist "$inp")
selection=$(rofi -dmenu -only-match -config "$ROFI_CFG" \ selection=$(rofi -dmenu -only-match -config "$ROFI_CFG" \
-l 13 -i -sep '|' -mesg "$span" -p "Enter selection" <<< "${inputlist[@]}") -l 13 -i -sep '|' -mesg "$span" -a "$watched_files" \
-p "Enter selection" <<< "${inputlist[@]}")
if [ -z "$selection" ] || [ "$selection" = "Quit" ]; then if [ -z "$selection" ] || [ "$selection" = "Quit" ]; then
return 1 return 1