Skip to content

Instantly share code, notes, and snippets.

@dtomvan
Last active May 14, 2022 15:19
Show Gist options
  • Save dtomvan/a226c706b642fda6541c4141fab53b43 to your computer and use it in GitHub Desktop.
Save dtomvan/a226c706b642fda6541c4141fab53b43 to your computer and use it in GitHub Desktop.
Updater for Solar Tweaks for Arch Linux.
#!/bin/bash
bail() {
echo "$@"
echo "Fatal error occured. Exiting."
exit 1
}
echo "Solar Tweaks installer for Arch Linux"
echo "-------------------------------------"
echo "version 0.1"
id | grep root && bail "You should not run this script as root."
set -uo pipefail
pacman -h 2>&1 >/dev/null
if [[ $? != 0 ]]; then
bail "You are not on Arch Linux. This script only works on Arch Linux. Visit https://github.com/Solar-Tweaks/Solar-Tweaks for installation instuctions."
fi
read -p "Install Solar Tweaks? (y/N) " -r
if [[ ! $REPLY =~ ^[Yy]$ ]]; then
echo "Cancelled. Exiting."
exit 1
fi
INSTALL_DIR=~/.cache/solar-tweaks-installer
mkdir -p $INSTALL_DIR && pushd $INSTALL_DIR
install-dependencies() {
echo "Missing dependencies detected. Installing base-devel and git."
sudo pacman -S --needed base-devel git
}
install-lunar-client() {
git clone https://aur.archlinux.org/lunar-client.git
pushd lunar-client
git fetch --all
git reset --hard origin
makepkg -sic || bail "Failed to install lunar client."
popd
}
install-solar-tweaks() {
git clone https://aur.archlinux.org/solar-tweaks-bin.git
pushd solar-tweaks-bin
git fetch --all
git reset --hard origin
makepkg -sic || bail "Failed to install Solar Tweaks."
popd
}
echo "Checking dependencies..."
pacman -Q git 2>&1 >/dev/null && pacman -Qg base-devel 2>&1 >/dev/null || \
install-dependencies
echo "Checking if Lunar Client is installed..."
pacman -Q lunar-client 2>&1 >/dev/null || install-lunar-client
echo "All dependencies are installed. Installing Solar Tweaks..."
install-solar-tweaks
echo "DONE! Took $SECONDS seconds."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment