diff options
-rw-r--r-- | .gitignore | 7 | ||||
-rw-r--r-- | README.md | 42 | ||||
-rw-r--r-- | debian/README.Debian | 5 | ||||
-rw-r--r-- | debian/_service | 28 | ||||
-rw-r--r-- | debian/changelog | 5 | ||||
-rw-r--r-- | debian/control | 20 | ||||
-rw-r--r-- | debian/copyright | 35 | ||||
-rw-r--r-- | debian/fix-alttab.dsc | 16 | ||||
-rw-r--r-- | debian/fix-alttab.lintian-overrides | 0 | ||||
-rw-r--r-- | debian/patches/series | 1 | ||||
-rwxr-xr-x | debian/rules | 17 | ||||
-rw-r--r-- | debian/source/format | 1 | ||||
-rw-r--r-- | debian/source/lintian-overrides | 0 | ||||
-rw-r--r-- | debian/source/local-options | 4 | ||||
-rw-r--r-- | debian/source/options | 4 | ||||
-rw-r--r-- | debian/source/patch-header | 22 | ||||
-rw-r--r-- | debian/upstream/metadata | 16 | ||||
-rw-r--r-- | debian/watch | 2 | ||||
-rw-r--r-- | src/Makefile | 106 | ||||
-rw-r--r-- | src/etc/sysconfig/fix-alttab | 14 | ||||
-rw-r--r-- | src/etc/xdg/autostart/fix-alttab-daemon.desktop | 13 | ||||
-rwxr-xr-x | src/usr/bin/fix-alttab-daemon | 43 | ||||
-rwxr-xr-x | src/usr/libexec/fix-alttab | 75 | ||||
-rw-r--r-- | src/usr/share/man/man1/fix-alttab-daemon.1.txt | 33 | ||||
-rw-r--r-- | src/usr/share/man/man1/fix-alttab.1.txt | 33 |
25 files changed, 542 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..651823d --- /dev/null +++ b/.gitignore @@ -0,0 +1,7 @@ +*.log +*.gz +debian/.debhelper +debian/debhelper* +debian/files +debian/fix-alttab.substvars +debian/fix-alttab/ diff --git a/README.md b/README.md new file mode 100644 index 0000000..6409f48 --- /dev/null +++ b/README.md @@ -0,0 +1,42 @@ +<!-- +.. File: README.md +.. Location: https://bgstack15.ddns.net/cgit/fix-alttab +.. Author: bgstack15 +.. Startdate: 2023-07-10-2 11:01 +.. Title: README for fix-alttab +.. Project: fix-alttab +.. Purpose: Readme file +.. History: +.. Usage: Read it +.. Reference: +.. Improve: +.. Dependencies: +.. Documentation: +--> + +# README for fix-alttab +This is a quick and dirty tool that rearranges alttab on the screen when one of my two monitors is on a different input. For my main workstation, when xrandr output resembles certain setup (only right monitor usable), run alttab with certain config. When xrandr output resembles 2 monitors usable, run alttab with certain config. + +## Upstream +This project's upstream is at <https://bgstack15.ddns.net/cgit/fix-alttab>. + +## Alternatives +Use a desktop environment. + +## Reason for existence + +## Using +Use the included fix-alttab-daemon.desktop entry in `/etc/xdg/autostart`, or add the program to `~/.fluxbox/startup` or run in a terminal. + +## Dependencies + +* Optional: bgscripts, for script plecho +* xrandr + +## Building +N/A. + +## References + +## WORKHERE +2023-07-10-2 11:21 need to add Makefile install target. diff --git a/debian/README.Debian b/debian/README.Debian new file mode 100644 index 0000000..ee149a1 --- /dev/null +++ b/debian/README.Debian @@ -0,0 +1,5 @@ +fix-alttab for Devuan + +Initial package for Devuan + + -- B. Stack <bgstack15@gmail.com> Wed, 12 Jul 2023 16:30:59 -0400 diff --git a/debian/_service b/debian/_service new file mode 100644 index 0000000..c956bf2 --- /dev/null +++ b/debian/_service @@ -0,0 +1,28 @@ +<services> + <service name="tar_scm"> + <param name="scm">git</param> + <param name="url">https://bgstack15.ddns.net/cgit/fix-alttab</param> + <param name="subdir">fix-alttab/debian</param> + <param name="filename">debian</param> + <param name="revision">master</param> + <param name="version">_none_</param> + </service> + <service name="recompress"> + <param name="file">*.tar</param> + <param name="compression">xz</param> + </service> + <service name="tar_scm"> + <param name="scm">git</param> + <param name="url">https://bgstack15.ddns.net/cgit/fix-alttab</param> + <param name="revision">master</param> + <param name="version">_none_</param> + </service> + <service name="recompress"> + <param name="file">*.tar</param> + <param name="compression">gz</param> + </service> + <service name="extract_file"> + <param name="archive">*.tar.xz</param> + <param name="files">*/*.dsc</param> + </service> +</services> diff --git a/debian/changelog b/debian/changelog new file mode 100644 index 0000000..d35fcff --- /dev/null +++ b/debian/changelog @@ -0,0 +1,5 @@ +fix-alttab (0.0.1-1) obs; urgency=low + + * Initial release. Closes: packages-want#29 + + -- B. Stack <bgstack15@gmail.com> Wed, 12 Jul 2023 16:30:59 -0400 diff --git a/debian/control b/debian/control new file mode 100644 index 0000000..38b15da --- /dev/null +++ b/debian/control @@ -0,0 +1,20 @@ +Source: fix-alttab +Section: x11 +Priority: optional +Maintainer: B. Stack <bgstack15@gmail.com> +Build-Depends: debhelper-compat (= 13), + bgscripts-core, + txt2man +Standards-Version: 4.5.1 +Homepage: https://bgstack15.ddns.net/ +Rules-Requires-Root: no +Vcs-Git: https://bgstack15.ddns.net/git/fix-alttab +Vcs-Browser: https://bgstack15.ddns.net/git/fix-alttab + +Package: fix-alttab +Architecture: all +Multi-Arch: foreign +Depends: ${misc:Depends}, ${shlibs:Depends} +Description: rerun alttab if monitor config changes + This small utility restarts alttab with various parameters + depending on which monitors are active. diff --git a/debian/copyright b/debian/copyright new file mode 100644 index 0000000..a888660 --- /dev/null +++ b/debian/copyright @@ -0,0 +1,35 @@ +Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ +Upstream-Name: fix-alttab +Upstream-Contact: B. Stack <bgstack15@gmail.com> +Source: https://bgstack15.ddns.net/ + +Files: src/Makefile + src/etc/sysconfig/fix-alttab + src/etc/xdg/autostart/fix-alttab-daemon.desktop + src/usr/bin/fix-alttab-daemon + src/usr/libexec/fix-alttab + src/usr/share/man/man1/fix-alttab-daemon.1.txt + src/usr/share/man/man1/fix-alttab.1.txt + debian/* + README.md +Copyright: 2023 B. Stack +License: GPL-3.0 + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + . + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + . + You should have received a copy of the GNU General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. + . + On Debian systems, the complete text of the GNU General Public License + Version 3 can be found in `/usr/share/common-licenses/GPL-3'. + +#---------------------------------------------------------------------------- +# Files marked as NO_LICENSE_TEXT_FOUND may be covered by the following +# license/copyright files. diff --git a/debian/fix-alttab.dsc b/debian/fix-alttab.dsc new file mode 100644 index 0000000..d412f9d --- /dev/null +++ b/debian/fix-alttab.dsc @@ -0,0 +1,16 @@ +Format: 3.0 (quilt) +Source: fix-alttab +Binary: fix-alttab +Architecture: all +Version: 0.0.1-1 +Maintainer: B. Stack <bgstack15@gmail.com> +Homepage: https://bgstack15.ddns.net/ +Standards-Version: 4.5.1 +Vcs-Browser: https://bgstack15.ddns.net/git/fix-alttab +Vcs-Git: https://bgstack15.ddns.net/git/fix-alttab +Build-Depends: debhelper-compat (= 13), bgscripts-core, txt2man +Package-List: + fix-alttab deb x11 optional arch=all +Files: + 00000000000000000000000000000000 1 fix-alttab.orig.tar.gz + 00000000000000000000000000000000 1 fix-alttab.debian.tar.xz diff --git a/debian/fix-alttab.lintian-overrides b/debian/fix-alttab.lintian-overrides new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/debian/fix-alttab.lintian-overrides diff --git a/debian/patches/series b/debian/patches/series new file mode 100644 index 0000000..4a97dfa --- /dev/null +++ b/debian/patches/series @@ -0,0 +1 @@ +# You must remove unused comment lines for the released package. diff --git a/debian/rules b/debian/rules new file mode 100755 index 0000000..9d50627 --- /dev/null +++ b/debian/rules @@ -0,0 +1,17 @@ +#!/usr/bin/make -f +# You must remove unused comment lines for the released package. +#export DH_VERBOSE = 1 +#export DEB_BUILD_MAINT_OPTIONS = hardening=+all +#export DEB_CFLAGS_MAINT_APPEND = -Wall -pedantic +#export DEB_LDFLAGS_MAINT_APPEND = -Wl,--as-needed +export APPNAME=fix-alttab + +%: + dh $@ --sourcedirectory=src + +override_dh_auto_install: + dh_auto_install -- prefix=/usr DEFAULTDIR='$$(DESTDIR)/etc/default' + +override_dh_auto_build: + dh_auto_build + make-dsc-for-obs diff --git a/debian/source/format b/debian/source/format new file mode 100644 index 0000000..163aaf8 --- /dev/null +++ b/debian/source/format @@ -0,0 +1 @@ +3.0 (quilt) diff --git a/debian/source/lintian-overrides b/debian/source/lintian-overrides new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/debian/source/lintian-overrides diff --git a/debian/source/local-options b/debian/source/local-options new file mode 100644 index 0000000..77effbe --- /dev/null +++ b/debian/source/local-options @@ -0,0 +1,4 @@ +# +# ### gbp-buildpackage(1) user may like this. ### +#abort-on-upstream-changes +#unapply-patches diff --git a/debian/source/options b/debian/source/options new file mode 100644 index 0000000..077de7d --- /dev/null +++ b/debian/source/options @@ -0,0 +1,4 @@ +# +# ### dgit-maint-merge(7) workflow user need this ### +# single-debian-patch +# auto-commit diff --git a/debian/source/patch-header b/debian/source/patch-header new file mode 100644 index 0000000..6ff0a40 --- /dev/null +++ b/debian/source/patch-header @@ -0,0 +1,22 @@ +The automatically generated patch puts this free form text on top of it. + +If you are using gbp-buildpackage(1), you probably don't need this file. + +If you are using dgit-maint-merge(7), please consider text as follows. + +The Debian packaging of foo is maintained in git, using the merging workflow +described in dgit-maint-merge(7). There isn't a patch queue that can be +represented as a quilt series. + +A detailed breakdown of the changes is available from their canonical +representation - git commits in the packaging repository. For example, to see +the changes made by the Debian maintainer in the first upload of upstream +version 1.2.3, you could use: + + % git clone https://git.dgit.debian.org/foo + % cd foo + % git log --oneline 1.2.3..debian/1.2.3-1 -- . ':!debian' + +(If you have dgit, use `dgit clone foo`, rather than plain `git clone`.) + +A single combined diff, containing all the changes, follows. diff --git a/debian/upstream/metadata b/debian/upstream/metadata new file mode 100644 index 0000000..dc2feb0 --- /dev/null +++ b/debian/upstream/metadata @@ -0,0 +1,16 @@ +# +# DEP-12: Per-package machine-readable metadata about Upstream +# Please check * https://dep-team.pages.debian.net/deps/dep12/ +# * https://wiki.debian.org/UpstreamMetadata +Reference: + Author: <please use full names and separate multiple author by the keyword "and"> + Title: + Journal: + Year: + Volume: + Number: + Pages: + DOI: + PMID: + URL: + eprint: diff --git a/debian/watch b/debian/watch new file mode 100644 index 0000000..76575dc --- /dev/null +++ b/debian/watch @@ -0,0 +1,2 @@ +# You must remove unused comment lines for the released package. +version=3 diff --git a/src/Makefile b/src/Makefile new file mode 100644 index 0000000..5e2d00f --- /dev/null +++ b/src/Makefile @@ -0,0 +1,106 @@ +# File: Makefile for fix-alttab +# Location: fix-alttab source package +# Author: bgstack15 +# Startdate: 2023-07-10-2 16:27 +# SPDX-License-Identifier: GPL-3.0 +# Title: Makefile for fix-alttab source package +# Project: fix-alttab +# Purpose: To use traditional Unix make utility +# History: +# Usage: +# Reference: +# outbound Makefile +# Improve: +# Document: +# Dependencies: +# build-devuan: bgscripts-core, txt2man + +APPNAME = fix-alttab +APPVERSION = 0.0.1 +SRCDIR = $(CURDIR) +prefix = /usr +SYSCONFDIR = $(DESTDIR)/etc +DEFAULTDIR = $(DESTDIR)/etc/sysconfig# for debian use '$(DESTDIR)/etc/default' +LIBEXECDIR = $(DESTDIR)$(prefix)/libexec +SHAREDIR = $(DESTDIR)$(prefix)/share +DOCDIR = $(SHAREDIR)/doc/$(APPNAME) +MANDIR = $(SHAREDIR)/man +BINDIR = $(DESTDIR)$(prefix)/bin + +# variables for deplist +DEPTYPE = dep +SEPARATOR = , + +awkbin :=$(shell which awk) +chmodbin :=$(shell which chmod) +cpbin :=$(shell which cp) +echobin :=$(shell which echo) +falsebin :=$(shell which false) +findbin :=$(shell which find) +grepbin :=$(shell which grep) +gzipbin :=$(shell which gzip) +installbin :=$(shell which install) +rmbin :=$(shell which rm) +rmdirbin :=$(shell which rmdir) +sedbin :=$(shell which sed) +sortbin :=$(shell which sort) +truebin :=$(shell which true) +uniqbin :=$(shell which uniq) +xargsbin :=$(shell which xargs) +txt2manwrapper :=/usr/bin/txt2man-wrapper + +with_man ?= YES + +all: build_man + -@#echo "Nothing to build." && ${truebin} + +ifeq ($(with_man),YES) +install: build_man install_files +else +install: install_files +endif + +.PHONY: clean install install_files build_man uninstall list deplist deplist_opts + +list: + @$(MAKE) -pRrq -f $(lastword $(MAKEFILE_LIST)) : 2>/dev/null | ${awkbin} -v RS= -F: '/^# File/,/^# Finished Make data base/ {if ($$1 !~ "^[#.]") {print $$1}}' | ${sortbin} | ${grepbin} -E -v -e '^[^[:alnum:]]' -e '^$@$$' + +deplist: + @# deplist 2020-04-18 input must be comma separated + @# DEPTYPE( dep , rec , sug ) for depends, recommends, or suggests + @if test -z "${DISTRO}" ; then ${echobin} "Please run \`make deplist\` with DISTRO= one of: `make deplist_opts 2>&1 1>/dev/null | ${xargsbin}`. Aborted." 1>&2 ; exit 1 ; fi + @if ! ${echobin} "${DEPTYPE}" | grep -qE "^(dep|rec|sug)$$" ; then ${echobin} "Please run \`make deplist\` with DEPTYPE= one of: dep, rec, sug. Undefined will use \`dep\`. Aborted." 1>&2 ; exit 1; fi + @${grepbin} -h --exclude-dir='doc' -riIE "\<${DEPTYPE}-" ${SRCDIR} | ${awkbin} -v "domain=${DISTRO}" -v "deptype=${DEPTYPE}" 'tolower($$2) ~ deptype"-"domain {$$1="";$$2="";print}' | tr ',' '\n' | ${sortbin} | ${uniqbin} | ${sedbin} -r -e 's/^\s*//' -e "s/\s*\$$/${SEPARATOR}/" | ${xargsbin} + +deplist_opts: + @# deplist_opts 2020-04-18 find all available dependency domains + @${grepbin} -h -o -riIE '\<(dep|rec|sug)-[^\ :]+:' ${SRCDIR} | ${sedbin} -r -e 's/(dep|rec|sug)-//;' -e 's/:$$//;' | ${sortbin} | ${uniqbin} 1>&2 + +install_files: + @ls usr/share/man/man*/*gz 1>/dev/null 2>&1 && echo "Including man pages." || : + @${echobin} Installing files to ${DESTDIR} + for td in $$( ${findbin} ${SRCDIR} -type d ! -name '.*.swp' ! -name 'Makefile' ! -name '.gitignore' ! -name 'README.md' -printf '%P\n' | ${sedbin} -r -e "s:etc/sysconfig:${DEFAULTDIR}:" -e "s:${DESTDIR}/?::" ) ; do ${installbin} -m0755 -d ${DESTDIR}/$${td} ; done + for tf in $$( ${findbin} ${SRCDIR} ! -type d ! -name '.*.swp' ! -name 'Makefile' ! -name '.gitignore' ! -name 'README.md' ! \( -path '*/man/*' -name '*.txt' \) ! -path '*/sysconfig/*' -printf '%P\n' ) ; do MODE=0644 ; echo "$${tf}" | grep -qE "(bin|libexec|deprecated)/" && MODE=0755 ; ${installbin} -m$${MODE} ${SRCDIR}/$${tf} ${DESTDIR}/$${tf} ; done + @# sysconfig/default dir + ${installbin} -m0644 -t ${DEFAULTDIR} ${SRCDIR}/etc/sysconfig/* + @# grab the project readme from above dir src/ + ${installbin} -m0644 -t ${DOCDIR} ${SRCDIR}/../README.md + +MAN_TXT:=$(wildcard usr/share/man/man*/*.txt) +MAN_GZ:= $(subst .txt,.gz,$(MAN_TXT)) + +build_man: $(MAN_GZ) + +$(MAN_GZ): %.gz: %.txt + ${txt2manwrapper} - < $< | ${gzipbin} > $@ + +uninstall: + @${echobin} SRCDIR=${SRCDIR} + ${rmbin} -f $$( ${findbin} ${SRCDIR} -mindepth 1 ! -type d -printf '%p\n' | ${sedbin} -r -e "s:/etc/sysconfig:${DEFAULTDIR}:" -e "s:^${SRCDIR}:${DESTDIR}:" -e "s:${DESTDIR}${DESTDIR}:${DESTDIR}:" ) + + # remove all installed directories that are now blank. + ${rmdirbin} ${DEFAULTDIR} 2>/dev/null || : ; for word in $$( ${findbin} ${SRCDIR} -mindepth 1 -type d -printf '%p\n' | ${sedbin} -r -e "s:^${SRCDIR}:${DESTDIR}:" | ${awkbin} '{ print length, $$0 }' | ${sortbin} -rn | ${awkbin} '{print $$2}' ) ; do ${findbin} $${word} -mindepth 1 1>/dev/null 2>&1 | read 1>/dev/null 2>&1 || { ${rmdirbin} "$${word}" 2>/dev/null || ${truebin} ; } ; done + +clean: + -@#${echobin} "target $@ not implemented yet! Gotta say unh." && ${falsebin} + -${rmbin} -f usr/share/man/man*/*.gz || : diff --git a/src/etc/sysconfig/fix-alttab b/src/etc/sysconfig/fix-alttab new file mode 100644 index 0000000..0b348c2 --- /dev/null +++ b/src/etc/sysconfig/fix-alttab @@ -0,0 +1,14 @@ +# Example fix-alttab.conf +# Usage: dot-sourced by fix-alttab and its daemon +# Locations: +# /etc/sysconfig/fix-alttab.conf +# ~/.config/fix-alttab +ALTTAB_DAEMON_LOOP=3 +ALTTAB_DAEMON_LOGFILE="${XDG_RUNTIME_DIR:~}/fix-alttab-daemon.log" +# First word here is the binary to run. This will be killalled if it needs to be run. +ALTTAB_COMMON="alttab -w 1 -theme numix-circle" +ALTTAB_LEFTYES_RIGHTYES="" +ALTTAB_LEFTNO_RIGHTYES="-vp 1920x1080+1920+0" +ALTTAB_LEFTYES_RIGHTNO="" #unsupported +ALTTAB_LEFTNO_RIGHTNO="" # unsupported +FIX_ALTTAB_BIN=/usr/libexec/fix-alttab diff --git a/src/etc/xdg/autostart/fix-alttab-daemon.desktop b/src/etc/xdg/autostart/fix-alttab-daemon.desktop new file mode 100644 index 0000000..f02d8e6 --- /dev/null +++ b/src/etc/xdg/autostart/fix-alttab-daemon.desktop @@ -0,0 +1,13 @@ +[Desktop Entry] +Categories=Utility;Accessibility; +Comment=forces alttab dialog to visible monitor +Exec=/usr/bin/fix-alttab-daemon +GenericName=Fix alttab daemon +Icon=system-run +Keywords=daemon;alttab; +Name=Fix-alttab daemon +StartupNotify=true +Terminal=false +Type=Application +Version=1.0 +Hidden=false diff --git a/src/usr/bin/fix-alttab-daemon b/src/usr/bin/fix-alttab-daemon new file mode 100755 index 0000000..f32084f --- /dev/null +++ b/src/usr/bin/fix-alttab-daemon @@ -0,0 +1,43 @@ +#!/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 diff --git a/src/usr/libexec/fix-alttab b/src/usr/libexec/fix-alttab new file mode 100755 index 0000000..c0b68b2 --- /dev/null +++ b/src/usr/libexec/fix-alttab @@ -0,0 +1,75 @@ +#!/bin/sh +# File: fix-alttab +# Location: /usr/libexec/fix-alttab +# Author: bgstack15 +# Startdate: 2023-07-10-2 08:10 +# SPDX-License-Identifier: GPL-3.0 +# Title: fix-alttab +# History: +# Usage: +# called by fix-alttab-daemon +# Reference: +# https://unix.stackexchange.com/questions/537529/how-do-i-get-xdg-config-home-from-a-shell-script-command-line +# Improve: +# Dependencies: +# dep-devuan: xrandr, alttab +# 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" +# just in case no settings defined there +test -z "${ALTTAB_COMMON}" && ALTTAB_COMMON="alttab -w 1 -theme numix-circle" +test -z "${ALTTAB_LEFTYES_RIGHTYES}" && ALTTAB_LEFTYES_RIGHTYES="" +test -z "${ALTTAB_LEFTNO_RIGHTYES}" && ALTTAB_LEFTNO_RIGHTYES="-vp 1920x1080+1920+0" +test -z "${ALTTAB_LEFTYES_RIGHTNO}" && ALTTAB_LEFTYES_RIGHTNO="" #unsupported +test -z "${ALTTAB_LEFTNO_RIGHTNO}" && ALTTAB_LEFTNO_RIGHTNO="" # unsupported + +# for better security, strip out any semicolons from these values because we evaluate without quotes +_strip() { + printf '%s' "${@}" | sed -r -e 's/;.*$//;' +} +ALTTAB_COMMON="$( _strip "${ALTTAB_COMMON}" )" +ALTTAB_LEFTYES_RIGHTYES="$( _strip "${ALTTAB_LEFTYES_RIGHTYES}" )" +ALTTAB_LEFTNO_RIGHTYES="$( _strip "${ALTTAB_LEFTNO_RIGHTYES}" )" +ALTTABLEFTYES_RIGHTNO="$( _strip "${ALTTABLEFTYES_RIGHTNO}" )" +ALTTAB_LEFTNO_RIGHTNO="$( _strip "${ALTTAB_LEFTNO_RIGHTNO}" )" + +# always evaluate this +_ALTTAB_COMMAND_TO_KILL="$( echo "${ALTTAB_COMMON}" | awk '{print $1}' )" + +# main +# set environment variables "left" and "right" to yes or no, to indicate if monitor is there. +unset right left +eval $( xrandr | awk 'BEGIN{a[0]="no";a[1]="yes"}/HDMI-1/{if($2~/\<connected/){r=1;}else{r=0};} /HDMI-0/{if($2~/\<connected/){l=1;}else{l=0;};} END{print "right="a[r];print "left="a[l];}' ) +unset _ALTTAB_PARAMS +case "${left}${right}" in + yesyes) + printf '%s\n' "Using left yes, right yes" + _ALTTAB_PARAMS="${ALTTAB_LEFTYES_RIGHTYES}" + ;; + noyes) + printf '%s\n' "Using left no, right yes" + _ALTTAB_PARAMS="${ALTTAB_LEFTNO_RIGHTYES}" + ;; + yesno) + printf '%s\n' "Using left no, right yes" + _ALTTAB_PARAMS="${ALTTAB_LEFTNO_RIGHTYES}" + ;; + nono) + printf '%s\n' "Using left no, right no: UNSUPPORTED!" + _ALTTAB_PARAMS="${ALTTAB_LEFTNO_RIGHTNO}" + ;; + *) + printf '%s\n' "Unknown config: leftright \"${left}${right}\". Aborted." 1>&2 ; exit 1 + ;; +esac +test -n "${APPLY}" && { + test -n "${DEBUG}" && set -x + killall "${_ALTTAB_COMMAND_TO_KILL}" + # unquoted here: + ${ALTTAB_COMMON} ${_ALTTAB_PARAMS} & + set +x +} diff --git a/src/usr/share/man/man1/fix-alttab-daemon.1.txt b/src/usr/share/man/man1/fix-alttab-daemon.1.txt new file mode 100644 index 0000000..780f145 --- /dev/null +++ b/src/usr/share/man/man1/fix-alttab-daemon.1.txt @@ -0,0 +1,33 @@ +title fix-alttab-daemon +section 1 +project fix-alttab +volume General Commands Manual +date July 2023 +===== +NAME + fix-alttab-daemon - dynamically change where alttab displays based on available displays +SYNOPSIS + fix-alttab-daemon +OPTIONS + None +ENVIRONMENT + XDG_CONFIG_HOME is normally ~/.config, and determines where the per-user fix-alttab configuration file lives. +DESCRIPTION + This daemon loops over fix-alttab, an included script that performs the work of checking available monitors and then running alttab with various configs defined in the config file (normally ~/.config/fix-alttab or /etc/sysconfig/fix-alttab) + The point is to keep alttab within the viewable monitor area if I change inputs on one of my workstation monitors. +CONFIGURATION + These options are loaded from /etc/sysconfig/fix-alttab and then ~/.config/fix-alttab, so the last loaded value is used. + ALTTAB_DAEMON_LOOP how many seconds to sleep between each instance of checking the available displays. Default is 3. + ALTTAB_DAEMON_LOGFILE where to put logs. Default is "${XDG_RUNTIME_DIR}/fix-alttab-daemon.log" + ALTTAB_COMMON is the base command and any parameters to run. The first word of this value is the binary name that will be killalled if the alttab daemon needs to be restarted. Default is "alttab -w 1 -theme numix-circle" + The next four options are related to which monitors/X11 displays are available, and what options to pass to alttab when restarting it. + ALTTAB_LEFTYES_RIGHTYES "" + ALTTAB_LEFTNO_RIGHTYES "-vp 1920x1080+1920+0" which is the X11 geometry for this -vp options of alttab, which means that the maximum possible display screen for the alttab program is a 1920x1080-sized box, starting at pixel 1920,0, so my right monitor in a basic side-by-side organization. +AUTHOR + B. Stack <bgstack15@gmail.com> +COPYRIGHT + GPL 3.0 +SEE ALSO + `fix-alttab(1)` +BUGS + Report any anomalies to the author. diff --git a/src/usr/share/man/man1/fix-alttab.1.txt b/src/usr/share/man/man1/fix-alttab.1.txt new file mode 100644 index 0000000..233a793 --- /dev/null +++ b/src/usr/share/man/man1/fix-alttab.1.txt @@ -0,0 +1,33 @@ +title fix-alttab +section 1 +project fix-alttab +volume General Commands Manual +date July 2023 +===== +NAME + fix-alttab - check active monitors and re-run alttab if different from before +SYNOPSIS + fix-alttab +OPTIONS + None +ENVIRONMENT + XDG_CONFIG_HOME is normally ~/.config, and determines where the per-user fix-alttab configuration file lives. + APPLY If 1, then actually re-run `alttab(1)` with the parameters in the config file. +DESCRIPTION + This is the main logic to react to current monitor status. that performs the work of checking available monitors and then running alttab with various configs defined in the config file (normally ~/.config/fix-alttab or /etc/sysconfig/fix-alttab) + The point is to keep alttab within the viewable monitor area if I change inputs on one of my workstation monitors. + Run this with `APPLY` unset, to print which monitors it detects. Then run with `APPLY=1` to re-run alttab. +CONFIGURATION + These options are loaded from /etc/sysconfig/fix-alttab and then ~/.config/fix-alttab, so the last loaded value is used. + ALTTAB_COMMON is the base command and any parameters to run. The first word of this value is the binary name that will be killalled if the alttab daemon needs to be restarted. Default is "alttab -w 1 -theme numix-circle" + The next four options are related to which monitors/X11 displays are available, and what options to pass to alttab when restarting it. + ALTTAB_LEFTYES_RIGHTYES "" + ALTTAB_LEFTNO_RIGHTYES "-vp 1920x1080+1920+0" which is the X11 geometry for this -vp options of alttab, which means that the maximum possible display screen for the alttab program is a 1920x1080-sized box, starting at pixel 1920,0, so my right monitor in a basic side-by-side organization. +AUTHOR + B. Stack <bgstack15@gmail.com> +COPYRIGHT + GPL 3.0 +SEE ALSO + `fix-alttab-daemon(1)` +BUGS + Report any anomalies to the author. |