Skip to content

Instantly share code, notes, and snippets.

@Corben78
Created May 12, 2021 15:13
Show Gist options
  • Select an option

  • Save Corben78/96ce59d9490d2ed1bb9a322da1af008c to your computer and use it in GitHub Desktop.

Select an option

Save Corben78/96ce59d9490d2ed1bb9a322da1af008c to your computer and use it in GitHub Desktop.
Shell script to use with leafac/obs-cli for toggeling visiblity of a single or a group of items. Needs jq for parsing json.
#!/bin/bash
OBSWSPW=obs-studio
GETPROPERTIES=()
for JSON in "$@"; do
GETPROPERTIES+=("GetSceneItemProperties=${JSON}")
done
# read all given properties, extract visible element, save into array
VISIBILITY=( $(obs-cli-linux -p "$OBSWSPW" "${GETPROPERTIES[@]}" | jq ".[].visible") )
#toggle visibility for each entry
IDX=0
for ITEM in "${VISIBILITY[@]}"; do
case "$ITEM" in
true)
VISIBILITY[$IDX]=false
;;
false)
VISIBILITY[$IDX]=true
;;
esac
(( IDX++ ))
done
IDX=0
for JSON in "$@"; do
NEWJSON=$(echo ${JSON} | jq ". |= . + {"visible": "${VISIBILITY[$IDX]}"}")
SETPROPERTIES+=("SetSceneItemProperties=${NEWJSON}")
(( IDX++ ))
done
obs-cli-linux -p "$OBSWSPW" "${SETPROPERTIES[@]}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment