SRC := $(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))

include ../lib/shared.mk
TARGET :=  $(XDG_DIR)/i3

install: | init update

init:
ifeq ($(call cmd_exist,i3), true)
	$(info => Setting up i3)
	$(mk_link) $(SRC) $(TARGET)
else
	$(report) warn "i3 not installed."
endif

update:
ifeq ($(call cmd_exist,i3-msg), true)
	$(info => Reloading i3-msg)
	$(MAKE) -C $(SRC) build_i3
	i3-msg reload ; $(report) "i3 reload"
else
	$(report) warn "i3 not installed."
endif

remove:
	$(info => Remvoing sway)
	$(rm_link) $(TARGET)

build_i3:
	cat $(SRC)/config.d/* > $(SRC)/config