From d03be6796cc8fadb73351ce87a320c74812b8135 Mon Sep 17 00:00:00 2001 From: Chris Titus Date: Thu, 25 Jul 2024 17:01:11 -0500 Subject: [PATCH] consolidate code and fix global theme --- src/commands/common-script.sh | 3 ++- src/commands/dotfiles/alacritty-setup.sh | 7 ------ src/commands/dotfiles/kitty-setup.sh | 7 ------ src/commands/dotfiles/rofi-setup.sh | 7 ------ src/commands/system-setup/1-compile-setup.sh | 7 ------ src/commands/system-setup/2-gaming-setup.sh | 7 ------ src/commands/system-setup/3-global-theme.sh | 25 +++++++++++++------- src/commands/system-update.sh | 7 ------ 8 files changed, 19 insertions(+), 51 deletions(-) diff --git a/src/commands/common-script.sh b/src/commands/common-script.sh index a6f31515..064bf3c9 100644 --- a/src/commands/common-script.sh +++ b/src/commands/common-script.sh @@ -78,7 +78,8 @@ checkDistro() { checkEnv() { checkCommandRequirements 'curl groups sudo' - checkPackageManager 'apt-get dnf pacman zypper' + checkPackageManager 'apt-get nala dnf pacman zypper yum xbps-install nix-env' + checkCurrentDirectoryWritable checkSuperUser checkDistro } diff --git a/src/commands/dotfiles/alacritty-setup.sh b/src/commands/dotfiles/alacritty-setup.sh index 2e2156d4..2b363e85 100755 --- a/src/commands/dotfiles/alacritty-setup.sh +++ b/src/commands/dotfiles/alacritty-setup.sh @@ -1,12 +1,5 @@ #!/bin/sh -e -checkEnv() { - checkCommandRequirements 'curl groups sudo' - checkPackageManager 'apt-get dnf pacman zypper' - checkSuperUser - checkDistro -} - setupAlacritty() { echo "Install Alacritty if not already installed..." if ! command_exists alacritty; then diff --git a/src/commands/dotfiles/kitty-setup.sh b/src/commands/dotfiles/kitty-setup.sh index 131d1f9a..bad29ac0 100755 --- a/src/commands/dotfiles/kitty-setup.sh +++ b/src/commands/dotfiles/kitty-setup.sh @@ -1,12 +1,5 @@ #!/bin/sh -e -checkEnv() { - checkCommandRequirements 'curl groups sudo' - checkPackageManager 'apt-get dnf pacman zypper' - checkSuperUser - checkDistro -} - setupKitty() { echo "Install Kitty if not already installed..." if ! command_exists kitty; then diff --git a/src/commands/dotfiles/rofi-setup.sh b/src/commands/dotfiles/rofi-setup.sh index aab942ed..ea2be0f2 100755 --- a/src/commands/dotfiles/rofi-setup.sh +++ b/src/commands/dotfiles/rofi-setup.sh @@ -1,12 +1,5 @@ #!/bin/sh -e -checkEnv() { - checkCommandRequirements 'curl groups sudo' - checkPackageManager 'apt-get dnf pacman zypper' - checkSuperUser - checkDistro -} - setupRofi() { echo "Install Rofi if not already installed..." if ! command_exists rofi; then diff --git a/src/commands/system-setup/1-compile-setup.sh b/src/commands/system-setup/1-compile-setup.sh index 0ae78950..345f09c8 100755 --- a/src/commands/system-setup/1-compile-setup.sh +++ b/src/commands/system-setup/1-compile-setup.sh @@ -22,13 +22,6 @@ fi cd "$LINUXTOOLBOXDIR/linutil" || exit -checkEnv() { - checkCommandRequirements 'curl groups sudo' - checkPackageHandler 'apt yum dnf pacman zypper' - checkCurrentDirectoryWritable - checkSuperUser -} - installDepend() { ## Check for dependencies. DEPENDENCIES='tar tree multitail tldr trash-cli unzip cmake make jq' diff --git a/src/commands/system-setup/2-gaming-setup.sh b/src/commands/system-setup/2-gaming-setup.sh index f044162c..98f47552 100755 --- a/src/commands/system-setup/2-gaming-setup.sh +++ b/src/commands/system-setup/2-gaming-setup.sh @@ -1,12 +1,5 @@ #!/bin/sh -e -checkEnv() { - checkCommandRequirements 'curl groups sudo' - checkPackageManager 'apt-get yum dnf pacman zypper' - checkCurrentDirectoryWritable - checkSuperUser -} - installDepend() { ## Check for dependencies. echo -e "${YELLOW}Installing dependencies...${RC}" diff --git a/src/commands/system-setup/3-global-theme.sh b/src/commands/system-setup/3-global-theme.sh index 915684b1..a1ad4824 100644 --- a/src/commands/system-setup/3-global-theme.sh +++ b/src/commands/system-setup/3-global-theme.sh @@ -4,15 +4,15 @@ LINUXTOOLBOXDIR="$HOME/linuxtoolbox" if [ ! -d "$LINUXTOOLBOXDIR" ]; then - echo -e "${YELLOW}Creating linuxtoolbox directory: $LINUXTOOLBOXDIR${RC}" + printf "${YELLOW}Creating linuxtoolbox directory: %s${RC}\n" "$LINUXTOOLBOXDIR" mkdir -p "$LINUXTOOLBOXDIR" - echo -e "${GREEN}linuxtoolbox directory created: $LINUXTOOLBOXDIR${RC}" + printf "${GREEN}linuxtoolbox directory created: %s${RC}\n" "$LINUXTOOLBOXDIR" fi cd "$LINUXTOOLBOXDIR" || exit install_theme_tools() { - echo -e "${YELLOW}Installing theme tools (qt6ct and kvantum)...${RC}" + printf "${YELLOW}Installing theme tools (qt6ct and kvantum)...${RC}\n" case $PACKAGER in apt-get) sudo apt-get update @@ -31,14 +31,14 @@ install_theme_tools() { sudo pacman --noconfirm -S qt6ct kvantum ;; *) - echo -e "${RED}Unsupported package manager. Please install qt6ct and kvantum manually.${RC}" + printf "${RED}Unsupported package manager. Please install qt6ct and kvantum manually.${RC}\n" exit 1 ;; esac } configure_qt6ct() { - echo -e "${YELLOW}Configuring qt6ct...${RC}" + printf "${YELLOW}Configuring qt6ct...${RC}\n" mkdir -p "$HOME/.config/qt6ct" cat < "$HOME/.config/qt6ct/qt6ct.conf" [Appearance] @@ -46,17 +46,26 @@ style=kvantum color_scheme=default icon_theme=breeze EOF - echo -e "${GREEN}qt6ct configured successfully.${RC}" + printf "${GREEN}qt6ct configured successfully.${RC}\n" + + # Add QT_QPA_PLATFORMTHEME to /etc/environment + if ! grep -q "QT_QPA_PLATFORMTHEME=qt6ct" /etc/environment; then + printf "${YELLOW}Adding QT_QPA_PLATFORMTHEME to /etc/environment...${RC}\n" + echo "QT_QPA_PLATFORMTHEME=qt6ct" | sudo tee -a /etc/environment > /dev/null + printf "${GREEN}QT_QPA_PLATFORMTHEME added to /etc/environment.${RC}\n" + else + printf "${GREEN}QT_QPA_PLATFORMTHEME already set in /etc/environment.${RC}\n" + fi } configure_kvantum() { - echo -e "${YELLOW}Configuring Kvantum...${RC}" + printf "${YELLOW}Configuring Kvantum...${RC}\n" mkdir -p "$HOME/.config/Kvantum" cat < "$HOME/.config/Kvantum/kvantum.kvconfig" [General] theme=Breeze EOF - echo -e "${GREEN}Kvantum configured successfully.${RC}" + printf "${GREEN}Kvantum configured successfully.${RC}\n" } checkEnv diff --git a/src/commands/system-update.sh b/src/commands/system-update.sh index 132e617d..b86172b8 100755 --- a/src/commands/system-update.sh +++ b/src/commands/system-update.sh @@ -1,12 +1,5 @@ #!/bin/sh -e -checkEnv() { - checkCommandRequirements 'curl groups sudo' - checkPackageManager 'apt-get nala dnf pacman zypper yum xbps-install' - checkSuperUser - checkDistro -} - fastUpdate() { case ${PACKAGER} in pacman)