usr

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

commit 820c2267c67e942732c81b6462bcc2d6eaab7c41
parent bd6ebb9b43f866dbef943bf5c42143d0da6a7beb
Author: Theo Henson <[email protected]>
Date:   Sun, 15 Nov 2020 17:54:58 -0500

Change python, improve curling, create theo_dirs

Diffstat:
Mhome/.config/python/rc.py | 11+++++++++--
Ahome/av/wall/bg1.jpg | 0
Ahome/av/wall/bg2.jpg | 0
Mmodules/mod.list | 1+
Amodules/theo_dirs.mod.sh | 45+++++++++++++++++++++++++++++++++++++++++++++
Musr | 14++++++--------
6 files changed, 61 insertions(+), 10 deletions(-)

diff --git a/home/.config/python/rc.py b/home/.config/python/rc.py @@ -2,8 +2,15 @@ import os import atexit import readline -# get .python_history outta ~! -histfile = os.path.join(os.path.expanduser("~"), ".local/share/python_history") +# get .python_history out of home directory: +base = "" +try: + base = os.environ['XDG_CACHE_HOME'] +except KeyError: + base = os.path.join(os.path.expanduser("~"), ".cache") + +histfile = os.path.join(base, "python_history") + try: readline.read_history_file(histfile) readline.set_history_length(1000) diff --git a/home/av/wall/bg1.jpg b/home/av/wall/bg1.jpg Binary files differ. diff --git a/home/av/wall/bg2.jpg b/home/av/wall/bg2.jpg Binary files differ. diff --git a/modules/mod.list b/modules/mod.list @@ -1,3 +1,4 @@ test +theo_dirs theo_dotfiles theo_scripts diff --git a/modules/theo_dirs.mod.sh b/modules/theo_dirs.mod.sh @@ -0,0 +1,45 @@ +# theo_dirs module + +: "${XDG_CACHE_HOME:=$HOME/.cache}" +: "${XDG_DATA_HOME:=$HOME/.local/share}" + +theo_dirs_add() { + printf "theo_dirs: creating directories\n" + mkdir -p "$HOME"/av/wall + mkdir -p "$HOME"/av/scrot + mkdir -p "$HOME"/docs + mkdir -p "$HOME"/src/git/aur + mkdir -p "$HOME"/src/git/ghw + mkdir -p "$HOME"/src/git/ghf + mkdir -p "$HOME"/src/git/ghf + mkdir -p "$XDG_DATA_HOME"/pub + printf "theo_dirs: linking some wallpapers\n" + ln -sf "$USR_DIR"/home/av/wall/bg1.jpg "$HOME"/av/wall/bg1.jpg + ln -sf "$USR_DIR"/home/av/wall/bg2.jpg "$HOME"/av/wall/bg2.jpg +} + +theo_dirs_remove() { + printf "theo_dirs: removing directories\n" + rmdir "$HOME"/av/wall + rmdir "$HOME"/av/scrot + rmdir "$HOME"/av + rmdir "$HOME"/docs + rmdir "$HOME"/src/git/aur + rmdir "$HOME"/src/git/ghw + rmdir "$HOME"/src/git/ghf + rmdir "$HOME"/src/git + rmdir "$HOME"/src + rmdir "$XDG_DATA_HOME"/pub +} + +theo_dirs_info() { + printf "Creates directories I (theo) like to have in ~.\n" +} + +theo_dirs_dirs() { + printf "av/wall" +} + +theo_dirs_files() { + printf "av/wall/bg1.jpg av/wall/bg2.jpg" +} diff --git a/usr b/usr @@ -14,7 +14,7 @@ die() { [ "$(id -u)" = 0 ] && die "usr: do not run as root" -: "${USR_DIR:=$HOME/src/git/usr}" +: "${USR_DIR:=$HOME/src/usr}" # create directories mkdir -p "$USR_DIR"/var @@ -123,11 +123,9 @@ prep_module() { BASE_URL=$(cat "$USR_DIR"/var/remote) for FILE in $("$MOD"_files) ; do - if ! [ -f "$USR_DIR/home/$FILE" ] ; then - URL="$BASE_URL"home/"$FILE" - printf "usr: getting %s\n" "$URL" - printf "url = %s" "$URL" | curl -sLf -o "$USR_DIR/home/$FILE" -K - || die "usr: error getting $USR_DIR/home/$FILE" & - fi + URL="$BASE_URL"home/"$FILE" + printf "usr: getting %s\n" "$URL" + printf "url = %s" "$URL" | curl -sLf -o "$USR_DIR/home/$FILE" -K - || die "usr: error getting $USR_DIR/home/$FILE" & done while : ; do @@ -138,8 +136,8 @@ prep_module() { fi done - if [ "$COUNT" -ne $("$MOD"_files | wc -w) ] ; then - printf "usr: waiting for curl jobs to finish [%s/%s]\n" "$COUNT" $("$MOD"_files | wc -w) + printf "usr: waiting for curl jobs to finish [%s/%s]\n" "$COUNT" "$("$MOD"_files | wc -w)" + if [ "$COUNT" -ne "$("$MOD"_files | wc -w)" ] ; then sleep 0.5 else break