diff --git a/src/commands/kitty-setup.sh b/src/commands/kitty-setup.sh new file mode 100755 index 00000000..ece5f9e3 --- /dev/null +++ b/src/commands/kitty-setup.sh @@ -0,0 +1,82 @@ +#!/bin/bash + +RC='\e[0m' +RED='\e[31m' +YELLOW='\e[33m' +GREEN='\e[32m' + +command_exists() { + command -v $1 >/dev/null 2>&1 +} + +checkEnv() { + ## Check for requirements. + REQUIREMENTS='curl groups sudo' + if ! command_exists ${REQUIREMENTS}; then + echo -e "${RED}To run me, you need: ${REQUIREMENTS}${RC}" + exit 1 + fi + + ## Check Package Handeler + PACKAGEMANAGER='apt-get dnf pacman zypper' + for pgm in ${PACKAGEMANAGER}; do + if command_exists ${pgm}; then + PACKAGER=${pgm} + echo -e "Using ${pgm}" + fi + done + + if [ -z "${PACKAGER}" ]; then + echo -e "${RED}Can't find a supported package manager" + exit 1 + fi + + ## Check SuperUser Group + SUPERUSERGROUP='wheel sudo root' + for sug in ${SUPERUSERGROUP}; do + if groups | grep ${sug}; then + SUGROUP=${sug} + echo -e "Super user group ${SUGROUP}" + fi + done + + ## Check if member of the sudo group. + if ! groups | grep ${SUGROUP} >/dev/null; then + echo -e "${RED}You need to be a member of the sudo group to run me!" + exit 1 + fi + + + DTYPE="unknown" # Default to unknown + # Use /etc/os-release for modern distro identification + if [ -f /etc/os-release ]; then + source /etc/os-release + DTYPE=$ID + fi +} + +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 + cp -r ${HOME}/.config/kitty {HOME}/.config/kitty-bak + 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 +setupKitty diff --git a/src/commands/rofi-setup.sh b/src/commands/rofi-setup.sh old mode 100644 new mode 100755 diff --git a/src/commands/system-update.sh b/src/commands/system-update.sh old mode 100644 new mode 100755 diff --git a/src/list.rs b/src/list.rs index fc6feb6d..2aac4c2b 100644 --- a/src/list.rs +++ b/src/list.rs @@ -76,11 +76,14 @@ impl CustomList { name: "Titus Dotfiles", command: "" } => { + ListNode { + name: "Kitty Setup", + command: include_str!("commands/kitty-setup.sh"), + }, ListNode { name: "Rofi Setup", command: include_str!("commands/rofi-setup.sh"), }, - } }); // We don't get a reference, but rather an id, because references are siginficantly more