commit a7ef0d7feeb4c01ce93ae272ac07afdc1b4ef2d9 parent 739aa1aa7238e88648d0026033189f05bcd10b16 Author: Jacob R. Edwards <n/a> Date: Sun, 4 Dec 2022 19:48:08 -0600 Add apc wrapper This wrapper automatically starts and configures the server, but it's primary purpose is to provide a seperate namespace for aps related scripts. Diffstat:
| A | local/bin/bin/ap | | | 48 | ++++++++++++++++++++++++++++++++++++++++++++++++ |
| M | local/ksh/.profile | | | 7 | ------- |
2 files changed, 48 insertions(+), 7 deletions(-)
diff --git a/local/bin/bin/ap b/local/bin/bin/ap @@ -0,0 +1,48 @@ +#!/bin/sh +# Copyright 2022 Jacob R. Edwards +# Featureful apc wrapper +# +# Features: +# - Automatically start daemon if it's not running already +# - Configure daemon with an rc file on startup +# - Uniform interface between user scripts and server commands +# +# It's primary purpose is simply to provide a unique yet conveniently +# accessed namespace for writting apc scripts. (If only exec*p +# searched recursively.) + +set -e + +config="${XDG_CONFIG_HOME:-"$HOME"/.config}"/ap + +! test -S "${apsock:-/tmp/aps}" && { + aps + test -f "$config"/rc && + nocomment < "$config"/rc | apc +} + +commands() { + { + (cd "$config"/bin; find . -type f | stest -x | cut -c3-) + apc commands + } | sort -u +} + +test $# -lt 1 && { + echo 'error: No command +usage: ap command [arg ...]' 1>&2 + exit 1 +} +com="$(commands | fgrep -x "$1")" || { + echo "$1: Command not found" 1>&2 + exit 1 +} +shift + +if test "$com" = 'commands'; then + exec commands "$@" +elif test -x "$config"/bin/"$com"; then + exec "$config"/bin/"$com" "$@" +else + exec apc "$com" "$@" +fi diff --git a/local/ksh/.profile b/local/ksh/.profile @@ -40,11 +40,4 @@ then #font="$PLAN9"/font/misc/unicode.6x13.font fi -{ - aps && { - apc stop - shf < "$HOME"/music/playlists/general | apc add ^ - } -} 2>/dev/null - ENV="$XDG_CONFIG_HOME/kshrc"