#!/bin/bash # I, Ian Kelling, follow the GNU license recommendations at # https://www.gnu.org/licenses/license-recommendations.en.html. They # recommend that small programs, < 300 lines, be licensed under the # Apache License 2.0. This file contains or is part of one or more small # programs. If a small program grows beyond 300 lines, I plan to switch # its license to GPL. # Copyright 2024 Ian Kelling # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # http://www.apache.org/licenses/LICENSE-2.0 # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. set -e; . /usr/local/lib/bash-bear; set +e obs-interlude() { p=$(cat /p/obs-ws-pass) if [[ -e /tmp/no-obs-auto-scene-switch ]]; then rm -f /tmp/no-obs-auto-scene-switch if [[ -s /tmp/last-obs-i3-mark ]]; then mark=$(cat /tmp/last-obs-i3-mark) obs-cmd -w obsws://localhost:4455/$p scene switch $mark fi else touch /tmp/no-obs-auto-scene-switch obs-cmd -w obsws://localhost:4455/$p scene switch interlude fi } ffmpeg-interlude() { f=/tmp/iank-ffmpeg-interlude-toggle # interlude off if [[ -e $f ]]; then rm -f $f # note: get _6 from looking for "parsed" ffmpeg debug output. zsend -b tcp://127.0.0.1:5557 Parsed_drawbox_6 t 0 zsend -b tcp://127.0.0.1:5557 Parsed_drawtext_7 reinit "text=''" else # I started an attempt to track if I was muted before an interlude, # but decided against it. Seems easier to handle unmuting with # whatever normal process I have for it. # # muted=$(pactl get-source-mute @DEFAULT_SOURCE@ | awk '{print $2}') zsend Parsed_volume_1 volume 0 zsend -b tcp://127.0.0.1:5557 Parsed_drawbox_6 t fill zsend -b tcp://127.0.0.1:5557 Parsed_drawtext_7 reinit "text='$(date "+%H\:%M %Z") - Be right back'" touch $f fi } zsend() { local out if [[ $1 == -b ]]; then zmq_args=("$1" "$2") shift 2 fi out=$(printf "%s\n" "$*" | zmqsend ${zmq_args[@]} ||:) if [[ $out != "0 Success" ]]; then i3-nagbar -m "FAILED zmqsend: $*" -t error -f "pango:monospace 30" fi } if pgrep '^obs$' &>/dev/null; then obs-interlude else ffmpeg-interlude fi