linutil/src/commands/kitty-setup.sh

84 lines
2.2 KiB
Bash
Raw Normal View History

2024-07-14 03:16:02 +01:00
#!/bin/sh
RC='\033[0m'
RED='\033[31m'
YELLOW='\033[33m'
GREEN='\033[32m'
2024-07-13 22:44:09 +01:00
command_exists() {
2024-07-14 03:16:02 +01:00
which $1 >/dev/null 2>&1
2024-07-13 22:44:09 +01:00
}
checkEnv() {
## Check for requirements.
REQUIREMENTS='curl groups sudo'
2024-07-14 03:16:02 +01:00
for req in ${REQUIREMENTS}; do
if ! command_exists ${req}; then
echo "${RED}To run me, you need: ${REQUIREMENTS}${RC}"
exit 1
fi
done
2024-07-13 22:44:09 +01:00
2024-07-14 03:16:02 +01:00
## Check Package Handler
2024-07-13 22:44:09 +01:00
PACKAGEMANAGER='apt-get dnf pacman zypper'
for pgm in ${PACKAGEMANAGER}; do
if command_exists ${pgm}; then
PACKAGER=${pgm}
2024-07-14 03:16:02 +01:00
echo "Using ${pgm}"
break
2024-07-13 22:44:09 +01:00
fi
done
if [ -z "${PACKAGER}" ]; then
2024-07-14 03:16:02 +01:00
echo "${RED}Can't find a supported package manager${RC}"
2024-07-13 22:44:09 +01:00
exit 1
fi
## Check SuperUser Group
SUPERUSERGROUP='wheel sudo root'
for sug in ${SUPERUSERGROUP}; do
2024-07-14 03:16:02 +01:00
if groups | grep -q ${sug}; then
2024-07-13 22:44:09 +01:00
SUGROUP=${sug}
2024-07-14 03:16:02 +01:00
echo "Super user group ${SUGROUP}"
break
2024-07-13 22:44:09 +01:00
fi
done
## Check if member of the sudo group.
2024-07-14 03:16:02 +01:00
if ! groups | grep -q ${SUGROUP}; then
echo "${RED}You need to be a member of the sudo group to run me!${RC}"
2024-07-13 22:44:09 +01:00
exit 1
fi
DTYPE="unknown" # Default to unknown
2024-07-14 03:16:02 +01:00
# Use /etc/os-release for modern distro identification
if [ -f /etc/os-release ]; then
. /etc/os-release
DTYPE=$ID
fi
2024-07-13 22:44:09 +01:00
}
setupKitty() {
echo "Install Kitty if not already installed..."
if ! command_exists kitty; then
case ${PACKAGER} in
pacman)
sudo ${PACKAGER} -S --noconfirm kitty
;;
*)
sudo ${PACKAGER} install -y kitty
;;
esac
else
echo "Kitty is already installed."
fi
echo "Copy Kitty config files"
if [ -d "${HOME}/.config/kitty" ]; then
2024-07-14 03:16:02 +01:00
cp -r ${HOME}/.config/kitty ${HOME}/.config/kitty-bak
2024-07-13 22:44:09 +01:00
fi
mkdir -p ${HOME}/.config/kitty/
wget -O ${HOME}/.config/kitty/kitty.conf https://github.com/ChrisTitusTech/dwm-titus/raw/main/config/kitty/kitty.conf
wget -O ${HOME}/.config/kitty/nord.conf https://github.com/ChrisTitusTech/dwm-titus/raw/main/config/kitty/nord.conf
}
checkEnv
2024-07-14 03:16:02 +01:00
setupKitty