#!/bin/sh # SPDX-FileCopyrightText: 2023-2024 The Remph # SPDX-License-Identifier: GPL-3.0-or-later set ${BASH_VERSION:+-o pipefail} -efmu wobfifo=$XDG_RUNTIME_DIR/$WAYLAND_DISPLAY.swob wobini= set_wobini() { for dir in ${XDG_CONFIG_HOME:+"$XDG_CONFIG_HOME"} ~/.config /etc; do if test -r "$dir"/swob/wob.ini; then wobini=$dir/swob/wob.ini return fi done # fine, I will make my own wob.ini(5) wobini=${XDG_CONFIG_HOME:-~/.config}/swob/wob.ini echo >&2 "$0: no swob/wob.ini found; writing default to $wobini" mkdir -p "${wobini%/*}" cat >$wobini <&2 "$0: error: unrecognised argument: $target" exit -1 ;; esac } ## MAIN ## start_wob { do_cmd_get_percent "$@" sleep 3 # Needs to be long enough that there aren't too many wob(1) # processes spawned and respawned consecutively on repeated # taps, but short enough that there aren't too many /bin/sh # processes hanging around simultaneously running sleep(1) # from this script! 3 seconds is an uneducated guess. } >$wobfifo # Don't let wob die if it's still receiving input from another process; wait # until it says it's finished # To solve the above mentioned problem of too many /bin/sh processes hanging # around, we could setsid(1) wob so the script can exit without waiting as # soon as it's done sleeping (the existing situation is that as long as one # script sleeps, the shell that spawned the wob process will wait until that # sleep is done) test -z $! || wait $!