Skip to content

Commit

Permalink
Format now playing and zone info
Browse files Browse the repository at this point in the history
  • Loading branch information
ron.record committed Jun 11, 2024
1 parent 9c6d1b6 commit 0c0eeee
Showing 1 changed file with 76 additions and 47 deletions.
123 changes: 76 additions & 47 deletions bin/roon
Original file line number Diff line number Diff line change
Expand Up @@ -652,10 +652,7 @@ show_info() {
printf "\nDefault ${media}:\t${DEFAULT}"
fi
done
[ "${fullinfo}" ] && {
show_now_playing -p
${ROON}/bin/get_zone_volume
}
[ "${fullinfo}" ] && show_now_playing
}

# Install the fzf fuzzy finder utility
Expand Down Expand Up @@ -724,20 +721,70 @@ set_zone_options() {

# Display currently playing info for specified zone or all zones
show_now_playing() {
nowarg="$1"
zone="$2"
if [ "${LOCAL}" = true ]; then
if [ "${zone}" ]; then
${ROON}/bin/now_playing ${nowarg} -z "${zone}"
zone="$1"
nowarg="$2"
if [ "${nowarg}" ]; then
if [ "${LOCAL}" = true ]; then
if [ "${zone}" ]; then
${ROON}/bin/now_playing ${nowarg} -z "${zone}"
else
${ROON}/bin/now_playing ${nowarg}
fi
else
${ROON}/bin/now_playing ${nowarg}
if [ "${zone}" ]; then
ssh ${user}@${server} "bash -l -c \"${ROON}/bin/now_playing ${nowarg} -z ${zone}\""
else
ssh ${user}@${server} "bash -l -c \"${ROON}/bin/now_playing ${nowarg}\""
fi
fi
else
if [ "${zone}" ]; then
ssh ${user}@${server} "bash -l -c \"${ROON}/bin/now_playing ${nowarg} -z ${zone}\""
[ "${zone}" ] || zone=$(get_default_ini DefaultZone)
if [ "${have_rich}" ]; then
rich "[red]Now Playing[/]:" -p
else
printf "\nNow Playing:\n"
fi
if [ "${have_jq}" ]; then
${ROON}/bin/get_zone_info -n -z "${zone}" | \
jq -r 'to_entries[] | "\(.key)=\"\(.value)\""' | while read i
do
k=$(echo $i | awk -F '=' '{ print $1 }')
v=$(echo $i | awk -F '=' '{ print $2 }')
k="$(echo -e "${k}" | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//')"
v="$(echo -e "${v}" | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//')"
v="$(echo -e "${v}" | sed -e 's/^\"//' -e 's/\"$//')"
if echo "${k}" | grep Now > /dev/null; then
pre=""
siz=19
else
pre=" "
siz=15
fi
numspaces=$((${siz} - ${#k}))
spaces=""
for i in $(seq ${numspaces}); do
spaces="${spaces} "
done
if [ "${have_rich}" ]; then
rich "${pre}[red]${k}[/]:${spaces} [yellow]${v}[/]" -p
else
printf "\n\t${pre}$k:${spaces} $v"
fi
done
else
${ROON}/bin/get_zone_info -n -z "${zone}"
fi
fi
if [ "${have_jq}" ]; then
pre=" "
vol=$(${ROON}/bin/get_zone_volume -n)
if [ "${have_rich}" ]; then
rich "${pre}[red]Volume[/]: [yellow]${vol}[/]" -p
else
ssh ${user}@${server} "bash -l -c \"${ROON}/bin/now_playing ${nowarg}\""
printf "\n\t${pre}Volume: $vol"
fi
else
${ROON}/bin/get_zone_volume
fi
}

Expand Down Expand Up @@ -1050,59 +1097,40 @@ play_zone() {
zone_info() {
this_zone="$1"
if [ "${have_rich}" ]; then
rich "[red]Zone Name:[/] [yellow]${this_zone}[/]" -p
else
printf "\nZone Name: ${this_zone}\n"
fi
${ROON}/bin/get_zone_volume -z "${this_zone}" | \
awk -F ':' '{ print $2 }' | \
sed -e 's/^[[:space:]]*/ /' -e 's/[[:space:]]*$//'
if [ "${have_rich}" ]; then
rich "[red]Groups With:[/]" -p
rich "[red]Zone[/] [yellow]${this_zone}[/] [red]Groups With:[/]" -p
else
printf "\nGroups With:\n"
printf "\nZone '${this_zone}' Groups With:"
fi
${ROON}/bin/get_zone_info -l -z "${this_zone}" | sed -e "s/,/\n /g" -e "s/^/ /"
if [ "${have_rich}" ]; then
rich "[red]Zone Settings:[/]" -p
else
printf "\nZone Settings:\n"
fi
if [ "${have_jq}" ]; then
${ROON}/bin/get_zone_info -s -z "${this_zone}" | \
jq -r 'to_entries[] | "\(.key)=\"\(.value)\""' | while read i
${ROON}/bin/get_zone_info -l -z "${this_zone}" | sed -e "s/,/\n /g" -e "s/^/ /" \
| while read l
do
k=$(echo $i | awk -F '=' '{ print $1 }')
v=$(echo $i | awk -F '=' '{ print $2 }')
if [ "${have_rich}" ]; then
rich " [yellow]$k[/]: [cyan]$v[/]" -p
rich " [yellow]$l[/]" -p
else
printf "\n\t$k: $v"
printf "\n\t$l"
fi
done
else
${ROON}/bin/get_zone_info -s -z "${this_zone}"
fi
if [ "${have_rich}" ]; then
rich "[red]Now Playing:[/]" -p
rich "[red]Zone Settings:[/]" -p
else
printf "\nNow Playing:\n"
printf "\nZone Settings:\n"
fi
if [ "${have_jq}" ]; then
${ROON}/bin/get_zone_info -n -z "${this_zone}" | \
${ROON}/bin/get_zone_info -s -z "${this_zone}" | \
jq -r 'to_entries[] | "\(.key)=\"\(.value)\""' | while read i
do
k=$(echo $i | awk -F '=' '{ print $1 }')
v=$(echo $i | awk -F '=' '{ print $2 }')
if [ "${have_rich}" ]; then
rich " [yellow]$k[/]: [cyan]$v[/]" -p
rich " [yellow]$k[/]: [cyan]$v[/]" -p
else
printf "\n\t$k: $v"
fi
done
else
${ROON}/bin/get_zone_info -n -z "${this_zone}"
${ROON}/bin/get_zone_info -s -z "${this_zone}"
fi
show_now_playing "${this_zone}"
}

select_media() {
Expand Down Expand Up @@ -1811,7 +1839,8 @@ main_menu() {
break
;;
"Now Playing"*,* | *,"Now Playing"* | "N",* | *,"N")
show_now_playing -p
heading "Roon Now Playing" "Now Playing"
show_now_playing
prompt_continue
break
;;
Expand Down Expand Up @@ -1873,7 +1902,7 @@ main_menu() {
;;
"Zone Info"*,* | *,"Zone Info"* | "zone info"*,* | *,"zone info"* | "Z",* | *,"Z")
infozone=$(get_default_ini DefaultZone)
heading "Default Roon Zone" "Roon Zone"
heading "Roon Zone $infozone" "$infozone"
zone_info "$infozone"
prompt_continue
break
Expand Down Expand Up @@ -2260,7 +2289,7 @@ done
fi
}

[ "$now_playing" ] && show_now_playing "${nowarg}" "${zone}"
[ "$now_playing" ] && show_now_playing "${zone}" "${nowarg}"

[ "$albumlist" ] && {
[ "$album" ] || {
Expand Down

0 comments on commit 0c0eeee

Please sign in to comment.