usr

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

commit a55c3aa0c1eae7fc5a4641727cc2e58f1b5935bc
parent 452095616e585409e5c3937d8fd9ff4006c59a2d
Author: Theo Henson <[email protected]>
Date:   Sun, 15 Nov 2020 15:12:35 -0500

Update modules

Diffstat:
MMakefile | 2+-
Dmodules/dotfiles.mod.sh | 56--------------------------------------------------------
Mmodules/mod.list | 2+-
Mmodules/test.mod.sh | 4++--
Amodules/theo_dotfiles.mod.sh | 49+++++++++++++++++++++++++++++++++++++++++++++++++
Musr | 4++++
6 files changed, 57 insertions(+), 60 deletions(-)

diff --git a/Makefile b/Makefile @@ -11,4 +11,4 @@ uninstall: rm ${PREFIX}/bin/${NAME} test: - shellcheck -s sh ${NAME} modules/test.mod.sh + shellcheck -s sh ${NAME} modules/*.mod.sh diff --git a/modules/dotfiles.mod.sh b/modules/dotfiles.mod.sh @@ -1,56 +0,0 @@ -#!/bin/sh - -link () { - ln -sf $(pwd)/$1 $HOME/$1 -} - -mkd () { - mkdir $XDG_DATA_HOME/wineprefixes -p - mkdir $XDG_CONFIG_HOME/discocss -p - mkdir $XDG_CONFIG_HOME/fish -p - # mkdir $XDG_CONFIG_HOME/spotifyd - mkdir $XDG_CONFIG_HOME/spotify-tui - mkdir $XDG_CONFIG_HOME/newsboat - mkdir $XDG_CONFIG_HOME/gtk-3.0 - mkdir $XDG_CONFIG_HOME/gtk-2.0 - mkdir $XDG_CONFIG_HOME/python - mkdir $XDG_CONFIG_HOME/picom - mkdir $XDG_CONFIG_HOME/sxhkd - mkdir $XDG_CONFIG_HOME/dunst - mkdir $XDG_CONFIG_HOME/nvim - mkdir $XDG_CONFIG_HOME/rco - mkdir $XDG_CONFIG_HOME/git - mkdir $XDG_CONFIG_HOME/mpv - mkdir $XDG_CONFIG_HOME/npm - mkdir $XDG_CONFIG_HOME/X11 - mkdir $HOME/.vim -} - -mkd 2> /dev/null - -link .bashrc -link .xinitrc -link .vim/vimrc -link .bash_profile -link .config/wgetrc -link .config/npm/npmrc -link .config/git/config -link .config/mpv/mpv.conf -link .config/python/rc.py -link .config/sxhkd/sxhkdrc -link .config/dunst/dunstrc -link .config/nvim/init.vim -link .config/X11/Xresources -link .config/mpv/input.conf -link .config/newsboat/config -link .config/rco/config.csv -link .config/rco/objects.csv -link .config/picom/picom.conf -link .config/fish/config.fish -link .config/gtk-2.0/gtkrc-2.0 -link .config/fish/fish_variables -link .config/gtk-3.0/settings.ini -link .config/spotify-tui/config.yml -link .config/nvim/coc-settings.json -# link .config/spotifyd/spotifyd.conf -link .config/discocss/custom.css diff --git a/modules/mod.list b/modules/mod.list @@ -1,2 +1,2 @@ -dotfiles test +theo_dotfiles diff --git a/modules/test.mod.sh b/modules/test.mod.sh @@ -19,9 +19,9 @@ test_info() { } test_dirs() { - printf ".test-dir\n" + printf ".test-dir" } test_files() { - printf ".test\n.test-dir/1\n.test-dir/2" + printf ".test .test-dir/1 .test-dir/2" } diff --git a/modules/theo_dotfiles.mod.sh b/modules/theo_dotfiles.mod.sh @@ -0,0 +1,49 @@ +# theo_dotfiles module + +: "${XDG_DATA_HOME:=$HOME/.local/share}" +DATA_DIR="${XDG_DATA_HOME#$HOME/}" + +: "${XDG_CONFIG_HOME:=$HOME/.config}" +CONFIG_DIR="${XDG_CONFIG_HOME#$HOME/}" + +theo_dotfiles_add() { + while read -r FILE ; do + [ -f "$HOME/$FILE" ] && mv "$HOME/$FILE" "$HOME/$FILE".orig && \ + printf "theo_dotfiles: moving %s/%s to %s/%s.orig" "$HOME" "$FILE" "$HOME" "$FILE" + ln -sf "$USR_DIR/home/$FILE" "$HOME/$FILE" && \ + printf "theo_dotfiles: linking %s/home/%s to %s/%s" "$USR_DIR" "$FILE" "$HOME" "$FILE" + done <$(theo_dotfiles_files) +} + +theo_dotfiles_remove() { + while read -r FILE ; do + rm "$HOME/$FILE" && \ + printf "theo_dotfiles: removing %s/%s" "$HOME" "$FILE" + [ -f "$HOME/$FILE".orig ] && mv "$HOME/$FILE".orig "$HOME/$FILE" && \ + printf "theo_dotfiles: moving %s/%s.orig to %s/%s" "$HOME" "$FILE" "$HOME" "$FILE" + done <$(theo_dotfiles_files) +} + +theo_dotfiles_info() { + printf "This module contains my (theo's) dotfiles." +} + +theo_dotfiles_dirs() { + printf "$DATA_DIR/wineprefixes $CONFIG_DIR/discocss $CONFIG_DIR/fish + $CONFIG_DIR/spotify-tui $CONFIG_DIR/newsboat $CONFIG_DIR/gtk-3.0 + $CONFIG_DIR/gtk-2.0 $CONFIG_DIR/python $CONFIG_DIR/picom $CONFIG_DIR/sxhkd + $CONFIG_DIR/dunst $CONFIG_DIR/nvim $CONFIG_DIR/rco $CONFIG_DIR/git + $CONFIG_DIR/mpv $CONFIG_DIR/npm $CONFIG_DIR/X11 $HOME/.vim" +} + +theo_dotfiles_files() { + printf ".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 + $CONFIG_DIR/newsboat/config $CONFIG_DIR/rco/config.csv $CONFIG_DIR/rco/objects.csv + $CONFIG_DIR/picom/picom.conf $CONFIG_DIR/fish/config.fish $CONFIG_DIR/gtk-2.0/gtkrc-2.0 + $CONFIG_DIR/fish/fish_variables $CONFIG_DIR/gtk-3.0/settings.ini + $CONFIG_DIR/spotify-tui/config.yml $CONFIG_DIR/nvim/coc-settings.json + $CONFIG_DIR/discocss/custom.css" +} diff --git a/usr b/usr @@ -1,5 +1,9 @@ #!/bin/sh # licensed under the Unlicense +# TODO: +# - create more modules +# - force add/force remove +# - purge from home tree set -e