Created
May 12, 2021 15:13
-
-
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/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