aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Jonas Gunz <himself@jonasgunz.de> 2023-03-27 15:24:57 +0200
committerGravatar Jonas Gunz <himself@jonasgunz.de> 2023-03-27 15:24:57 +0200
commit9fb37a7cfb5fe48c0b43ef29d1b18b482e53082a (patch)
treebbe095e6360f5b2d655f1f1bbf3c3086407dc226
parentc8a12c61bc9694d4f6538d47ab317c5122b648ee (diff)
parent0e24383d706a91bc9536b1c0827e4209679ce009 (diff)
downloaddotfiles-9fb37a7cfb5fe48c0b43ef29d1b18b482e53082a.tar.gz
Merge branch 'master' of git.jonasgunz.de:repos/dotfiles
-rwxr-xr-xinstall.sh23
-rw-r--r--lib/funcs.sh14
-rw-r--r--lib/hooks.sh13
-rw-r--r--sets.csv5
4 files changed, 32 insertions, 23 deletions
diff --git a/install.sh b/install.sh
index e0dbff0..75f4c3c 100755
--- a/install.sh
+++ b/install.sh
@@ -9,8 +9,6 @@ function fail(){
WORKDIR=$(realpath "$(dirname "$0")")
cd "$WORKDIR" || fail 1 "The working directory could not be determined."
-echo "Working in $WORKDIR"
-echo "Homedir is $HOME"
# For hooks
export WORKDIR
@@ -21,6 +19,9 @@ for f in lib/*.sh; do
source "$f" || fail 1 "Failed to load $f"
done
+debug "Working in $WORKDIR"
+debug "Homedir is $HOME"
+
if [ ! -f "config.csv" ] || [ ! -f "sets.csv" ]; then
# TODO Create them
fail 1 "Configuration files do not exist"
@@ -41,17 +42,7 @@ done < sets.csv
unset SET PKGS
if [ $# -eq 0 ]; then
- cat << EOF
-USAGE: $0 COMMAND [ARGS]
-COMMANDS
- install [CONFIG ...]
- install configurations. if none are provided,
- a selection menu is showm.
- add PATH
- Add PATH to managed configs
- hook HOOK
- manually call a hook
-EOF
+ print_help "$0"
exit 1
fi
@@ -84,10 +75,10 @@ case $CMD in
cp -r "$1" ./ || fail 1 "Failed to copy configuration"
echo "$NAME;$RELPATH" >> config.csv
- # This would need a reload
- #choose_target "$NAME"
- echo "Config was isntalled successfully."
+ call_hook post_add "$NAME" "$TARGET"
+
+ echo "Config was installed successfully."
echo "It can now be installed with $0 install $NAME"
echo "The following files were changed: config.csv $NAME"
;;
diff --git a/lib/funcs.sh b/lib/funcs.sh
index 585c4aa..66786a0 100644
--- a/lib/funcs.sh
+++ b/lib/funcs.sh
@@ -114,3 +114,17 @@ debug() {
warning() {
echo "[WARNING] $@"
}
+
+print_help() {
+ cat << EOF
+USAGE: $1 COMMAND [ARGS]
+COMMANDS
+ install [CONFIG ...]
+ install configurations. if none are provided,
+ a selection menu is showm.
+ add PATH
+ Add PATH to managed configs
+ hook HOOK
+ manually call a hook
+EOF
+}
diff --git a/lib/hooks.sh b/lib/hooks.sh
index 8d5fc1d..2256914 100644
--- a/lib/hooks.sh
+++ b/lib/hooks.sh
@@ -2,17 +2,20 @@
# 1: Name of hook
call_hook() {
- if [ ! -x "hooks/$1.hook" ]; then
- debug "$1.hook was not found. Skipping."
+ local HOOK="$1"
+ shift
+
+ if [ ! -x "hooks/$HOOK.hook" ]; then
+ debug "$HOOK.hook was not found. Skipping."
return
fi
- debug "Running hook $1"
+ debug "Running hook $HOOK"
- hooks/$1.hook 2>&1 | (while read line; do echo [hook: $1] $line; done)
+ hooks/$HOOK.hook 2>&1 | (while read line; do echo [hook: $HOOK] $line; done)
RET=${PIPESTATUS[0]}
if [ $RET -ne 0 ]; then
- warning "Hook $1 exitet with code $RET"
+ warning "Hook $HOOK exitet with code $RET"
fi
}
diff --git a/sets.csv b/sets.csv
index b3d8ad0..c7415a8 100644
--- a/sets.csv
+++ b/sets.csv
@@ -1,2 +1,3 @@
-base;.vim .bashrc .bash_profile
-desktop;base termite picom i3 deadd polybar .xinitrc .Xresources
+base;.vim .bashrc .bash_profile .screenrc
+i3;base termite picom i3 deadd polybar .xinitrc .Xresources
+sway;base sway waybar alacritty