commit 4ea970fd4b8e85daa6d4d0be3f2f926e6e9e5a65 parent 8342d8733baf67d9342e56e5b23f83c0367d16ad Author: Jacob R. Edwards <jacobouno@protonmail.com> Date: Thu, 18 Feb 2021 11:12:19 -0800 Update style and language of the svt script It is now written in sh(1) and uses to new header format. Diffstat:
| M | local/scripts/.local/bin/svt | | | 32 | ++++++++++++++++++-------------- |
1 file changed, 18 insertions(+), 14 deletions(-)
diff --git a/local/scripts/.local/bin/svt b/local/scripts/.local/bin/svt @@ -1,17 +1,21 @@ -#!/usr/local/bin/rc -e -#! svt -- switch virtual terminals -#! -#! If no argument is given the previous vt is focused, otherwise the -#! given the arguments are taken as a display identifier and you are -#! focused on that. +#!/bin/sh -e +# Copyright 2020 Jacob R. Edwards +# License: GPLv3 +# +# svt -- unportably switch virtual terminals +# +# Switch to the virtual terminal specified by the arguments if +# given, otherwise switch to the previously focused. -if (test -n $XDG_CACHE_HOME) - XDG_CACHE_HOME = $HOME^/.cache; -CACHE = $XDG_CACHE_HOME^/`{ basename $0 } +state="${XDG_CACHE_HOME:-$HOME/.cache}/svt" -fn cache { wsconsctl -n display.focus >$CACHE } -fn focus { cache && wsconsctl 'display.focus='^$* >/dev/null } +focus() { + wsconsctl -n display.focus >"$state" + wsconsctl display.focus="$@" >/dev/null +} -if (test $#* -eq 0) { - focus `{ cat <$CACHE } -} else focus $* +if test $# -eq 0; then + focus $(cat "$state") +else + focus "$@" +fi