usr

Modulate your userpace into POSIX-compliant shell scripts!
git clone git://clone.theohenson.com/usr.git
Log | Files | Refs | README

commit 800660b1dcdcde5e8442511f0f5a7219987f3788
parent bade87b2de16cfba91cceda1ce3a89a53c66d89b
Author: Theo Henson <[email protected]>
Date:   Sun, 15 Nov 2020 01:03:39 -0500

Create usr and modules

Diffstat:
M.gitignore | 1+
AMakefile | 14++++++++++++++
MREADME.md | 4++++
Dhome/README.md | 9---------
Rhome/deploy.sh -> modules/dotfiles.mod.sh | 0
Amodules/test.mod.sh | 15+++++++++++++++
Ausr | 78++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
7 files changed, 112 insertions(+), 9 deletions(-)

diff --git a/.gitignore b/.gitignore @@ -1,4 +1,5 @@ *.o +installed/ home/src/suk/st/st home/src/suk/dwm/dwm home/src/suk/dwmblocks/dwmblocks diff --git a/Makefile b/Makefile @@ -0,0 +1,14 @@ +PREFIX=/usr/local +NAME=usr + +all: + @>&2 echo "use 'make install'" + +install: + install -D -m 0755 ${NAME} ${DESTDIR}${PREFIX}/bin/${NAME} + +uninstall: + rm ${DESTDIR}${PREFIX}/bin/${NAME} + +test: + shellcheck -s sh ${NAME} modules/test.mod.sh diff --git a/README.md b/README.md @@ -2,6 +2,8 @@ My dotfiles + more, and some tools to manage them. +Work in progress. + ## .local/bin/opt Some scripts I've made, which are all licensed under the Unlicense. @@ -45,4 +47,6 @@ Upstream: [github.com/torrinfail/dwmblocks](https://github.com/torrinfail/dwmblo I've added my own blocks in `blocks.h` which use some scripts I made. +## Gallery + ![Screenshot of my desktop](https://raw.githubusercontent.com/tteeoo/usr/main/scrot.png) diff --git a/home/README.md b/home/README.md @@ -1,9 +0,0 @@ -# dotfiles - -My Arch (now technically Artix) Linux configuration files. - -Mainly for backup/archival purposes, but you can use them if you want. - -See [sainnhe/gruvbox-material-gtk](https://github.com/sainnhe/gruvbox-material-gtk) for my gtk themes. - -See [tteeoo/suckless](https://github.com/tteeoo/suckless) for my window manager and terminal. diff --git a/home/deploy.sh b/modules/dotfiles.mod.sh diff --git a/modules/test.mod.sh b/modules/test.mod.sh @@ -0,0 +1,15 @@ +# test module + +test_add() { + printf "creating \$HOME/test\n" + touch "$HOME/test" +} + +test_remove() { + printf "removing \$HOME/test\n" + rm "$HOME/test" +} + +test_info() { + printf "information about the test module\n" +} diff --git a/usr b/usr @@ -0,0 +1,78 @@ +#!/bin/sh + +set -e + +: "${USR_DIR:=$HOME/src/git/usr}" + +mkdir -p "$USR_DIR"/modules +mkdir -p "$USR_DIR"/installed + +die() { + >&2 printf "%s\n" "$*" + exit 1 +} + +usage() { + die "usage: usr [-a <module>] [-r <module>] [-i <module>] [-l]" +} + +module_add() { + MOD="$2" + MOD_FILE="$USR_DIR/modules/$MOD".mod.sh + MOD_INSTALL="$USR_DIR/installed/$MOD" + + [ -e "$MOD_INSTALL" ] && die "$MOD is already installed" + [ -z "$MOD" ] && usage + + # shellcheck source=modules/test.mod.sh + . "$MOD_FILE" + + "$MOD"_add + + touch "$MOD_INSTALL" +} + +module_remove() { + MOD="$2" + MOD_FILE="$USR_DIR/modules/$MOD".mod.sh + MOD_INSTALL="$USR_DIR/installed/$MOD" + + [ -e "$MOD_INSTALL" ] || die "$MOD is not installed" + [ -z "$MOD" ] && usage + + # shellcheck source=modules/test.mod.sh + . "$MOD_FILE" + + "$MOD"_remove + + rm "$MOD_INSTALL" +} + +module_info() { + MOD="$2" + MOD_FILE="$USR_DIR/modules/$MOD".mod.sh + + [ -z "$MOD" ] && usage + + # shellcheck source=modules/test.mod.sh + . "$MOD_FILE" + + "$MOD"_info +} + +list_modules() { + for MOD in "$USR_DIR"/modules/*; do + [ -f "$MOD" ] && printf "%s\n" "$MOD" + done +} + +case ${1#-} in + h) usage ;; + a) module_add "[email protected]" ;; + r) module_remove "[email protected]" ;; + i) module_info "[email protected]" ;; + l) list_modules ;; + *) usage ;; +esac + +exit 0