diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md new file mode 100644 index 00000000..43426a8a --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -0,0 +1,26 @@ +--- +name: Bug report +about: Create a report to help us improve +title: '' +labels: '' +assignees: '' +--- + +## Describe the bug +A clear and concise description of what the bug is. + +## To Reproduce +Steps to reproduce the behavior: +1. Go to '...' +2. Click on '....' +3. Scroll down to '....' +4. See error + +## Expected behavior +A clear and concise description of what you expected to happen. + +## Screenshots +If applicable, add screenshots to help explain your problem. + +## Additional context +Add any other context about the problem here. diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md new file mode 100644 index 00000000..bbcbbe7d --- /dev/null +++ b/.github/ISSUE_TEMPLATE/feature_request.md @@ -0,0 +1,20 @@ +--- +name: Feature request +about: Suggest an idea for this project +title: '' +labels: '' +assignees: '' + +--- + +**Is your feature request related to a problem? Please describe.** +A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] + +**Describe the solution you'd like** +A clear and concise description of what you want to happen. + +**Describe alternatives you've considered** +A clear and concise description of any alternative solutions or features you've considered. + +**Additional context** +Add any other context or screenshots about the feature request here. diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md new file mode 100644 index 00000000..a38de0f5 --- /dev/null +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -0,0 +1,36 @@ +# Pull Request + +## Title +[Provide a succinct and descriptive title for the pull request.] + +## Type of Change +- [ ] New feature +- [ ] Bug fix +- [ ] Documentation Update (Due to be added!) +- [ ] Refactoring +- [ ] Hotfix +- [ ] Security patch +- [ ] UI/UX improvement + +## Description +[Provide a detailed explanation of the changes you have made. Include the reasons behind these changes and any relevant context. Link any related issues.] + +## Testing +[Detail the testing you have performed to ensure that these changes function as intended. Include information about any added tests.] + +## Impact +[Discuss the impact of your changes on the project. This might include effects on performance, new dependencies, or changes in behaviour.] + +## Issue related to PR +[What issue/discussion is related to this PR (if any)] +- Resolves # + +## Additional Information +[Any additional information that reviewers should be aware of.] + +## Checklist +- [ ] My code adheres to the coding and style guidelines of the project. +- [ ] I have performed a self-review of my own code. +- [ ] I have commented my code, particularly in hard-to-understand areas. +- [ ] I have made corresponding changes to the documentation. +- [ ] My changes generate no errors/warnings/merge conflicts. diff --git a/.github/workflows/linutil.yml b/.github/workflows/linutil.yml index 34ce5d4c..30f7f8ad 100644 --- a/.github/workflows/linutil.yml +++ b/.github/workflows/linutil.yml @@ -30,13 +30,11 @@ jobs: key: ${{ runner.os }}-cargo-index-${{ hashFiles('**/Cargo.lock') }} restore-keys: ${{ runner.os }}-cargo-index- - name: Install Rust - uses: actions-rs/toolchain@v1 - with: - toolchain: stable + uses: dtolnay/rust-toolchain@stable - name: Build run: cargo build --target-dir=build --release --verbose - uses: stefanzweifel/git-auto-commit-action@v5 with: commit_message: Commit Linutil file_pattern: 'build/release/linutil' - if: success() \ No newline at end of file + if: success() diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 471af03f..0b2e12a4 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -1,4 +1,4 @@ -name: Rust Check +name: Rust Checks on: pull_request: @@ -9,25 +9,46 @@ env: jobs: cargo_check: + name: Cargo Check runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4 + - name: Checkout sources + uses: actions/checkout@v4 + - name: Cache Cargo registry uses: actions/cache@v4 with: path: ~/.cargo/registry key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }} restore-keys: ${{ runner.os }}-cargo-registry- + - name: Cache Cargo index uses: actions/cache@v4 with: path: ~/.cargo/git key: ${{ runner.os }}-cargo-index-${{ hashFiles('**/Cargo.lock') }} restore-keys: ${{ runner.os }}-cargo-index- + - name: Install Rust - uses: actions-rs/toolchain@v1 - with: - toolchain: stable + uses: dtolnay/rust-toolchain@stable + - name: Build - run: cargo check \ No newline at end of file + run: cargo check + + lints: + name: Lints + runs-on: ubuntu-latest + + steps: + - name: Checkout sources + uses: actions/checkout@v4 + + - name: Install Rust + uses: dtolnay/rust-toolchain@stable + + - name: Run cargo fmt + run: cargo fmt --all --check + + - name: Run cargo clippy + run: cargo clippy diff --git a/build/release/linutil b/build/release/linutil index e6438a34..ec3242e6 100755 Binary files a/build/release/linutil and b/build/release/linutil differ diff --git a/src/commands/common-script.sh b/src/commands/common-script.sh index a8d43871..a6f31515 100644 --- a/src/commands/common-script.sh +++ b/src/commands/common-script.sh @@ -1,28 +1,33 @@ #!/bin/sh -e +# shellcheck disable=SC2034 + RC='\033[0m' RED='\033[31m' YELLOW='\033[33m' GREEN='\033[32m' command_exists() { - which $1 >/dev/null 2>&1 + which "$1" >/dev/null 2>&1 } -checkEnv() { + +checkCommandRequirements() { ## Check for requirements. - REQUIREMENTS='curl groups sudo' + REQUIREMENTS=$1 for req in ${REQUIREMENTS}; do - if ! command_exists ${req}; then - echo -e "${RED}To run me, you need: ${REQUIREMENTS}${RC}" + if ! command_exists "${req}"; then + echo "${RED}To run me, you need: ${REQUIREMENTS}${RC}" exit 1 fi done +} - ## Check Package Handler - PACKAGEMANAGER='apt-get dnf pacman zypper' +checkPackageManager() { + ## Check Package Manager + PACKAGEMANAGER=$1 for pgm in ${PACKAGEMANAGER}; do - if command_exists ${pgm}; then + if command_exists "${pgm}"; then PACKAGER=${pgm} echo "Using ${pgm}" break @@ -33,11 +38,13 @@ checkEnv() { echo -e "${RED}Can't find a supported package manager${RC}" exit 1 fi +} +checkSuperUser() { ## Check SuperUser Group SUPERUSERGROUP='wheel sudo root' for sug in ${SUPERUSERGROUP}; do - if groups | grep -q ${sug}; then + if groups | grep -q "${sug}"; then SUGROUP=${sug} echo "Super user group ${SUGROUP}" break @@ -45,15 +52,33 @@ checkEnv() { done ## Check if member of the sudo group. - if ! groups | grep -q ${SUGROUP}; then - echo -e "${RED}You need to be a member of the sudo group to run me!${RC}" + if ! groups | grep -q "${SUGROUP}"; then + echo "${RED}You need to be a member of the sudo group to run me!${RC}" exit 1 fi +} +checkCurrentDirectoryWritable() { + ## Check if the current directory is writable. + GITPATH="$(dirname "$(realpath "$0")")" + if [ ! -w "$GITPATH" ]; then + echo "${RED}Can't write to $GITPATH${RC}" + exit 1 + fi +} + +checkDistro() { DTYPE="unknown" # Default to unknown # Use /etc/os-release for modern distro identification if [ -f /etc/os-release ]; then . /etc/os-release DTYPE=$ID fi -} \ No newline at end of file +} + +checkEnv() { + checkCommandRequirements 'curl groups sudo' + checkPackageManager 'apt-get dnf pacman zypper' + checkSuperUser + checkDistro +} diff --git a/src/commands/dotfiles/alacritty-setup.sh b/src/commands/dotfiles/alacritty-setup.sh index bf8473d5..2e2156d4 100755 --- a/src/commands/dotfiles/alacritty-setup.sh +++ b/src/commands/dotfiles/alacritty-setup.sh @@ -1,61 +1,10 @@ #!/bin/sh -e -RC='\033[0m' -RED='\033[31m' -YELLOW='\033[33m' -GREEN='\033[32m' - -command_exists() { - which $1 >/dev/null 2>&1 -} - checkEnv() { - ## Check for requirements. - REQUIREMENTS='curl groups sudo' - for req in ${REQUIREMENTS}; do - if ! command_exists ${req}; then - echo -e "${RED}To run me, you need: ${REQUIREMENTS}${RC}" - exit 1 - fi - done - - ## Check Package Handler - PACKAGEMANAGER='apt-get dnf pacman zypper' - for pgm in ${PACKAGEMANAGER}; do - if command_exists ${pgm}; then - PACKAGER=${pgm} - echo "Using ${pgm}" - break - fi - done - - if [ -z "${PACKAGER}" ]; then - echo -e "${RED}Can't find a supported package manager${RC}" - exit 1 - fi - - ## Check SuperUser Group - SUPERUSERGROUP='wheel sudo root' - for sug in ${SUPERUSERGROUP}; do - if groups | grep -q ${sug}; then - SUGROUP=${sug} - echo "Super user group ${SUGROUP}" - break - fi - done - - ## Check if member of the sudo group. - if ! groups | grep -q ${SUGROUP}; then - echo -e "${RED}You need to be a member of the sudo group to run me!${RC}" - exit 1 - fi - - DTYPE="unknown" # Default to unknown - # Use /etc/os-release for modern distro identification - if [ -f /etc/os-release ]; then - . /etc/os-release - DTYPE=$ID - fi + checkCommandRequirements 'curl groups sudo' + checkPackageManager 'apt-get dnf pacman zypper' + checkSuperUser + checkDistro } setupAlacritty() { @@ -82,4 +31,4 @@ setupAlacritty() { } checkEnv -setupAlacritty \ No newline at end of file +setupAlacritty diff --git a/src/commands/dotfiles/kitty-setup.sh b/src/commands/dotfiles/kitty-setup.sh index 52167460..131d1f9a 100755 --- a/src/commands/dotfiles/kitty-setup.sh +++ b/src/commands/dotfiles/kitty-setup.sh @@ -1,61 +1,10 @@ #!/bin/sh -e -RC='\033[0m' -RED='\033[31m' -YELLOW='\033[33m' -GREEN='\033[32m' - -command_exists() { - which $1 >/dev/null 2>&1 -} - checkEnv() { - ## Check for requirements. - REQUIREMENTS='curl groups sudo' - for req in ${REQUIREMENTS}; do - if ! command_exists ${req}; then - echo -e "${RED}To run me, you need: ${REQUIREMENTS}${RC}" - exit 1 - fi - done - - ## Check Package Handler - PACKAGEMANAGER='apt-get dnf pacman zypper' - for pgm in ${PACKAGEMANAGER}; do - if command_exists ${pgm}; then - PACKAGER=${pgm} - echo "Using ${pgm}" - break - fi - done - - if [ -z "${PACKAGER}" ]; then - echo -e "${RED}Can't find a supported package manager${RC}" - exit 1 - fi - - ## Check SuperUser Group - SUPERUSERGROUP='wheel sudo root' - for sug in ${SUPERUSERGROUP}; do - if groups | grep -q ${sug}; then - SUGROUP=${sug} - echo "Super user group ${SUGROUP}" - break - fi - done - - ## Check if member of the sudo group. - if ! groups | grep -q ${SUGROUP}; then - echo -e "${RED}You need to be a member of the sudo group to run me!${RC}" - exit 1 - fi - - DTYPE="unknown" # Default to unknown - # Use /etc/os-release for modern distro identification - if [ -f /etc/os-release ]; then - . /etc/os-release - DTYPE=$ID - fi + checkCommandRequirements 'curl groups sudo' + checkPackageManager 'apt-get dnf pacman zypper' + checkSuperUser + checkDistro } setupKitty() { @@ -63,10 +12,10 @@ setupKitty() { if ! command_exists kitty; then case ${PACKAGER} in pacman) - sudo ${PACKAGER} -S --noconfirm kitty + sudo "${PACKAGER}" -S --noconfirm kitty ;; *) - sudo ${PACKAGER} install -y kitty + sudo "${PACKAGER}" install -y kitty ;; esac else @@ -74,12 +23,12 @@ setupKitty() { fi echo "Copy Kitty config files" if [ -d "${HOME}/.config/kitty" ]; then - cp -r ${HOME}/.config/kitty ${HOME}/.config/kitty-bak + 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 + 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 \ No newline at end of file +setupKitty diff --git a/src/commands/dotfiles/rofi-setup.sh b/src/commands/dotfiles/rofi-setup.sh index 16fc84c6..aab942ed 100755 --- a/src/commands/dotfiles/rofi-setup.sh +++ b/src/commands/dotfiles/rofi-setup.sh @@ -1,61 +1,10 @@ #!/bin/sh -e -RC='\033[0m' -RED='\033[31m' -YELLOW='\033[33m' -GREEN='\033[32m' - -command_exists() { - which "$1" >/dev/null 2>&1 -} - checkEnv() { - ## Check for requirements. - REQUIREMENTS='curl groups sudo' - for req in $REQUIREMENTS; do - if ! command_exists "$req"; then - echo -e "${RED}To run me, you need: ${REQUIREMENTS}${RC}" - exit 1 - fi - done - - ## Check Package Handler - PACKAGEMANAGER='apt-get dnf pacman zypper' - for pgm in $PACKAGEMANAGER; do - if command_exists "$pgm"; then - PACKAGER="$pgm" - echo "Using $pgm" - break - fi - done - - if [ -z "$PACKAGER" ]; then - echo -e "${RED}Can't find a supported package manager${RC}" - exit 1 - fi - - ## Check SuperUser Group - SUPERUSERGROUP='wheel sudo root' - for sug in $SUPERUSERGROUP; do - if groups | grep -q "$sug"; then - SUGROUP="$sug" - echo "Super user group $SUGROUP" - break - fi - done - - ## Check if member of the sudo group. - if ! groups | grep -q "$SUGROUP"; then - echo -e "${RED}You need to be a member of the sudo group to run me!${RC}\n" - exit 1 - fi - - DTYPE="unknown" # Default to unknown - # Use /etc/os-release for modern distro identification - if [ -f /etc/os-release ]; then - . /etc/os-release - DTYPE="$ID" - fi + checkCommandRequirements 'curl groups sudo' + checkPackageManager 'apt-get dnf pacman zypper' + checkSuperUser + checkDistro } setupRofi() { @@ -87,4 +36,4 @@ setupRofi() { } checkEnv -setupRofi \ No newline at end of file +setupRofi diff --git a/src/commands/system-setup/1-compile-setup.sh b/src/commands/system-setup/1-compile-setup.sh index 0c0df4f7..0ae78950 100755 --- a/src/commands/system-setup/1-compile-setup.sh +++ b/src/commands/system-setup/1-compile-setup.sh @@ -1,10 +1,5 @@ #!/bin/sh -e -RC='\033[0m' -RED='\033[31m' -YELLOW='\033[33m' -GREEN='\033[32m' - # Check if the home directory and linuxtoolbox folder exist, create them if they don't LINUXTOOLBOXDIR="$HOME/linuxtoolbox" @@ -14,70 +9,24 @@ if [ ! -d "$LINUXTOOLBOXDIR" ]; then echo -e "${GREEN}linuxtoolbox directory created: $LINUXTOOLBOXDIR${RC}" fi -if [ ! -d "$LINUXTOOLBOXDIR/linux-setup" ]; then - echo -e "${YELLOW}Cloning linux-setup repository into: $LINUXTOOLBOXDIR/linux-setup${RC}" - git clone https://github.com/ChrisTitusTech/linux-setup "$LINUXTOOLBOXDIR/linux-setup" +if [ ! -d "$LINUXTOOLBOXDIR/linutil" ]; then + echo -e "${YELLOW}Cloning linutil repository into: $LINUXTOOLBOXDIR/linutil${RC}" + git clone https://github.com/ChrisTitusTech/linutil "$LINUXTOOLBOXDIR/linutil" if [ $? -eq 0 ]; then - echo -e "${GREEN}Successfully cloned linux-setup repository${RC}" + echo -e "${GREEN}Successfully cloned linutil repository${RC}" else - echo -e "${RED}Failed to clone linux-setup repository${RC}" + echo -e "${RED}Failed to clone linutil repository${RC}" exit 1 fi fi -cd "$LINUXTOOLBOXDIR/linux-setup" || exit - -command_exists() { - command -v "$1" >/dev/null 2>&1 -} +cd "$LINUXTOOLBOXDIR/linutil" || exit checkEnv() { - ## Check for requirements. - REQUIREMENTS='curl groups sudo' - for req in $REQUIREMENTS; do - if ! command_exists "$req"; then - echo -e "${RED}To run me, you need: $REQUIREMENTS${RC}" - exit 1 - fi - done - - ## Check Package Manager - PACKAGEMANAGER='apt yum dnf pacman zypper' - for pgm in $PACKAGEMANAGER; do - if command_exists "$pgm"; then - PACKAGER="$pgm" - echo "Using $pgm" - break - fi - done - - if [ -z "$PACKAGER" ]; then - echo -e "${RED}Can't find a supported package manager${RC}" - exit 1 - fi - - ## Check if the current directory is writable. - GITPATH="$(dirname "$(realpath "$0")")" - if [ ! -w "$GITPATH" ]; then - echo -e "${RED}Can't write to $GITPATH${RC}" - exit 1 - fi - - ## Check SuperUser Group - SUPERUSERGROUP='wheel sudo root' - for sug in $SUPERUSERGROUP; do - if groups | grep -q "$sug"; then - SUGROUP="$sug" - echo "Super user group $SUGROUP" - break - fi - done - - ## Check if member of the sudo group. - if ! groups | grep -q "$SUGROUP"; then - echo -e "${RED}You need to be a member of the sudo group to run me!${RC}" - exit 1 - fi + checkCommandRequirements 'curl groups sudo' + checkPackageHandler 'apt yum dnf pacman zypper' + checkCurrentDirectoryWritable + checkSuperUser } installDepend() { @@ -109,30 +58,30 @@ installDepend() { echo "No AUR helper found. Please install yay or paru." exit 1 fi - "$AUR_HELPER" --noconfirm -S $DEPENDENCIES + "$AUR_HELPER" --noconfirm -S "$DEPENDENCIES" ;; apt) COMPILEDEPS='build-essential' sudo "$PACKAGER" update sudo dpkg --add-architecture i386 sudo "$PACKAGER" update - sudo "$PACKAGER" install -y $DEPENDENCIES $COMPILEDEPS + sudo "$PACKAGER" install -y "$DEPENDENCIES" $COMPILEDEPS ;; dnf) COMPILEDEPS='@development-tools' sudo "$PACKAGER" update sudo "$PACKAGER" config-manager --set-enabled powertools - sudo "$PACKAGER" install -y $DEPENDENCIES $COMPILEDEPS + sudo "$PACKAGER" install -y "$DEPENDENCIES" $COMPILEDEPS sudo "$PACKAGER" install -y glibc-devel.i686 libgcc.i686 ;; zypper) COMPILEDEPS='patterns-devel-base-devel_basis' sudo "$PACKAGER" refresh - sudo "$PACKAGER" --non-interactive install $DEPENDENCIES $COMPILEDEPS + sudo "$PACKAGER" --non-interactive install "$DEPENDENCIES" $COMPILEDEPS sudo "$PACKAGER" --non-interactive install libgcc_s1-gcc7-32bit glibc-devel-32bit ;; *) - sudo "$PACKAGER" install -y $DEPENDENCIES + sudo "$PACKAGER" install -y "$DEPENDENCIES" ;; esac } @@ -159,4 +108,4 @@ install_additional_dependencies() { checkEnv installDepend -install_additional_dependencies \ No newline at end of file +install_additional_dependencies diff --git a/src/commands/system-setup/2-gaming-setup.sh b/src/commands/system-setup/2-gaming-setup.sh index c9ed0368..f044162c 100755 --- a/src/commands/system-setup/2-gaming-setup.sh +++ b/src/commands/system-setup/2-gaming-setup.sh @@ -1,58 +1,10 @@ #!/bin/sh -e -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 yum dnf pacman zypper' - for pgm in ${PACKAGEMANAGER}; do - if command_exists ${pgm}; then - PACKAGER=${pgm} - echo "Using ${pgm}" - fi - done - - if [ -z "${PACKAGER}" ]; then - echo -e "${RED}Can't find a supported package manager" - exit 1 - fi - - ## Check if the current directory is writable. - GITPATH="$(dirname "$(readlink -f "$0")")" - if [ ! -w ${GITPATH} ]; then - echo -e "${RED}Can't write to ${GITPATH}${RC}" - exit 1 - fi - - ## Check SuperUser Group - SUPERUSERGROUP='wheel sudo root' - for sug in ${SUPERUSERGROUP}; do - if groups | grep ${sug}; then - SUGROUP=${sug} - echo "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 - + checkCommandRequirements 'curl groups sudo' + checkPackageManager 'apt-get yum dnf pacman zypper' + checkCurrentDirectoryWritable + checkSuperUser } installDepend() { @@ -138,4 +90,4 @@ install_additional_dependencies() { checkEnv installDepend -install_additional_dependencies \ No newline at end of file +install_additional_dependencies diff --git a/src/commands/system-setup/3-global-theme.sh b/src/commands/system-setup/3-global-theme.sh new file mode 100644 index 00000000..915684b1 --- /dev/null +++ b/src/commands/system-setup/3-global-theme.sh @@ -0,0 +1,65 @@ +#!/bin/sh -e + +# Check if the home directory and linuxtoolbox folder exist, create them if they don't +LINUXTOOLBOXDIR="$HOME/linuxtoolbox" + +if [ ! -d "$LINUXTOOLBOXDIR" ]; then + echo -e "${YELLOW}Creating linuxtoolbox directory: $LINUXTOOLBOXDIR${RC}" + mkdir -p "$LINUXTOOLBOXDIR" + echo -e "${GREEN}linuxtoolbox directory created: $LINUXTOOLBOXDIR${RC}" +fi + +cd "$LINUXTOOLBOXDIR" || exit + +install_theme_tools() { + echo -e "${YELLOW}Installing theme tools (qt6ct and kvantum)...${RC}" + case $PACKAGER in + apt-get) + sudo apt-get update + sudo apt-get install -y qt6ct kvantum + ;; + zypper) + sudo zypper refresh + sudo zypper --non-interactive install qt6ct kvantum + ;; + dnf) + sudo dnf update + sudo dnf install -y qt6ct kvantum + ;; + pacman) + sudo pacman -Sy + sudo pacman --noconfirm -S qt6ct kvantum + ;; + *) + echo -e "${RED}Unsupported package manager. Please install qt6ct and kvantum manually.${RC}" + exit 1 + ;; + esac +} + +configure_qt6ct() { + echo -e "${YELLOW}Configuring qt6ct...${RC}" + mkdir -p "$HOME/.config/qt6ct" + cat < "$HOME/.config/qt6ct/qt6ct.conf" +[Appearance] +style=kvantum +color_scheme=default +icon_theme=breeze +EOF + echo -e "${GREEN}qt6ct configured successfully.${RC}" +} + +configure_kvantum() { + echo -e "${YELLOW}Configuring Kvantum...${RC}" + mkdir -p "$HOME/.config/Kvantum" + cat < "$HOME/.config/Kvantum/kvantum.kvconfig" +[General] +theme=Breeze +EOF + echo -e "${GREEN}Kvantum configured successfully.${RC}" +} + +checkEnv +install_theme_tools +configure_qt6ct +configure_kvantum \ No newline at end of file diff --git a/src/commands/system-update.sh b/src/commands/system-update.sh index 6faaf62a..132e617d 100755 --- a/src/commands/system-update.sh +++ b/src/commands/system-update.sh @@ -1,60 +1,10 @@ #!/bin/sh -e -RC='\033[0m' -RED='\033[31m' -YELLOW='\033[33m' -GREEN='\033[32m' - -command_exists() { - which $1 >/dev/null 2>&1 -} - checkEnv() { - ## Check for requirements. - REQUIREMENTS='curl groups sudo' - for req in ${REQUIREMENTS}; do - if ! command_exists ${req}; then - echo -e "${RED}To run me, you need: ${REQUIREMENTS}${RC}" - exit 1 - fi - done - ## Check Package Handler - PACKAGEMANAGER='apt-get nala dnf pacman zypper yum xbps-install' - for pgm in ${PACKAGEMANAGER}; do - if command_exists ${pgm}; then - PACKAGER=${pgm} - echo "Using ${pgm}" - break - fi - done - - if [ -z "${PACKAGER}" ]; then - echo -e "${RED}Can't find a supported package manager${RC}" - exit 1 - fi - - ## Check SuperUser Group - SUPERUSERGROUP='wheel sudo root' - for sug in ${SUPERUSERGROUP}; do - if groups | grep ${sug} >/dev/null; then - SUGROUP=${sug} - echo "Super user group ${SUGROUP}" - break - 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!${RC}" - exit 1 - fi - - DTYPE="unknown" # Default to unknown - # Use /etc/os-release for modern distro identification - if [ -f /etc/os-release ]; then - . /etc/os-release - DTYPE=$ID - fi + checkCommandRequirements 'curl groups sudo' + checkPackageManager 'apt-get nala dnf pacman zypper yum xbps-install' + checkSuperUser + checkDistro } fastUpdate() { @@ -125,15 +75,15 @@ updateSystem() { echo -e "${GREEN}Updating system${RC}" case ${PACKAGER} in nala|apt-get) - sudo ${PACKAGER} update -y - sudo ${PACKAGER} upgrade -y + sudo "${PACKAGER}" update -y + sudo "${PACKAGER}" upgrade -y ;; yum|dnf) - sudo ${PACKAGER} update -y - sudo ${PACKAGER} upgrade -y + sudo "${PACKAGER}" update -y + sudo "${PACKAGER}" upgrade -y ;; pacman) - sudo ${PACKAGER} -Syu --noconfirm + sudo "${PACKAGER}" -Syu --noconfirm ;; zypper) sudo ${PACKAGER} ref diff --git a/src/list.rs b/src/list.rs index 22d1ef7a..b564bdea 100644 --- a/src/list.rs +++ b/src/list.rs @@ -9,6 +9,15 @@ use ratatui::{ Frame, }; +macro_rules! with_common_script { + ($command:expr) => { + concat!( + include_str!("commands/common-script.sh"), + include_str!($command) + ) + }; +} + struct ListNode { name: &'static str, command: &'static str, @@ -55,7 +64,7 @@ impl CustomList { } => { ListNode { name: "Full System Update", - command: include_str!("commands/system-update.sh"), + command: with_common_script!("commands/system-update.sh"), }, ListNode { name: "Setup Bash Prompt", @@ -75,11 +84,15 @@ impl CustomList { } => { ListNode { name: "Build Prerequisites", - command: include_str!("commands/system-setup/1-compile-setup.sh"), + command: with_common_script!("commands/system-setup/1-compile-setup.sh"), }, ListNode { name: "Gaming Dependencies", - command: include_str!("commands/system-setup/2-gaming-setup.sh"), + command: with_common_script!("commands/system-setup/2-gaming-setup.sh"), + }, + ListNode { + name: "Global Theme", + command: with_common_script!("commands/system-setup/3-global-theme.sh"), }, ListNode { name: "Recursion?", @@ -92,15 +105,15 @@ impl CustomList { } => { ListNode { name: "Alacritty Setup", - command: include_str!("commands/dotfiles/alacritty-setup.sh"), + command: with_common_script!("commands/dotfiles/alacritty-setup.sh"), }, ListNode { name: "Kitty Setup", - command: include_str!("commands/dotfiles/kitty-setup.sh"), + command: with_common_script!("commands/dotfiles/kitty-setup.sh"), }, ListNode { name: "Rofi Setup", - command: include_str!("commands/dotfiles/rofi-setup.sh"), + command: with_common_script!("commands/dotfiles/rofi-setup.sh"), }, } });