63 lines
2 KiB
Bash
Executable file
63 lines
2 KiB
Bash
Executable file
#!/bin/sh
|
|
# speedwm-core
|
|
# This script handles the updating and other things necessary for keybinds.
|
|
|
|
# Set binary directory if not set already.
|
|
if [ -e "/usr/share/speedwm/bindir" ]; then
|
|
BINDIR=$(cat /usr/share/speedwm/bindir) # Set binary directory to the contents of this variable.
|
|
else
|
|
BINDIR="/usr/bin/"
|
|
fi
|
|
|
|
# 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 ;;
|
|
"-curl-cheatsheet") clear ; echo -n "What cheatsheet do you want to view?\nExample: vim\n > " ; read CHEATSHEET ; curl -s cheat.sh/$(echo $CHEATSHEET | tr '[:upper:]' '[:lower:]') > /tmp/cheatsheet
|
|
grep "Unknown topic." /tmp/cheatsheet && $0 -curl-cheatsheet && exit 0
|
|
less /tmp/cheatsheet ;;
|
|
"-update-speedwm") UPDATE_SPEEDWM ;;
|
|
esac
|