speedwm-personal/scripts/speedwm-core
2022-10-25 19:23:36 +02:00

55 lines
1.5 KiB
Bash
Executable file

#!/bin/sh
# speedwm-core
# This script handles the updating and other things necessary for keybinds.
BINDIR="$(dirname $(command -v speedwm_status))/"
# update
UPDATE_SPEEDWM() {
FAIL_SOURCEDOESNOTEXIST() {
echo "The speedwm source code directory could not be located. This means an automatic update cannot be performed. Clone a new build (instructions on https://speedie.gq/speedwm) and update manually."
exit 1
}
FAIL_NOT_INSTALLED_USING_GIT() {
echo "Your build of speedwm was likely not installed through Git (maybe installed using a tarball?) so therefore the update cannot continue. Clone a new build (instructions on https://speedie.gq/speedwm) and update manually."
exit 1
}
FAIL_NO_AUTH() {
echo "Failed to authenticate."
exit 1
}
SOURCEDIR=$(cat /usr/share/speedwm/sourcedir)
test $SOURCEDIR || FAIL_SOURCEDOESNOTEXIST
# Check if Git is available
if [ -e "${BINDIR}git" ]; then
echo "Git found!"
else
echo "Git was not found, therefore the speedwm update cannot continue." ; exit 1
fi
cd $SOURCEDIR
make patch
make patch_remove
git stash
git pull || FAIL_NOT_INSTALLED_USING_GIT
make patch_install
clear
printf "speedwm requires root permissions briefly to run the following command:\nmake clean install\nEnter your password to allow this.\n"
su -c "make clean install" || FAIL_NO_AUTH
echo 'speedwm has been updated!'
exit 0
}
OPT=$1
case "$OPT" in
"-curl-weather") clear ; curl -s wttr.in | head -n 38 | tail -n 37 && sleep 60 ;;
"-update-speedwm") UPDATE_SPEEDWM ;;
esac