local do_rare_genres read_wait help line lsout tmp ls_line skip_lookback
local escape_char escaped_input expected_input skip_input_regex right_pad erasable_line seek_sec
local pl_state_path pl_state_dir pl_state_file
- local new_random pl_seed_path seed_num seed_file
+ local new_random pl_seed_path seed_num seed_file fmt
local -a pl_tags buttons button_map ids tags tmp_tags initial_ls ls_lines paths
local -A button_i
local -i i j volume scrolled id_count line_int skip_start pre_j_count head_count skip_lookback
# PijokVipiotOzeph is just a random string for a delimiter
+ fmt='%ifdef{rating,$rating }'"$fstring"'$genre | $title - $artist - $album $length $id PijokVipiotOzeph $path'
# shellcheck disable=SC2016 # obvious reason
- mapfile -t initial_ls < <(beet ls -f '%ifdef{rating,$rating }'"$fstring"'$genre | $artist - $album - $title $length $id PijokVipiotOzeph $path' "$@" | { if $random; then sort -R --random-source=$pl_seed_path; else cat; fi; } )
+ mapfile -t initial_ls < <(beet ls -f "$fmt" "$@" | { if $random; then sort -R --random-source=$pl_seed_path; else cat; fi; } )
id_count=${#initial_ls[@]}
for line in "${initial_ls[@]}"; do
path="${line#*PijokVipiotOzeph }"
echo "$ls_line"
fi
done
+ if $doplay; then
+ #{ mpv --profile=a --volume=$volume --idle 2>&1 & } 2>/dev/null
+ mpv --profile=a --volume=$volume --idle &
+ # if we dont sleep, we get error like this:
+ # socat[1103381] E connect(5, AF=1 "/tmp/mpvsock", 14): Connection refused
+ # and strangely, it persists until mpv is restarted.
+ # .1 sleep was too little.
+ sleep .2
+ fi
while true; do
id=${ids[j]}
if $doplay; then
# https://stackoverflow.com/a/7687716
# note: duplicated down below
+ #
+ # notes on old method of invoking mpv each time:
# https://superuser.com/questions/305933/preventing-bash-from-displaying-done-when-a-background-command-finishes-execut
# we can't disown or run in a subshell or set +m because all that
# disabled job control from working properly in ways we want.
# is that we are waiting in 2 second intervals and checking if the
# background job exists. Instead, we should make mpv just idle
# when it is done with a song and then send it a command to play a new track.
- { mpv --profile=a --volume=$volume "$path" 2>&1 & } 2>/dev/null
+ #{ mpv --profile=a --volume=$volume "$path" 2>&1 & } 2>/dev/null
+ # old
+ #{ beet play "--args=--volume=$volume" "id:$id" 2>&1 & } 2>/dev/null
+ mpvrpc '{ "command": ["loadfile", "'"$path"'"] }'
erasable_line=false
fi
while true; do
fi
beetag-help
if [[ $char == $'\n' ]]; then
- # https://stackoverflow.com/a/5722874
- kill-bg-quiet
break
fi
case $char in
";")
- kill-bg-quiet
j=$(( j - 2 ))
break
;;
doplay=false
else
doplay=true
- kill-bg-quiet
- { mpv --profile=a --volume=$volume "$path" 2>&1 & } 2>/dev/null
- #{ beet play "--args=--volume=$volume" "id:$id" 2>&1 & } 2>/dev/null
+ mpvrpc '{ "command": ["loadfile", "'"$path"'"] }'
erasable_line=false
fi
beetag-nostatus 1
continue
;;
_)
- kill-bg-quiet
m beet rm --delete --force "id:$id"
beetag-nostatus 4 # guessing. dont want to test atm
break
j=$(( j - 1 ))
fi
fi
- kill-bg-quiet
break
fi
;;
mycheologs() {
local days q
days=${1:-16}
+ # timezone compared to utc. note: this will need adjustment for spring/fall.
+ zone_offset=$(( 60 * 60 * 5 ))
q="
select
- datetime(substr(timeSent,0,11), 'unixepoch'),
+ datetime(substr(timeSent,0,11) - $zone_offset, 'unixepoch'),
body
from messages
where timeSent > $(( (EPOCHSECONDS - days * 60 * 60 * 24) * 1000 ))