usr

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

commit 5ea864df46d739a00a33f9083511d9da6cf266d7
parent 480fdb1a1a8fcee1c3097363e0d470427a0387ff
Author: Theo Henson <[email protected]>
Date:   Sun, 15 Nov 2020 16:47:01 -0500

Improve modules, improve prep_modules, create .profile

Diffstat:
Mhome/.bash_profile | 64+---------------------------------------------------------------
Ahome/.profile | 63+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Mmodules/test.mod.sh | 8++++----
Mmodules/theo_dotfiles.mod.sh | 2+-
Amodules/theo_scripts.mod.sh | 27+++++++++++++++++++++++++++
Musr | 16++++++++++++++++
6 files changed, 112 insertions(+), 68 deletions(-)

diff --git a/home/.bash_profile b/home/.bash_profile @@ -1,66 +1,4 @@ -# base directories -export XDG_CONFIG_HOME="$HOME/.config" -export XDG_DATA_HOME="$HOME/.local/share" -export XDG_CACHE_HOME="$HOME/.cache" - -# these are used in ~/.config/user-dirs.dirs to set locations -export XDG_DESKTOP_DIR="/home/theo" -export XDG_DOCUMENTS_DIR="/home/theo/docs" -export XDG_DOWNLOAD_DIR="/home/theo" -export XDG_MUSIC_DIR="/home/theo/av" -export XDG_PICTURES_DIR="/home/theo/av" -export XDG_PUBLICSHARE_DIR="/home/theo/.local/share/pub" -export XDG_TEMPLATES_DIR="/home/theo/docs" -export XDG_VIDEOS_DIR="/home/theo/av" - -# more envs -export BIN="$HOME/.local/bin" -export SCRIPTS="$HOME/src/git/scripts" -export GOPATH="$XDG_DATA_HOME/go" - -# set some default programs -export VISUAL=/usr/bin/nvim -export EDITOR=/usr/bin/nvim -export TERMINAL=/usr/local/bin/st -export BROWSER=/usr/bin/firefox -export READER=/usr/bin/zathura - -# clean up ~ -export SEST_DIR="$XDG_DATA_HOME/sest" -export LESSHISTFILE="-" -export HISTFILE="$XDG_CACHE_HOME/bash_history" -export CARGO_HOME="$XDG_DATA_HOME/cargo" -export GTK2_RC_FILES="$XDG_CONFIG_HOME/gtk-2.0/gtkrc-2.0" -export _JAVA_OPTIONS="-Djava.util.prefs.userRoot=$XDG_CONFIG_HOME/java" -export PYTHONSTARTUP="$XDG_CONFIG_HOME/python/rc.py" -export NPM_CONFIG_USERCONFIG="$XDG_CONFIG_HOME/npm/npmrc" -export RANDFILE="$XDG_DATA_HOME/rnd" -export PYLINTHOME="$XDG_CACHE_HOME/pylint" -export GEM_HOME="$XDG_DATA_HOME/gem" -export GEM_SPEC_CACHE="$XDG_CACHE_HOME/gem" -export RUSTUP_HOME="$XDG_DATA_HOME/rustup" -export WGETRC="$XDG_CONFIG_HOME/wgetrc" -export WINEPREFIX="$XDG_DATA_HOME/wineprefixes/default" -export DENO_DIR="$XDG_DATA_HOME/deno" -export DENO_INSTALL_ROOT="$XDG_DATA_HOME/deno/bin" -export VSCODE_PORTABLE="$XDG_DATA_HOME/vscode" -export CCACHE_CONFIGPATH="$XDG_CONFIG_HOME/ccache.config" -export CCACHE_DIR="$XDG_CACHE_HOME/ccache" -export PSQL_HISTORY="$XDG_CACHE_HOME/pg/psql_history" -export XAUTHORITY="$XDG_RUNTIME_DIR/Xauthority" -export GNUPGHOME="$XDG_DATA_HOME/gnupg" -export IPYTHONDIR="$XDG_CONFIG_HOME"/ipython -export JUPYTER_CONFIG_DIR="$XDG_CONFIG_HOME"/jupyter -export TEXMFHOME=$XDG_DATA_HOME/texmf -export TEXMFVAR=$XDG_CACHE_HOME/texlive/texmf-var -export TEXMFCONFIG=$XDG_CONFIG_HOME/texlive/texmf-config - -# things for mitchweaver/subs -export SUBS_FILE="$XDG_DOCUMENTS_DIR/subs.list" -export SUBS_MENU_PROG="fzf --no-sort -e --color=16" - -# add directories to path -export PATH="$SCRIPTS:$BIN:$CARGO_HOME/bin:$GOPATH/bin:$DENO_INSTALL_ROOT:$PATH" +source $HOME/.profile if [[ -z $DISPLAY ]] ; then diff --git a/home/.profile b/home/.profile @@ -0,0 +1,63 @@ +# base directories +export XDG_CONFIG_HOME="$HOME/.config" +export XDG_DATA_HOME="$HOME/.local/share" +export XDG_CACHE_HOME="$HOME/.cache" + +# these are used in ~/.config/user-dirs.dirs to set locations +export XDG_DESKTOP_DIR="/home/theo" +export XDG_DOCUMENTS_DIR="/home/theo/docs" +export XDG_DOWNLOAD_DIR="/home/theo" +export XDG_MUSIC_DIR="/home/theo/av" +export XDG_PICTURES_DIR="/home/theo/av" +export XDG_PUBLICSHARE_DIR="/home/theo/.local/share/pub" +export XDG_TEMPLATES_DIR="/home/theo/docs" +export XDG_VIDEOS_DIR="/home/theo/av" + +# more envs +export BIN="$HOME/.local/bin" +export OPT_BIN="$BIN/opt" +export GOPATH="$XDG_DATA_HOME/go" + +# set some default programs +export VISUAL=/usr/bin/nvim +export EDITOR=/usr/bin/nvim +export TERMINAL=/usr/local/bin/st +export BROWSER=/usr/bin/firefox +export READER=/usr/bin/zathura + +# clean up ~ +export SEST_DIR="$XDG_DATA_HOME/sest" +export LESSHISTFILE="-" +export HISTFILE="$XDG_CACHE_HOME/bash_history" +export CARGO_HOME="$XDG_DATA_HOME/cargo" +export GTK2_RC_FILES="$XDG_CONFIG_HOME/gtk-2.0/gtkrc-2.0" +export _JAVA_OPTIONS="-Djava.util.prefs.userRoot=$XDG_CONFIG_HOME/java" +export PYTHONSTARTUP="$XDG_CONFIG_HOME/python/rc.py" +export NPM_CONFIG_USERCONFIG="$XDG_CONFIG_HOME/npm/npmrc" +export RANDFILE="$XDG_DATA_HOME/rnd" +export PYLINTHOME="$XDG_CACHE_HOME/pylint" +export GEM_HOME="$XDG_DATA_HOME/gem" +export GEM_SPEC_CACHE="$XDG_CACHE_HOME/gem" +export RUSTUP_HOME="$XDG_DATA_HOME/rustup" +export WGETRC="$XDG_CONFIG_HOME/wgetrc" +export WINEPREFIX="$XDG_DATA_HOME/wineprefixes/default" +export DENO_DIR="$XDG_DATA_HOME/deno" +export DENO_INSTALL_ROOT="$XDG_DATA_HOME/deno/bin" +export VSCODE_PORTABLE="$XDG_DATA_HOME/vscode" +export CCACHE_CONFIGPATH="$XDG_CONFIG_HOME/ccache.config" +export CCACHE_DIR="$XDG_CACHE_HOME/ccache" +export PSQL_HISTORY="$XDG_CACHE_HOME/pg/psql_history" +export XAUTHORITY="$XDG_RUNTIME_DIR/Xauthority" +export GNUPGHOME="$XDG_DATA_HOME/gnupg" +export IPYTHONDIR="$XDG_CONFIG_HOME"/ipython +export JUPYTER_CONFIG_DIR="$XDG_CONFIG_HOME"/jupyter +export TEXMFHOME=$XDG_DATA_HOME/texmf +export TEXMFVAR=$XDG_CACHE_HOME/texlive/texmf-var +export TEXMFCONFIG=$XDG_CONFIG_HOME/texlive/texmf-config + +# things for mitchweaver/subs +export SUBS_FILE="$XDG_DOCUMENTS_DIR/subs.list" +export SUBS_MENU_PROG="fzf --no-sort -e --color=16" + +# add directories to path +export PATH="$OPT_BIN:$BIN:$GOPATH/bin:$CARGO_HOME/bin:$DENO_INSTALL_ROOT:$PATH" diff --git a/modules/test.mod.sh b/modules/test.mod.sh @@ -1,16 +1,16 @@ # test module test_add() { - printf "test: linking \$HOME/.test\n" + printf "test: linking %s/.test\n" "$HOME" ln -sf "$USR_DIR/home/.test" "$HOME/.test" - printf "test: linking \$HOME/.test-dir\n" + printf "test: linking %s/.test-dir\n" "$HOME" ln -sf "$USR_DIR/home/.test-dir" "$HOME/.test-dir" } test_remove() { - printf "test: removing \$HOME/.test\n" + printf "test: removing %s/.test\n" "$HOME" rm "$HOME/.test" - printf "test: removing \$HOME/.test-dir\n" + printf "test: removing %s/.test-dir\n" "$HOME" rm "$HOME/.test-dir" } diff --git a/modules/theo_dotfiles.mod.sh b/modules/theo_dotfiles.mod.sh @@ -44,7 +44,7 @@ theo_dotfiles_dirs() { } theo_dotfiles_files() { - printf ".bashrc .xinitrc .vim/vimrc .bash_profile $CONFIG_DIR/wgetrc + printf ".profile .bashrc .xinitrc .vim/vimrc .bash_profile $CONFIG_DIR/wgetrc $CONFIG_DIR/npm/npmrc $CONFIG_DIR/git/config $CONFIG_DIR/mpv/mpv.conf $CONFIG_DIR/python/rc.py $CONFIG_DIR/sxhkd/sxhkdrc $CONFIG_DIR/dunst/dunstrc $CONFIG_DIR/nvim/init.vim $CONFIG_DIR/X11/Xresources $CONFIG_DIR/mpv/input.conf diff --git a/modules/theo_scripts.mod.sh b/modules/theo_scripts.mod.sh @@ -0,0 +1,27 @@ +# theo_scripts module + +theo_scripts_add() { + printf "theo_scripts: linking %s/.local/bin/opt\n" "$HOME" + ln -sf "$USR_DIR"/home/.local/bin/opt "$HOME"/.local/bin/opt +} + +theo_scripts_remove() { + printf "theo_scripts: removing %s/.local/bin/opt\n" "$HOME" + rm "$HOME"/.local/bin/opt +} + +theo_scripts_information() { + printf "Contains some scripts I (theo) made and use.\n" +} + +theo_scripts_dirs() { + printf ".local/bin/opt" +} + +theo_scripts_files() { + printf ".local/bin/opt/aur .local/bin/opt/autorss .local/bin/opt/cpusage + .local/bin/opt/git_status_prompt .local/bin/opt/lock .local/bin/opt/lsearch + .local/bin/opt/openup .local/bin/opt/randwall .local/bin/opt/runt + .local/bin/opt/spt-mute.sh .local/bin/opt/spt-vol.sh .local/bin/opt/time_bar + .local/bin/opt/volume_bar" +} diff --git a/usr b/usr @@ -129,6 +129,22 @@ prep_module() { printf "url = %s" "$URL" | curl -sLf -o "$USR_DIR/home/$FILE" -K - || die "usr: error getting $USR_DIR/home/$FILE" & fi done + + while : ; do + COUNT=0 + for FILE in $("$MOD"_files) ; do + if [ -f "$USR_DIR/home/$FILE" ] ; then + : "$((COUNT = COUNT + 1))" + fi + done + + if [ $COUNT -ne $("$MOD"_files | wc -w) ] ; then + printf "usr: waiting for curl jobs to finish [%s/%s]" "$COUNT" $("$MOD"_files | wc -w) + sleep 0.5 + else + break + fi + done } list_modules() {