Eclectic Media Git dmenu-tweet / master setup.sh
master

Tree @master (Download .tar.gz)

setup.sh @masterraw · history · blame

#! /bin/bash

BIN_PATH="$HOME/.local/bin"
LIB_PATH="$HOME/.local/lib"

subcommand_output () {
	tput setaf 3
	while read -e line; do
		echo "... $line"
	done
	tput sgr0
}


echo -e "\nEnsuring dependencies are installed!\n"
	if ! command -v dmenu &> /dev/null; then
		echo "Please ensure that dmenu is installed!"
		exit 1
	fi
	
	if ! ls lib | grep 'bash-send-tweet' &> /dev/null; then
		echo "bash-send-tweet submodule not cloned! Rectifying!"
		git submodule update --init --recursive | subcommand_output
	fi

	echo "Dependencies satisfied!" | subcommand_output
	sleep 0.5


echo -e "\nEnrolling twitter keys!\n"
	./utils/enroll.sh | subcommand_output

	if ! [[ $? == 0 ]]; then
		echo "Failed to enroll twitter keys! Exiting!"
		exit 1
	fi
	sleep 0.5


echo -e "\nCopying bin files to executable path! [~/.local/bin/]"
	mkdir -p $BIN_PATH &> /dev/null  # ensure path exists
	cp bin/dmenu-tweet $BIN_PATH/
	sleep 0.5


echo -e "\nCopying lib files to library path! [~/.local/lib/]"
	mkdir -p $LIB_PATH &> /dev/null  # ensure path exists
	rm -rf "$LIB_PATH/bash-send-tweet" &> /dev/null
	cp -r lib/bash-send-tweet $LIB_PATH/


# ADD TO PATH
if ! cat ~/.bashrc | grep "local/bin" &> /dev/null || cat ~/.bashrc | grep "dmenu-tweet" &> /dev/null; then
	echo -e "\nAdding paths to .bashrc...\n"
	echo 'export PATH=$PATH:~/.local/bin/dmenu-tweet'
fi


# ADD i3 BINDINGS
if [[ -f ~/.config/i3/config ]]; then
	if ! cat ~/.config/i3/config | grep "dmenu-tweet" &>/dev/null; then
		echo -e "\nDetected i3wm but no bindings for dmenu-tweet!\n"
		tput setaf 3; read -p '... Do you want to add $mod+Shift+t as a binding for dmenu-tweet? [y/N]: '; tput sgr0
		if [[ "$REPLY" == 'y' ]]; then
			echo 'bindsym $mod+Shift+t exec --no-startup-id "dmenu-tweet"' >> ~/.config/i3/config
		fi
	fi
fi

echo -e "\n\nDone!"