#!/bin/sh # File: fix-alttab-daemon # Location: /usr/bin # Author: bgstack15 # Startdate: 2023-07-10-2 08:55 # SPDX-License-Identifier: GPL-3.0 # Title: fix-alttab-daemon # Project: fix-alttab # Purpose: Detect changes to connected HDMI monitors # History: # Usage: # run in ~/.fluxbox/startup in the background # Reference: # Improve: # Dependencies: # dep-devuan: bgscripts-core # Documentation: README.md # load settings test -z "${DEFAULTSDIR}" && DEFAULTSDIR=/etc/sysconfig grep -qiE 'de(vu|bi)an|ubuntu|mint' /etc/os-release 1>/dev/null 2>&1 && DEFAULTSDIR=/etc/default test -f "${DEFAULTSDIR}/fix-alttab" && . "${DEFAULTSDIR}/fix-alttab" test -f "${XDG_CONFIG_HOME:-~/.config}/fix-alttab" && . "${XDG_CONFIG_HOME:-~/.config}/fix-alttab" test -z "${FIX_ALTTAB_BIN}" && FIX_ALTTAB_BIN=/usr/libexec/fix-alttab command -v plecho 1>/dev/null && _use_plecho=1 unset _laststatus while ! test -f /tmp/stop-fix-alttab-daemon ; do sleep "${ALTTAB_DAEMON_LOOP:-3}" _status="$( APPLY= "${FIX_ALTTAB_BIN}" )" test "${_status}" != "${_laststatus}" && { APPLY=1 "${FIX_ALTTAB_BIN}" | \ { if test "${_use_plecho}" = "1" ; then timeout 2 plecho else timeout 2 cat fi } } | tee -a "${ALTTAB_DAEMON_LOGFILE:-fix-alttab-daemon.log}" _laststatus="${_status}" done