From c04d22d04e5b767fc714ccd09aac594c4e3293ac Mon Sep 17 00:00:00 2001 From: AJ Jordan Date: Sun, 3 Nov 2024 04:19:04 -0500 Subject: [PATCH] Ask for the RTMP keyset --- bin/seagl-setup-app | 3 +-- sbin/seagl-setup-room | 12 ++++++++++-- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/bin/seagl-setup-app b/bin/seagl-setup-app index 8198f44..b08932b 100755 --- a/bin/seagl-setup-app +++ b/bin/seagl-setup-app @@ -29,8 +29,7 @@ function get_config_value() { } if [ "$arg" == obs ]; then - # TODO ask for the keyset - keyset=ajDevelopment + keyset=$(cat /var/lib/seagl/rtmp-keyset) rtmp_key=$(get_config_value .rtmpKeys.$keyset.$(cat /var/lib/seagl/room-id)) sed -i "s/__YOUTUBE_STREAM_KEY__/$rtmp_key/" ~/.var/app/com.obsproject.Studio/basic/profiles/Untitled/service.json start_and_link_app com.obsproject.Studio diff --git a/sbin/seagl-setup-room b/sbin/seagl-setup-room index b97de30..3b4d514 100755 --- a/sbin/seagl-setup-room +++ b/sbin/seagl-setup-room @@ -16,20 +16,28 @@ if ! [ $(id -u) == 0 ]; then fi mkdir -p /var/lib/seagl + +seagl-refresh-config + zenity --list --text='Which room is this?' --column=Room Lyceum 332 334 340 > /var/lib/seagl/room-id hostnamectl location "$(sed -E 's/([[:digit:]])/Room \1/' < /var/lib/seagl/room-id)" if zenity --question --text='Should this laptop be provisioned for streaming? Choose no if it will only be used for presentations.'; then echo streaming > /var/lib/seagl/laptop-type + descriptions=() + # Can't do `| while read` because bash runs this in a subshell, and vars don't set. + # https://unix.stackexchange.com/a/143959/29146 + while read i; do descriptions+=("$i"); done < <(jq -r '.rtmpKeys[] | .keysetDescription' < /var/lib/seagl/config-data.json) + desc="$(zenity --list --text='Which RTMP keyset is this?' --column=Room "${descriptions[@]}")" + # This is a little hard to follow, but basically we use to_entries to work with the key and (object) value at the same object depth, then filter for a description matching what Zenity gave us. The matching description's associated key is the keyset ID. + jq -r '.rtmpKeys | to_entries[] | select (.value.keysetDescription == "'"$desc"'") | .key' /var/lib/seagl/rtmp-keyset else echo presentations > /var/lib/seagl/laptop-type fi hostnamectl hostname seagl-$(tr '[:upper:]' '[:lower:]' < /var/lib/seagl/room-id)-$(cat /var/lib/seagl/laptop-type) -seagl-refresh-config - # TODO set up OBS, then (auto)launch it if [ $(cat /var/lib/seagl/laptop-type) == streaming ]; then