summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile66
1 files changed, 40 insertions, 26 deletions
diff --git a/Makefile b/Makefile
index ad792da..3679c86 100644
--- a/Makefile
+++ b/Makefile
@@ -7,41 +7,55 @@ DOTFILES := $(shell pwd)/dotfiles
# Extract DE from command line (e.g., 'make stow dwm' -> DE=dwm)
DE := $(filter dwm hyprland,$(MAKECMDGOALS))
-.PHONY: help stow restow reset unstow import dwm hyprland
+# Extract DEST from command line for import (e.g., 'make import common' -> DEST=common)
+DEST := $(filter common dwm hyprland,$(MAKECMDGOALS))
+
+.PHONY: help stow restow reset unstow import common dwm hyprland
# Default target - show help
help:
@echo "Dotfiles Management (GNU Stow)"
@echo ""
- @echo "Usage: make <target> <de>"
+ @echo "Usage: make <target> <de|dest>"
@echo ""
- @echo "Desktop Environments:"
- @echo " dwm X11/DWM setup (stows: common + dwm)"
- @echo " hyprland Wayland/Hyprland setup (stows: common + hyprland)"
+ @echo "Desktop Environments / Destinations:"
+ @echo " common Shared configs (all setups)"
+ @echo " dwm X11/DWM specific"
+ @echo " hyprland Wayland/Hyprland specific"
@echo ""
@echo "Targets:"
- @echo " stow Create symlinks (fresh install)"
- @echo " restow Refresh symlinks (unlink + relink)"
- @echo " reset Resolve conflicts, keep repo version (adopt + git checkout)"
- @echo " unstow Remove all symlinks"
- @echo " import Import new app configs into repo (fzf selector)"
+ @echo " stow Create symlinks (fresh install) - requires DE"
+ @echo " restow Refresh symlinks (unlink + relink) - requires DE"
+ @echo " reset Resolve conflicts, keep repo version - requires DE"
+ @echo " unstow Remove all symlinks - requires DE"
+ @echo " import Import new app configs into repo (fzf) - requires dest"
@echo ""
@echo "Examples:"
- @echo " make stow dwm # Fresh DWM install"
- @echo " make stow hyprland # Fresh Hyprland install"
- @echo " make restow dwm # Refresh DWM links after git pull"
- @echo " make reset hyprland # Resolve conflicts, keep repo version"
- @echo " make import # Select configs to import (no DE needed)"
+ @echo " make stow dwm # Fresh DWM install (common + dwm)"
+ @echo " make stow hyprland # Fresh Hyprland install (common + hyprland)"
+ @echo " make restow dwm # Refresh DWM links after git pull"
+ @echo " make reset hyprland # Resolve conflicts, keep repo version"
+ @echo " make import common # Import configs to common/"
+ @echo " make import hyprland # Import configs to hyprland/"
@echo ""
-# Prevent 'dwm' and 'hyprland' from being treated as file targets
-dwm hyprland:
+# Prevent 'common', 'dwm' and 'hyprland' from being treated as file targets
+common dwm hyprland:
@:
-# Validate DE was provided
+# Validate DE was provided (for stow/restow/reset/unstow)
check-de:
ifeq ($(DE),)
- @echo "Error: Desktop environment required."
+ @echo "Error: Desktop environment required (dwm or hyprland)."
+ @echo ""
+ @$(MAKE) --no-print-directory help
+ @exit 1
+endif
+
+# Validate DEST was provided (for import)
+check-dest:
+ifeq ($(DEST),)
+ @echo "Error: Destination required (common, dwm, or hyprland)."
@echo ""
@$(MAKE) --no-print-directory help
@exit 1
@@ -78,14 +92,14 @@ unstow: check-de
@echo "Done."
# Import - select and import new app configs into repo
-import:
+import: check-dest
@echo "Select directories to import (Tab to multi-select, Enter to confirm):"
@echo ""
@selections=$$({ \
find $(HOME) -maxdepth 1 -mindepth 1 -name '.*' -type d 2>/dev/null | grep -v '\.cache\|\.local\|\.config' | sed 's|$(HOME)/||'; \
find $(HOME)/.config -maxdepth 1 -mindepth 1 -type d 2>/dev/null | sed 's|$(HOME)/||'; \
find $(HOME)/.local -maxdepth 2 -mindepth 1 -type d 2>/dev/null | sed 's|$(HOME)/||'; \
- } | sort -u | fzf --multi --prompt="Import> " --header="Select configs to import into dotfiles/common/"); \
+ } | sort -u | fzf --multi --prompt="Import to $(DEST)> " --header="Select configs to import into dotfiles/$(DEST)/"); \
if [ -z "$$selections" ]; then \
echo "No selections made."; \
exit 0; \
@@ -93,17 +107,17 @@ import:
echo ""; \
for dir in $$selections; do \
src="$(HOME)/$$dir"; \
- dest="$(DOTFILES)/common/$$dir"; \
+ dest="$(DOTFILES)/$(DEST)/$$dir"; \
if [ -d "$$dest" ]; then \
- echo "Skipping $$dir (already exists in dotfiles)"; \
+ echo "Skipping $$dir (already exists in dotfiles/$(DEST))"; \
else \
- echo "Importing $$dir..."; \
+ echo "Importing $$dir to $(DEST)..."; \
mkdir -p "$$(dirname $$dest)"; \
mv "$$src" "$$dest"; \
fi; \
done; \
echo ""; \
- echo "Restowing common..."; \
- cd $(DOTFILES) && $(STOW) --restow common; \
+ echo "Restowing $(DEST)..."; \
+ cd $(DOTFILES) && $(STOW) --restow $(DEST); \
echo ""; \
echo "Done. Don't forget to: git add -A && git commit"