diff --git a/README.md b/README.md index 4f31eaf..6f63212 100644 --- a/README.md +++ b/README.md @@ -16,27 +16,35 @@ Automated post-installation setup script for Linux desktop environments. This pr - **Hardware Support**: Installs drivers for Intel, VMware, VirtualBox, Hyper-V, and QEMU - **System Customization**: Applies kernel parameters, journald, and core dump configurations +## Code Quality & Best Practices + +This project emphasizes reliability and security: + +- **Error Handling**: Comprehensive error checking on all critical operations with clear diagnostics +- **Secure Temp Files**: Uses `mktemp` for secure temporary directories with automatic cleanup via trap handlers +- **Safe Quoting**: Proper variable quoting throughout to prevent word splitting and glob expansion +- **Portable**: Uses `printf` instead of `echo -e` for better portability across shell implementations +- **Fail-Safe**: Non-critical failures don't halt the entire setup--the script continues gracefully +- **No eval**: Avoids dangerous `eval` for remote script execution; uses safe alternatives instead +- **Validation**: All shell scripts are POSIX sh-compatible and pass strict syntax validation with `sh -n` + ## Prerequisites -- A supported Linux distribution (see [Supported Scenarios](#supported-scenario)) +- A supported Linux distribution (see [Supported Scenarios](#supported-scenarios)) - Sudo access for system-level configuration - Internet connection to download packages and resources - `curl` command-line tool (required) -## Supported scenario +## Supported Scenarios -> **_NOTE:_** KDE's config system is all over the places and many things are only possible from UI. So, I could automate only few things. That's one of the reasons I don't like KDE. +> **_NOTE:_** KDE Plasma configuration is complex due to its scattered configuration system. The setup automates package installation and basic theming only; many settings require manual configuration through the System Settings GUI. -| Distrution Type | Specific | Desktop Environment | -| --------------- | ----------------------- | -------------------------- | -| Arch | Arch | Gnome, KDE, Cinnamon, XFCE | -| | EndeavourOS | Gnome, KDE, Cinnamon | -| Debian | Debian | Gnome, XFCE | -| | Ubuntu | Gnome | -| | Mint | Cinnamon, XFCE | -| | LMDE | Cinnamon | -| Fedora | Fedora (Non-Silverblue) | Gnome, KDE, Cinnamon, XFCE | -| OpenSUSE | Tumbleweed, Leap | Gnome, KDE, Cinnamon, XFCE | +| Distribution Type | Specific Variant | Desktop Environment | +| --- | --- | --- | +| **Arch-based** | Arch Linux, EndeavourOS | GNOME, KDE, Cinnamon, XFCE | +| **Debian-based** | Debian, Ubuntu, Linux Mint, LMDE | GNOME, Cinnamon, XFCE | +| **Fedora** | Fedora (non-Silverblue) | GNOME, KDE, Cinnamon, XFCE | +| **OpenSUSE** | Tumbleweed, Leap | GNOME, KDE, Cinnamon, XFCE | ## Project Structure @@ -90,19 +98,40 @@ Distribution-specific setup and package lists. Each distro has: ### `/home` User home directory configuration files and templates: -- `.bashrc` - Bash initialization (custom functions, sourcing from .aliases) -- `.profile` - Shell login profile environment setup -- `.xinitrc` - X11 initialization (for startx) + +**Shell & X11:** +- `.bashrc` - Bash initialization with custom functions and aliases +- `.profile` - Shell login profile and environment variables +- `.xinitrc` - X11 initialization for startx - `.xprofile` - X11 session startup profile - `.xsessionrc` - X11 session configuration -- `.Xresources` - X11 resource database (font DPI, colors, etc.) -- `.config/` - Desktop environment and application configs -- `.local/` - User-local binaries and data files -- `.config/fontconfig/fonts.conf` - Font rendering configuration -- `.config/nano/nanorc` - Nano editor configuration -- `.config/alacritty/alacritty.toml` - Alacritty terminal emulator config -- `.config/kitty/kitty.conf` - Kitty terminal emulator config -- `.local/share/keyrings/` - GNOME Keyring files +- `.Xresources` - X11 resource database (font DPI, colors) + +**Terminal Emulators:** +- `.config/alacritty/alacritty.toml` - Alacritty terminal configuration and themes +- `.config/kitty/kitty.conf` - Kitty terminal configuration +- `.config/wezterm/wezterm.lua` - WezTerm terminal configuration (Lua-based) + +**System & App Configs:** +- `.config/fontconfig/fonts.conf` - Font rendering and hinting configuration +- `.config/nano/nanorc` - Nano editor configuration with syntax highlighting +- `.config/fastfetch/config.jsonc` - System info display configuration +- `.config/mimeapps.list` - Default applications for file types +- `.config/xfce4/` - XFCE-specific panel and window manager settings +- `.config/Kvantum/` - KDE Qt application theming +- `.config/qt5ct/` & `.config/qt6ct/` - Qt5/Qt6 theme configuration +- `.config/vlc/` - VLC media player preferences +- `.config/environment.d/` - User environment variables +- `.config/systemd/` - User systemd service configurations + +**Application Flags:** +- `.config/chrome-flags.conf`, `.config/chromium-flags.conf` - Chromium-based browser flags +- `.config/code-flags.conf` - Visual Studio Code startup flags +- `.config/electron-flags.conf` - Electron application flags +- `.config/microsoft-edge-stable-flags.conf` - Microsoft Edge flags + +**User Data:** +- `.local/share/keyrings/` - GNOME Keyring files and SSH key storage ### `/specific` Fine-grained, distro-version specific configurations: @@ -114,17 +143,17 @@ Fine-grained, distro-version specific configurations: - `neon.sh` - KDE Neon-specific setup hooks ### `/system` -System-level configuration files (require sudo): +System-level configuration files for machine-wide settings (require sudo to apply): -**Kernel and System Parameters:** -- `etc/sysctl.d/999-sysctl.conf` - Kernel parameters (network, memory, security) +**Kernel and Sysctl Parameters:** +- `etc/sysctl.d/999-sysctl.conf` - Kernel tuning (network performance, memory management, security hardening) **Systemd Services:** -- `etc/systemd/journald.conf.d/00-journal-size.conf` - Journal size and retention policy -- `etc/systemd/coredump.conf.d/custom.conf` - Core dump handling configuration +- `etc/systemd/journald.conf.d/00-journal-size.conf` - Journal storage policy and size limits +- `etc/systemd/coredump.conf.d/custom.conf` - Core dump handling and storage configuration -**Display Manager:** -- `etc/dconf/db/gdm.d/95-gdm-settings` - GNOME Display Manager (GDM) login screen settings +**Display Manager (GNOME GDM):** +- `etc/dconf/db/gdm.d/95-gdm-settings` - Login screen appearance and behavior (currently commented out in main setup) ## Customization @@ -132,69 +161,78 @@ System-level configuration files (require sudo): To customize which packages are installed/removed: -1. **For your specific distribution**, edit `/distros/{arch,debian,fedora,opensuse}.sh`: - - Modify `*_PACKAGES_TO_INSTALL` variables to add/remove packages - - Update `UNINSTALL_CMD` options for removal behavior +1. **General distribution packages** - Edit `/distros/{arch,debian,fedora,opensuse}.sh`: + - Modify category variables like `*_PACKAGES_TO_INSTALL` to add/remove packages + - Adjust package manager command options in `INSTALL_CMD`, `REMOVE_CMD`, etc. -2. **For debloating**, edit `/debloat/{arch,debian,fedora,opensuse}.txt`: - - Add or remove one package name per line - - Comment out lines starting with `#` to skip removal +2. **Debloat lists** - Edit `/debloat/{arch,debian,fedora,opensuse}.txt`: + - One package name per line to remove during setup + - Prefix with `#` to comment out and skip removal of specific packages -3. **For your specific distro version**, edit `/specific/{arch,debian,ubuntu,linuxmint,neon}.sh`: - - Add distro-specific hooks and configurations - - Override variables from `/distros` scripts if needed +3. **Version-specific configurations** - Edit `/specific/{arch,debian,ubuntu,linuxmint,neon}.sh`: + - Add distro-variant hooks before or after main installation + - Override or append to variables from `/distros` for custom behavior ### Customizing Desktop Environment Settings Edit the relevant dconf file in `/desktop/`: -- **GNOME**: Modify `gnome.dconf` (keybindings, schema settings, appearance) -- **XFCE**: Modify `xfce.dconf` (panel, window manager, workspace) -- **Cinnamon**: Modify `cinnamon.dconf` (animations, themes, effects) -- **Common**: Modify `common.dconf` (settings applied to all DEs) +- **GNOME**: Modify `gnome.dconf` for keybindings, workspaces, appearance, and extensions +- **XFCE**: Modify `xfce.dconf` for panel layout, window manager behavior, and workspaces +- **Cinnamon**: Modify `cinnamon.dconf` for animations, panel settings, and theme effects +- **KDE**: `kde.sh` handles automatable settings (KDE config is mostly UI-driven) +- **Common**: Modify `common.dconf` for settings applied across all desktop environments +- **GNOME Terminal**: Edit `gterm.dconf` for color schemes and terminal appearance +- **Linux Mint**: Edit `linuxmint.dconf` for Mint-specific settings -DConf files use a simple key=value format. See [DConf documentation](https://wiki.gnome.org/Projects/dconf) for details. +DConf files use `key=value` format (one setting per line). See [DConf documentation](https://wiki.gnome.org/Projects/dconf) for schema details and valid value types. ### Terminal Emulator Configuration -Configure terminal theme and appearance: +Configure your preferred terminal emulator: -- **Alacritty** (`.config/alacritty/alacritty.toml`): Edit for font, colors, padding -- **Kitty** (`.config/kitty/kitty.conf`): Edit for font, opacity, keybindings -- **WezTerm** (`.config/wezterm/wezterm.lua`): Configure with Lua scripting +- **Alacritty** (`.config/alacritty/alacritty.toml`): TOML format for font, colors, window padding, and opacity +- **Kitty** (`.config/kitty/kitty.conf`): INI format for fonts, keybindings, colors, and transparency +- **WezTerm** (`.config/wezterm/wezterm.lua`): Lua scripting for full terminal customization -Themes are downloaded from upstream projects (Catppuccin by default). +Color themes are automatically downloaded from upstream projects (Catppuccin Mocha by default). Customize fonts, enable ligatures, and adjust colors by editing the appropriate config file. ### Shell Aliases and Functions -Customize `/distros/{distro}.aliases` to add your own shell aliases sourced at login. +Distribution-specific aliases are defined in `/distros/{distro}.aliases` and automatically sourced by `.bashrc`. Add your own custom aliases to these files or directly to `.bashrc`. ## Logging and Debugging -The setup script creates a log file in your home directory for each run: -``` -~/setup-2026-02-21-14:30:45.log -``` - -View the log: +**Log File Location:** Each run creates a timestamped log in your home directory: ```bash -cat ~/setup-*.log -tail -f ~/setup-*.log # Follow in real-time +ls -la ~/setup-*.log # List all setup logs +cat ~/setup-*.log # View latest log +tail -100 ~/setup-*.log # View last 100 lines +tail -f ~/setup-*.log # Follow in real-time (for actively running setup) ``` +**Error Handling:** The script: +- Logs all warnings and non-critical failures without stopping the setup +- Continues executing subsequent steps even if some operations fail +- Timestamps logs so you can compare multiple runs and track changes over time +- Check the log file if unexpected behavior occurs or if some packages didn't install + ## Notes and Limitations -- **KDE Plasmi**: KDE's configuration system is complex and mostly UI-driven. The automation covers basic packages and themes only. Manual configuration of many settings is still required. -- **GDM Configuration**: Commented out in the main setup—uncomment `/desktop/gnome.sh` if you need to customize the login screen. -- **Waylan d/Xorg**: The script detects your current session; some settings may not apply if switching between Wayland and Xorg. -- **Interactive Setup**: The script includes interactive checks and may pause for confirmation on some steps. +- **KDE Plasma**: KDE's configuration is mostly UI-driven (`~/.config/kdedefaults/`). Automation handles only packages, themes, and a few key settings. Many customizations require manual configuration through the System Settings GUI. +- **GDM Login Screen**: GNOME Display Manager configuration is intentionally commented out in the main setup. Uncomment the relevant section in `setup-main.sh` if you want to customize the login screen. +- **Wayland vs Xorg**: The script auto-detects your session type. Some settings (especially DE-specific dconf values) may not apply correctly when switching between Wayland and Xorg--re-run the setup after switching. +- **Error Recovery**: Non-critical failures are logged as warnings and don't stop the setup. Check the setup log to identify which operations failed. +- **Package Availability**: Package availability varies across distro versions. Installation failures are logged but ignore; the setup continues with remaining packages. +- **File Conflicts**: If customization files exist before setup, they may be overwritten. Back up important configs in `.config/` before running the setup. ## Requirements -- **Supported Distributions**: Arch, Debian, Fedora, OpenSUSE (and their derivatives) -- **Sudo Access**: Required for system-level configuration -- **Internet Connection**: Needed for downloading packages and resources -- **curl**: Required for downloading remote files -- **jq**: JSON parser (installed during setup if not present) +- **Supported Distributions**: Arch, Debian, Fedora, OpenSUSE (and official derivatives) +- **Sudo Access**: Required for system-level package installation and configuration +- **Internet Connection**: Essential for downloading packages, themes, and fonts +- **curl**: Command-line tool for downloading remote scripts and packages +- **jq**: JSON query tool (auto-installed during setup if missing) +- **bash or sh**: POSIX-compatible shell (script is compatible with both) ## License @@ -205,14 +243,14 @@ This project is provided as-is for personal use and customization. ### Quick Start - Option #1 (Remote) Run without cloning this repo. It downloads required files when needed: -```bash -curl -fsSL https://raw.githubusercontent.com/krish-gh/linux-setup/main/setup.sh | bash +```sh +curl -fsSL https://raw.githubusercontent.com/krish-gh/linux-setup/main/setup.sh | sh ``` ### Option #2 (Local Clone) Clone the repo first and run from local files: -```bash +```sh git clone https://github.com/krish-gh/linux-setup.git && . linux-setup/setup.sh && rm -rf linux-setup diff --git a/desktop/cinnamon.sh b/desktop/cinnamon.sh index 45c24a5..df422a0 100644 --- a/desktop/cinnamon.sh +++ b/desktop/cinnamon.sh @@ -1,43 +1,44 @@ -#!/bin/bash +#!/bin/sh -# shellcheck disable=SC2034 GUI_TEXT_EDITOR=xed.desktop setup_cinnamon() { - echo -e "Configuring cinnamon stuffs..." + printf 'Configuring Cinnamon stuff...\n' install_pkgs "$CINNAMON_PACKAGES_TO_INSTALL" - #mkdir -p ~/.local/share/xed/styles - #copy_file ~/.local/share/xed/styles/mocha.xml https://raw.githubusercontent.com/catppuccin/xed/main/src/mocha.xml - - copy_file "$TEMP_DIR"/cinnamon.dconf "${BASE_REPO_LOCATION}"desktop/cinnamon.dconf - dconf load / <"$TEMP_DIR"/cinnamon.dconf - rm -f "$TEMP_DIR"/cinnamon.dconf + copy_file "$TEMP_DIR/cinnamon.dconf" "${BASE_REPO_LOCATION}desktop/cinnamon.dconf" && { + dconf load / < "$TEMP_DIR/cinnamon.dconf" 2>/dev/null || printf 'Warning: Failed to load dconf settings\n' >&2 + rm -f "$TEMP_DIR/cinnamon.dconf" + } # pinned apps - gwlconfigfile=$(ls ~/.config/cinnamon/spices/grouped-window-list@cinnamon.org/*.json) - gwlconfig="$(jq '(."pinned-apps".value) |= [ "nemo.desktop", "xed.desktop", "org.gnome.Terminal.desktop", "firefox.desktop" ]' "$gwlconfigfile")" && - echo -E "${gwlconfig}" >"$gwlconfigfile" + gwlconfigfile=$(ls ~/.config/cinnamon/spices/grouped-window-list@cinnamon.org/*.json 2>/dev/null) + if [ -n "$gwlconfigfile" ]; then + gwlconfig="$(jq '(."pinned-apps".value) |= [ "nemo.desktop", "xed.desktop", "org.gnome.Terminal.desktop", "firefox.desktop" ]' "$gwlconfigfile")" && \ + printf '%s\n' "$gwlconfig" > "$gwlconfigfile" + fi # menu - mconfigfile=$(ls ~/.config/cinnamon/spices/menu@cinnamon.org/*.json) - mconfig="$(jq '(."popup-height".value) |= 600' "$mconfigfile")" && - echo -E "${mconfig}" >"$mconfigfile" + mconfigfile=$(ls ~/.config/cinnamon/spices/menu@cinnamon.org/*.json 2>/dev/null) + if [ -n "$mconfigfile" ]; then + mconfig="$(jq '(."popup-height".value) |= 600' "$mconfigfile")" && \ + printf '%s\n' "$mconfig" > "$mconfigfile" + fi } setup_cinnamon_theme() { - gsettings set org.gnome.desktop.interface gtk-theme Mint-Y-Dark - gsettings set org.gnome.desktop.interface icon-theme Mint-Y - gsettings set org.cinnamon.desktop.interface gtk-theme Mint-Y-Dark - gsettings set org.cinnamon.desktop.interface icon-theme Mint-Y - gsettings set org.cinnamon.theme name Mint-Y-Dark - sudo crudini --ini-options=nospace --set /etc/lightdm/slick-greeter.conf Greeter theme-name Mint-Y-Dark - sudo crudini --ini-options=nospace --set /etc/lightdm/slick-greeter.conf Greeter icon-theme-name Mint-Y + gsettings set org.gnome.desktop.interface gtk-theme Mint-Y-Dark 2>/dev/null || true + gsettings set org.gnome.desktop.interface icon-theme Mint-Y 2>/dev/null || true + gsettings set org.cinnamon.desktop.interface gtk-theme Mint-Y-Dark 2>/dev/null || true + gsettings set org.cinnamon.desktop.interface icon-theme Mint-Y 2>/dev/null || true + gsettings set org.cinnamon.theme name Mint-Y-Dark 2>/dev/null || true + sudo crudini --ini-options=nospace --set /etc/lightdm/slick-greeter.conf Greeter theme-name Mint-Y-Dark 2>/dev/null || true + sudo crudini --ini-options=nospace --set /etc/lightdm/slick-greeter.conf Greeter icon-theme-name Mint-Y 2>/dev/null || true } set_cinnamon_wallpaper() { - # shellcheck disable=SC2046 - gsettings set org.cinnamon.desktop.background picture-uri "file://$1" + # Set wallpaper for Cinnamon desktop + gsettings set org.cinnamon.desktop.background picture-uri "file://$1" 2>/dev/null || true } -echo -e "Done cinnamon.sh..." +printf 'Done cinnamon.sh...\n' diff --git a/desktop/gnome.sh b/desktop/gnome.sh index 0e36927..e46e8a6 100644 --- a/desktop/gnome.sh +++ b/desktop/gnome.sh @@ -1,60 +1,65 @@ -#!/bin/bash +#!/bin/sh -# shellcheck disable=SC2034 GUI_TEXT_EDITOR=org.gnome.TextEditor.desktop setup_gnome() { - echo -e "Configuring gnome stuffs..." + printf 'Configuring GNOME stuff...\n' install_pkgs "$GNOME_PACKAGES_TO_INSTALL" - # GDM - #sudo mkdir -p /etc/dconf/db/gdm.d - #copy_file 95-gdm-settings ${BASE_REPO_LOCATION}system/etc/dconf/db/gdm.d/95-gdm-settings - #sudo mv -f 95-gdm-settings /etc/dconf/db/gdm.d/ - - echo -e "Installing some extensions..." + printf 'Installing some extensions...\n' if command_exists flatpak; then - $FLATPAK_INSTALL_CMD com.mattjakeman.ExtensionManager + sh -c "$FLATPAK_INSTALL_CMD com.mattjakeman.ExtensionManager" || printf 'Warning: Failed to install extension manager\n' >&2 else install_pkgs "$GNOME_EXT_MGR_PKG" fi - pipx ensurepath - pipx install gnome-extensions-cli --system-site-packages - - declare -A exts - exts[1]=AlphabeticalAppGrid@stuarthayhurst - exts[2]=clipboard-indicator@tudmotu.com - exts[3]=status-area-horizontal-spacing@mathematical.coffee.gmail.com - exts[4]=xwayland-indicator@swsnr.de - exts[5]=apps-menu@gnome-shell-extensions.gcampax.github.com - [[ $DIST_ID != ubuntu ]] && exts[6]=appindicatorsupport@rgcjonas.gmail.com - [[ $DIST_ID != ubuntu ]] && exts[7]=dash-to-dock@micxgx.gmail.com - [[ $DISTRO_TYPE == arch ]] && exts[arch]=arch-update@RaphaelRochet - [[ $DISTRO_TYPE == debian ]] && exts[debian]=debian-updates-indicator@glerro.pm.me - [[ $DISTRO_TYPE == fedora ]] && exts[fedora]=update-extension@purejava.org + + if command_exists pipx; then + pipx ensurepath >/dev/null 2>&1 || true + pipx install gnome-extensions-cli --system-site-packages 2>/dev/null || printf 'Warning: Failed to install gnome-extensions-cli\n' >&2 + else + printf 'Warning: pipx not found, skipping gnome-extensions-cli\n' >&2 + return + fi + + # POSIX-compatible extension list (using space-separated string instead of associative array) + exts='AlphabeticalAppGrid@stuarthayhurst clipboard-indicator@tudmotu.com status-area-horizontal-spacing@mathematical.coffee.gmail.com xwayland-indicator@swsnr.de apps-menu@gnome-shell-extensions.gcampax.github.com' + + if [ "$DIST_ID" != "ubuntu" ]; then + exts="$exts appindicatorsupport@rgcjonas.gmail.com dash-to-dock@micxgx.gmail.com" + fi + + if [ "$DISTRO_TYPE" = "arch" ]; then + exts="$exts arch-update@RaphaelRochet" + elif [ "$DISTRO_TYPE" = "debian" ]; then + exts="$exts debian-updates-indicator@glerro.pm.me" + elif [ "$DISTRO_TYPE" = "fedora" ]; then + exts="$exts update-extension@purejava.org" + fi extdir=~/.local/share/gnome-shell/extensions - for i in "${exts[@]}"; do - ~/.local/bin/gnome-extensions-cli --filesystem install "$i" - [[ -d $extdir/"$i"/schemas ]] && glib-compile-schemas $extdir/"$i"/schemas/ + for i in $exts; do + ~/.local/bin/gnome-extensions-cli --filesystem install "$i" 2>/dev/null || printf 'Warning: Failed to install extension %s\n' "$i" >&2 + [ -d "$extdir/$i/schemas" ] && glib-compile-schemas "$extdir/$i/schemas/" 2>/dev/null || true done - if [[ $TERMINAL_TO_INSTALL != none ]]; then - python -m pip install --user --upgrade nautilus-open-any-terminal - glib-compile-schemas ~/.local/share/glib-2.0/schemas/ - gsettings set com.github.stunkymonkey.nautilus-open-any-terminal terminal "$TERMINAL_TO_INSTALL" + if [ "$TERMINAL_TO_INSTALL" != "none" ]; then + python -m pip install --user --upgrade nautilus-open-any-terminal 2>/dev/null || printf 'Warning: Failed to install nautilus-open-any-terminal\n' >&2 + glib-compile-schemas ~/.local/share/glib-2.0/schemas/ 2>/dev/null || true + gsettings set com.github.stunkymonkey.nautilus-open-any-terminal terminal "$TERMINAL_TO_INSTALL" 2>/dev/null || true fi - copy_file "$TEMP_DIR"/gnome.dconf "${BASE_REPO_LOCATION}"desktop/gnome.dconf - dconf load / <"$TEMP_DIR"/gnome.dconf - rm -f "$TEMP_DIR"/gnome.dconf + copy_file "$TEMP_DIR/gnome.dconf" "${BASE_REPO_LOCATION}desktop/gnome.dconf" && { + dconf load / < "$TEMP_DIR/gnome.dconf" 2>/dev/null || printf 'Warning: Failed to load dconf settings\n' >&2 + rm -f "$TEMP_DIR/gnome.dconf" + } } set_gnome_wallpaper() { - # shellcheck disable=SC2046 - gsettings set org.gnome.desktop.background picture-uri "file://$1" - gsettings set org.gnome.desktop.background picture-uri-dark "file://$1" + # Set both light and dark wallpaper + wallpaper_uri="file://$1" + gsettings set org.gnome.desktop.background picture-uri "$wallpaper_uri" 2>/dev/null || true + gsettings set org.gnome.desktop.background picture-uri-dark "$wallpaper_uri" 2>/dev/null || true } -echo -e "Done gnome.sh..." +printf 'Done gnome.sh...\n' diff --git a/desktop/kde.sh b/desktop/kde.sh index a370db1..2203bb9 100644 --- a/desktop/kde.sh +++ b/desktop/kde.sh @@ -1,75 +1,67 @@ -#!/bin/bash +#!/bin/sh -# shellcheck disable=SC2034 GUI_TEXT_EDITOR=org.kde.kwrite.desktop setup_kde() { - echo -e "Configuring kde stuffs..." + printf 'Configuring KDE Plasma stuff...\n' install_pkgs "$KDE_PACKAGES_TO_INSTALL" - # No need for qt theme in kde environment - #[[ -f ~/.config/environment.d/10-defaults.conf ]] && sed -i '/QT_QPA_PLATFORMTHEME/s/^/#/' ~/.config/environment.d/10-defaults.conf - #[[ -f ~/.profile ]] && sed -i '/QT_QPA_PLATFORMTHEME/s/^/#/' ~/.profile - #[[ -f ~/.xprofile ]] && sed -i '/QT_QPA_PLATFORMTHEME/s/^/#/' ~/.xprofile - #[[ -f ~/.config/systemd/user/service.d/env.conf ]] && sed -i '/QT_QPA_PLATFORMTHEME/s/^/#/' ~/.config/systemd/user/service.d/env.conf - KWRITECONFIG_CMD=kwriteconfig6 - ! command_exists kwriteconfig6 && KWRITECONFIG_CMD=kwriteconfig5 + if ! command_exists kwriteconfig6; then + KWRITECONFIG_CMD=kwriteconfig5 + fi # configs - lookandfeeltool -a org.kde.breezedark.desktop - kscreen-doctor output.1.scale.1.25 + lookandfeeltool -a org.kde.breezedark.desktop 2>/dev/null || printf 'Warning: Failed to set lookandfeel\n' >&2 + kscreen-doctor output.1.scale.1.25 2>/dev/null || true sudo mkdir -p /etc/sddm.conf.d - sudo $KWRITECONFIG_CMD --file /etc/sddm.conf.d/kde_settings.conf --group Theme --key Current breeze - sudo $KWRITECONFIG_CMD --file /etc/sddm.conf.d/kde_settings.conf --group Theme --key CursorTheme breeze_cursors + sudo "$KWRITECONFIG_CMD" --file /etc/sddm.conf.d/kde_settings.conf --group Theme --key Current breeze + sudo "$KWRITECONFIG_CMD" --file /etc/sddm.conf.d/kde_settings.conf --group Theme --key CursorTheme breeze_cursors sudo chmod -R +r /etc/sddm.conf.d/ - $KWRITECONFIG_CMD --file ~/.config/kdeglobals --group Sounds --key Enable false - $KWRITECONFIG_CMD --file ~/.config/kdeglobals --group KScreen --key ScaleFactor 1.25 - $KWRITECONFIG_CMD --file ~/.config/kwinrc --group Xwayland --key Scale 1.25 - #kwinoutputconfig="$(jq '(.[] | select(.name == "outputs") | .data | .[] | .scale) |= 1.25' ~/.config/kwinoutputconfig.json)" && \ - # echo -E "${kwinoutputconfig}" > ~/.config/kwinoutputconfig.json - $KWRITECONFIG_CMD --file ~/.config/plasmashellrc --group PlasmaViews --group "Panel 2" --group Defaults --key thickness 30 - $KWRITECONFIG_CMD --file ~/.config/plasma-org.kde.plasma.desktop-appletsrc --group Containments --group 2 --group Applets --group 5 --group Configuration --group General \ - --key launchers "preferred://filemanager,applications:org.kde.kwrite.desktop,applications:org.kde.konsole.desktop,preferred://browser" - $KWRITECONFIG_CMD --file ~/.config/kactivitymanagerd-pluginsrc --group Plugin-org.kde.ActivityManager.Resources.Scoring --key what-to-remember 2 - $KWRITECONFIG_CMD --file ~/.config/krunnerrc --group Plugins --key baloosearchEnabled false - $KWRITECONFIG_CMD --file ~/.config/baloofilerc --group "Basic Settings" --key Indexing-Enabled false + "$KWRITECONFIG_CMD" --file ~/.config/kdeglobals --group Sounds --key Enable false + "$KWRITECONFIG_CMD" --file ~/.config/kdeglobals --group KScreen --key ScaleFactor 1.25 + "$KWRITECONFIG_CMD" --file ~/.config/kwinrc --group Xwayland --key Scale 1.25 + "$KWRITECONFIG_CMD" --file ~/.config/plasmashellrc --group PlasmaViews --group "Panel 2" --group Defaults --key thickness 30 + "$KWRITECONFIG_CMD" --file ~/.config/plasma-org.kde.plasma.desktop-appletsrc --group Containments --group 2 --group Applets --group 5 --group Configuration --group General --key launchers "preferred://filemanager,applications:org.kde.kwrite.desktop,applications:org.kde.konsole.desktop,preferred://browser" + "$KWRITECONFIG_CMD" --file ~/.config/kactivitymanagerd-pluginsrc --group Plugin-org.kde.ActivityManager.Resources.Scoring --key what-to-remember 2 + "$KWRITECONFIG_CMD" --file ~/.config/krunnerrc --group Plugins --key baloosearchEnabled false + "$KWRITECONFIG_CMD" --file ~/.config/baloofilerc --group "Basic Settings" --key Indexing-Enabled false rm -f ~/.local/share/baloo/index - $KWRITECONFIG_CMD --file ~/.config/powerdevilrc --group AC --group Display --key TurnOffDisplayIdleTimeoutSec -1 - $KWRITECONFIG_CMD --file ~/.config/powerdevilrc --group AC --group Display --key TurnOffDisplayWhenIdle false + "$KWRITECONFIG_CMD" --file ~/.config/powerdevilrc --group AC --group Display --key TurnOffDisplayIdleTimeoutSec -1 + "$KWRITECONFIG_CMD" --file ~/.config/powerdevilrc --group AC --group Display --key TurnOffDisplayWhenIdle false # dolphin mkdir -p ~/.local/share/dolphin/view_properties/global - $KWRITECONFIG_CMD --file ~/.local/share/dolphin/view_properties/global/.directory --group Settings --key HiddenFilesShown true + "$KWRITECONFIG_CMD" --file ~/.local/share/dolphin/view_properties/global/.directory --group Settings --key HiddenFilesShown true # konsole - copy_file ~/.local/share/konsole/catppuccin-mocha.colorscheme https://raw.githubusercontent.com/catppuccin/konsole/main/themes/catppuccin-mocha.colorscheme - $KWRITECONFIG_CMD --file ~/.local/share/konsole/custom.profile --group Appearance --key ColorScheme catppuccin-mocha - $KWRITECONFIG_CMD --file ~/.local/share/konsole/custom.profile --group Appearance --key Font "JetBrainsMono Nerd Font,12" - $KWRITECONFIG_CMD --file ~/.local/share/konsole/custom.profile --group Appearance --key UseFontLineChararacters true - $KWRITECONFIG_CMD --file ~/.local/share/konsole/custom.profile --group General --key Name custom - $KWRITECONFIG_CMD --file ~/.local/share/konsole/custom.profile --group General --key TerminalColumns 120 - $KWRITECONFIG_CMD --file ~/.local/share/konsole/custom.profile --group General --key TerminalRows 36 - $KWRITECONFIG_CMD --file ~/.config/konsolerc --group "Desktop Entry" --key DefaultProfile custom.profile - $KWRITECONFIG_CMD --file ~/.config/konsolerc --group KonsoleWindow --key RememberWindowSize false - $KWRITECONFIG_CMD --file ~/.config/konsolerc --group KonsoleWindow --key UseSingleInstance true + copy_file ~/.local/share/konsole/catppuccin-mocha.colorscheme https://raw.githubusercontent.com/catppuccin/konsole/main/themes/catppuccin-mocha.colorscheme || true + "$KWRITECONFIG_CMD" --file ~/.local/share/konsole/custom.profile --group Appearance --key ColorScheme catppuccin-mocha + "$KWRITECONFIG_CMD" --file ~/.local/share/konsole/custom.profile --group Appearance --key Font "JetBrainsMono Nerd Font,12" + "$KWRITECONFIG_CMD" --file ~/.local/share/konsole/custom.profile --group Appearance --key UseFontLineChararacters true + "$KWRITECONFIG_CMD" --file ~/.local/share/konsole/custom.profile --group General --key Name custom + "$KWRITECONFIG_CMD" --file ~/.local/share/konsole/custom.profile --group General --key TerminalColumns 120 + "$KWRITECONFIG_CMD" --file ~/.local/share/konsole/custom.profile --group General --key TerminalRows 36 + "$KWRITECONFIG_CMD" --file ~/.config/konsolerc --group "Desktop Entry" --key DefaultProfile custom.profile + "$KWRITECONFIG_CMD" --file ~/.config/konsolerc --group KonsoleWindow --key RememberWindowSize false + "$KWRITECONFIG_CMD" --file ~/.config/konsolerc --group KonsoleWindow --key UseSingleInstance true # kate - $KWRITECONFIG_CMD --file ~/.config/katerc --group General --key "Close After Last" true - $KWRITECONFIG_CMD --file ~/.config/katerc --group General --key "Restore Window Configuration" false - $KWRITECONFIG_CMD --file ~/.config/katerc --group General --key "Save Meta Infos" false - $KWRITECONFIG_CMD --file ~/.config/katerc --group "KTextEditor Renderer" --key "Color Theme" "Catppuccin Mocha" - $KWRITECONFIG_CMD --file ~/.config/katerc --group "KTextEditor Renderer" --key "Auto Color Theme Selection" false - $KWRITECONFIG_CMD --file ~/.config/katerc --group "KTextEditor Renderer" --key "Text Font" "JetBrainsMono Nerd Font,12" + "$KWRITECONFIG_CMD" --file ~/.config/katerc --group General --key "Close After Last" true + "$KWRITECONFIG_CMD" --file ~/.config/katerc --group General --key "Restore Window Configuration" false + "$KWRITECONFIG_CMD" --file ~/.config/katerc --group General --key "Save Meta Infos" false + "$KWRITECONFIG_CMD" --file ~/.config/katerc --group "KTextEditor Renderer" --key "Color Theme" "Catppuccin Mocha" + "$KWRITECONFIG_CMD" --file ~/.config/katerc --group "KTextEditor Renderer" --key "Auto Color Theme Selection" false + "$KWRITECONFIG_CMD" --file ~/.config/katerc --group "KTextEditor Renderer" --key "Text Font" "JetBrainsMono Nerd Font,12" # kwrite - $KWRITECONFIG_CMD --file ~/.config/kwriterc --group General --key "Close After Last" true - $KWRITECONFIG_CMD --file ~/.config/kwriterc --group General --key "Restore Window Configuration" false - $KWRITECONFIG_CMD --file ~/.config/kwriterc --group General --key "Save Meta Infos" false - $KWRITECONFIG_CMD --file ~/.config/kwriterc --group "KTextEditor Renderer" --key "Color Theme" "Catppuccin Mocha" - $KWRITECONFIG_CMD --file ~/.config/kwriterc --group "KTextEditor Renderer" --key "Auto Color Theme Selection" false - $KWRITECONFIG_CMD --file ~/.config/kwriterc --group "KTextEditor Renderer" --key "Text Font" "JetBrainsMono Nerd Font,12" + "$KWRITECONFIG_CMD" --file ~/.config/kwriterc --group General --key "Close After Last" true + "$KWRITECONFIG_CMD" --file ~/.config/kwriterc --group General --key "Restore Window Configuration" false + "$KWRITECONFIG_CMD" --file ~/.config/kwriterc --group General --key "Save Meta Infos" false + "$KWRITECONFIG_CMD" --file ~/.config/kwriterc --group "KTextEditor Renderer" --key "Color Theme" "Catppuccin Mocha" + "$KWRITECONFIG_CMD" --file ~/.config/kwriterc --group "KTextEditor Renderer" --key "Auto Color Theme Selection" false + "$KWRITECONFIG_CMD" --file ~/.config/kwriterc --group "KTextEditor Renderer" --key "Text Font" "JetBrainsMono Nerd Font,12" } -echo -e "Done kde.sh..." +printf 'Done kde.sh...\n' diff --git a/desktop/xfce.sh b/desktop/xfce.sh index 8f550db..c8731f4 100644 --- a/desktop/xfce.sh +++ b/desktop/xfce.sh @@ -1,10 +1,9 @@ -#!/bin/bash +#!/bin/sh -# shellcheck disable=SC2034 GUI_TEXT_EDITOR=org.xfce.mousepad.desktop setup_xfce() { - echo -e "Configuring xfce stuffs..." + printf 'Configuring xfce stuffs...\n' install_pkgs "$XFCE_PACKAGES_TO_INSTALL" # config @@ -53,30 +52,31 @@ setup_xfce() { xfconf-query -c thunar-volman -v -n -p /automount-drives/enabled -t bool -s false xfconf-query -c thunar-volman -v -n -p /automount-media/enabled -t bool -s false - copy_file "$TEMP_DIR"/xfce.dconf "${BASE_REPO_LOCATION}"desktop/xfce.dconf - dconf load / <"$TEMP_DIR"/xfce.dconf - rm -f "$TEMP_DIR"/xfce.dconf + copy_file "$TEMP_DIR/xfce.dconf" "${BASE_REPO_LOCATION}desktop/xfce.dconf" && { + dconf load / < "$TEMP_DIR/xfce.dconf" 2>/dev/null || printf 'Warning: Failed to load dconf settings\n' >&2 + rm -f "$TEMP_DIR/xfce.dconf" + } } setup_xfce_panel() { - echo -e "Configuring xfce panel from scratch..." + printf 'Configuring xfce panel from scratch...\n' xfce4-panel --quit pkill xfconfd rm -rf ~/.config/xfce4/panel/launcher-* - mkdir -p ~/.config/xfce4/panel/launcher-{2,3,4,5} - copy_file ~/.config/xfce4/panel/launcher-2/FileManager.desktop "${BASE_REPO_LOCATION}"home/.config/xfce4/panel/launcher-2/FileManager.desktop - copy_file ~/.config/xfce4/panel/launcher-3/TextEditor.desktop "${BASE_REPO_LOCATION}"home/.config/xfce4/panel/launcher-3/TextEditor.desktop - copy_file ~/.config/xfce4/panel/launcher-4/TerminalEmulator.desktop "${BASE_REPO_LOCATION}"home/.config/xfce4/panel/launcher-4/TerminalEmulator.desktop - copy_file ~/.config/xfce4/panel/launcher-5/WebBrowser.desktop "${BASE_REPO_LOCATION}"home/.config/xfce4/panel/launcher-5/WebBrowser.desktop - copy_file ~/.config/xfce4/panel/whiskermenu-1.rc "${BASE_REPO_LOCATION}"home/.config/xfce4/panel/whiskermenu-1.rc - copy_file ~/.config/xfce4/xfconf/xfce-perchannel-xml/xfce4-panel.xml "${BASE_REPO_LOCATION}"home/.config/xfce4/xfconf/xfce-perchannel-xml/xfce4-panel.xml - sed -i "s/DISTRO_LOGO/$XFCE_MENU_LOGO/g" ~/.config/xfce4/xfconf/xfce-perchannel-xml/xfce4-panel.xml - sed -i "s/DISTRO_LOGO/$XFCE_MENU_LOGO/g" ~/.config/xfce4/panel/whiskermenu-1.rc + mkdir -p ~/.config/xfce4/panel/launcher-2 ~/.config/xfce4/panel/launcher-3 ~/.config/xfce4/panel/launcher-4 ~/.config/xfce4/panel/launcher-5 + copy_file ~/.config/xfce4/panel/launcher-2/FileManager.desktop "${BASE_REPO_LOCATION}home/.config/xfce4/panel/launcher-2/FileManager.desktop" + copy_file ~/.config/xfce4/panel/launcher-3/TextEditor.desktop "${BASE_REPO_LOCATION}home/.config/xfce4/panel/launcher-3/TextEditor.desktop" + copy_file ~/.config/xfce4/panel/launcher-4/TerminalEmulator.desktop "${BASE_REPO_LOCATION}home/.config/xfce4/panel/launcher-4/TerminalEmulator.desktop" + copy_file ~/.config/xfce4/panel/launcher-5/WebBrowser.desktop "${BASE_REPO_LOCATION}home/.config/xfce4/panel/launcher-5/WebBrowser.desktop" + copy_file ~/.config/xfce4/panel/whiskermenu-1.rc "${BASE_REPO_LOCATION}home/.config/xfce4/panel/whiskermenu-1.rc" + copy_file ~/.config/xfce4/xfconf/xfce-perchannel-xml/xfce4-panel.xml "${BASE_REPO_LOCATION}home/.config/xfce4/xfconf/xfce-perchannel-xml/xfce4-panel.xml" + sed_i "s/DISTRO_LOGO/${XFCE_MENU_LOGO}/g" ~/.config/xfce4/xfconf/xfce-perchannel-xml/xfce4-panel.xml + sed_i "s/DISTRO_LOGO/${XFCE_MENU_LOGO}/g" ~/.config/xfce4/panel/whiskermenu-1.rc xfce4-panel > /dev/null 2>&1 & disown } setup_xfce_theme() { - echo -e "Making xfce look better..." + printf 'Making xfce look better...\n' gsettings set org.gnome.desktop.interface gtk-theme Materia-dark gsettings set org.gnome.desktop.interface icon-theme Papirus-Dark xfconf-query -c xsettings -v -n -p /Net/ThemeName -t string -s Materia-dark @@ -87,8 +87,7 @@ setup_xfce_theme() { } set_xfce_wallpaper() { - # shellcheck disable=SC2046 - xfconf-query -c xfce4-desktop -p $(xfconf-query -c xfce4-desktop -l | grep "workspace0/last-image") -t string -s "$1" + xfconf-query -c xfce4-desktop -p "$(xfconf-query -c xfce4-desktop -l | grep 'workspace0/last-image')" -t string -s "$1" } -echo -e "Done xfce.sh..." +printf 'Done xfce.sh...\n' diff --git a/distros/arch.aliases b/distros/arch.aliases index 277dbae..4f8e966 100644 --- a/distros/arch.aliases +++ b/distros/arch.aliases @@ -1,11 +1,8 @@ #!/bin/sh -# shellcheck disable=SC2139 -# shellcheck disable=SC3009 -# shellcheck disable=SC3020 alias sudo='sudo -E -H ' alias e='sudo systemctl --failed --no-pager; sudo journalctl -p 3 -b' alias cls='clear' -alias u='sudo pacman -Syu; command -v flatpak &> /dev/null && flatpak update; command -v snap &> /dev/null && sudo snap refresh; command -v pipx &> /dev/null && pipx upgrade-all' +alias u='sudo pacman -Syu; command -v flatpak >/dev/null 2>&1 && flatpak update; command -v snap >/dev/null 2>&1 && sudo snap refresh; command -v pipx >/dev/null 2>&1 && pipx upgrade-all' alias uu='yay -Syu' alias i='sudo pacman -S --needed' alias ii='yay -S --needed' @@ -17,8 +14,8 @@ alias rr='yay -Rns' alias b='pacman -Qqen > pkglist.txt && echo >> pkglist.txt && pacman -Qm >> pkglist.txt && echo >> pkglist.txt' alias c='paccache -r; yay -Yc; yay -Sc; yay -Rns $(yay -Qtdq)' alias x='exit' -command -v gnome-text-editor &> /dev/null && alias {gte,gted}='gnome-text-editor' -if command -v fastfetch &> /dev/null; then +command -v gnome-text-editor >/dev/null 2>&1 && alias gte='gnome-text-editor' && alias gted='gnome-text-editor' +if command -v fastfetch >/dev/null 2>&1; then alias neofetch='fastfetch' else alias fastfetch='neofetch' @@ -31,7 +28,7 @@ alias ff='fastfetch' alias ua-drop-caches='sudo paccache -rk1; yay -Sc --aur --noconfirm' alias ua-rate='sudo true; \ rate-mirrors --disable-comments-in-file --protocol=https arch --max-delay=120 | sudo tee /etc/pacman.d/mirrorlist; \ - [[ -f /etc/pacman.d/endeavouros-mirrorlist ]] && rate-mirrors --disable-comments-in-file --protocol=https endeavouros | sudo tee /etc/pacman.d/endeavouros-mirrorlist; \ - [[ -f /etc/pacman.d/chaotic-mirrorlist ]] && rate-mirrors --disable-comments-in-file --protocol=https chaotic-aur | sudo tee /etc/pacman.d/chaotic-mirrorlist; \ + [ -f /etc/pacman.d/endeavouros-mirrorlist ] && rate-mirrors --disable-comments-in-file --protocol=https endeavouros | sudo tee /etc/pacman.d/endeavouros-mirrorlist; \ + [ -f /etc/pacman.d/chaotic-mirrorlist ] && rate-mirrors --disable-comments-in-file --protocol=https chaotic-aur | sudo tee /etc/pacman.d/chaotic-mirrorlist; \ ua-drop-caches; yay -Syyu --noconfirm' diff --git a/distros/arch.sh b/distros/arch.sh index 3145930..0b5b8fa 100644 --- a/distros/arch.sh +++ b/distros/arch.sh @@ -1,6 +1,5 @@ -#!/bin/bash +#!/bin/sh -# shellcheck disable=SC2034 REFRESH_CMD="sudo pacman -Sy" UPDATE_CMD="sudo pacman -Syu --noconfirm" INSTALL_CMD="sudo pacman -S --needed --noconfirm" @@ -8,69 +7,59 @@ UNINSTALL_CMD="sudo pacman -Rns --noconfirm" UNINSTALL_ONLY_CMD="sudo pacman -Rns --noconfirm" REQUIREMENTS="curl wget unzip xorg-xrdb dconf jq crudini" -SYSTEM_PACKAGES_TO_INSTALL="fwupd vulkan-{mesa-layers,swrast,icd-loader} alsa-{firmware,ucm-conf} sof-firmware fprintd power-profiles-daemon" +SYSTEM_PACKAGES_TO_INSTALL="fwupd vulkan-mesa-layers vulkan-swrast vulkan-icd-loader alsa-firmware alsa-ucm-conf sof-firmware fprintd power-profiles-daemon" INTEL_PACKAGES_TO_INSTALL="intel-media-driver vulkan-intel" VMWARE_PACKAGES_TO_INSTALL="gtkmm gtkmm3 open-vm-tools" VBOX_PACKAGES_TO_INSTALL="virtualbox-guest-utils" HYPERV_PACKAGES_TO_INSTALL="hyperv" VIRT_PACKAGES_TO_INSTALL="qemu-guest-agent" -FONTS_TO_INSTALL="noto-fonts{,-emoji} ttf-{liberation,dejavu,droid,roboto,ubuntu-font-family,jetbrains-mono-nerd}" +FONTS_TO_INSTALL="noto-fonts noto-fonts-emoji ttf-liberation ttf-dejavu ttf-droid ttf-roboto ttf-ubuntu-font-family ttf-jetbrains-mono-nerd" TERM_PACKAGES_TO_INSTALL="bash-completion nano-syntax-highlighting starship fastfetch" -APP_PACKAGES_TO_INSTALL="pacman-contrib firefox{,-i18n-en-gb,-i18n-en-us} gnome-keyring seahorse vlc onboard yay rate-mirrors reflector-simple" +APP_PACKAGES_TO_INSTALL="pacman-contrib firefox firefox-i18n-en-gb firefox-i18n-en-us gnome-keyring seahorse vlc onboard yay rate-mirrors reflector-simple" DEV_PACKAGES_TO_INSTALL="git base-devel python-pip shfmt diffutils meld github-cli visual-studio-code-bin" GTK_PACKAGES_TO_INSTALL="xdg-desktop-portal-gtk gnome-themes-extra" -QT_PACKAGES_TO_INSTALL="qt{5,6}-wayland" -QT_PATCHES_TO_INSTALL="kvantum-qt5 qt{5,6}ct" -GNOME_PACKAGES_TO_INSTALL="gnome-{menus,tweaks,terminal,text-editor} evolution-data-server python-nautilus python-pipx $QT_PATCHES_TO_INSTALL" +QT_PACKAGES_TO_INSTALL="qt5-wayland qt6-wayland" +QT_PATCHES_TO_INSTALL="kvantum-qt5 qt5ct qt6ct" +GNOME_PACKAGES_TO_INSTALL="gnome-menus gnome-tweaks gnome-terminal gnome-text-editor evolution-data-server python-nautilus python-pipx $QT_PATCHES_TO_INSTALL" GNOME_EXT_MGR_PKG="extension-manager" KDE_PACKAGES_TO_INSTALL="plasma-meta gwenview kcalc kfind kwrite okular spectacle" -CINNAMON_PACKAGES_TO_INSTALL="x-apps nemo-emblems nemo-fileroller nemo-preview nemo-python xviewer{,-plugins} mint-{themes,y-icons} $QT_PATCHES_TO_INSTALL" +CINNAMON_PACKAGES_TO_INSTALL="x-apps nemo-emblems nemo-fileroller nemo-preview nemo-python xviewer xviewer-plugins mint-themes mint-y-icons $QT_PATCHES_TO_INSTALL" XFCE_PACKAGES_TO_INSTALL="xfce4 xfce4-whiskermenu-plugin xfce4-clipman-plugin xfce4-screenshooter xfce4-taskmanager light-locker lightdm-slick-greeter lightdm-settings $QT_PATCHES_TO_INSTALL" XFCE_MENU_LOGO="distributor-logo-archlinux" PACKAGES_TO_REMOVE="" setup_arch() { - if [[ -f /etc/vconsole.conf ]]; then - vsconsoleAppend="$( - grep "FONT=" /etc/vconsole.conf >/dev/null 2>&1 - echo $? - )" - if [[ "${vsconsoleAppend}" -ne 0 ]]; then - echo -e "FONT is not set in vconsole.conf, updating..." - echo -e 'FONT="eurlatgr"' | sudo tee -a /etc/vconsole.conf + if [ -f /etc/vconsole.conf ]; then + if ! grep -q "FONT=" /etc/vconsole.conf; then + printf 'FONT is not set in vconsole.conf, updating...\n' + printf 'FONT="eurlatgr"\n' | sudo tee -a /etc/vconsole.conf >/dev/null fi fi - echo -e "Doing some cool stuffs in /etc/pacman.conf ..." - sudo sed -i "/^#Color/c\Color\nILoveCandy - /^#VerbosePkgLists/c\VerbosePkgLists - /^#ParallelDownloads/c\ParallelDownloads = 5" /etc/pacman.conf - sudo sed -i '/^#\[multilib\]/,+1 s/^#//' /etc/pacman.conf + printf 'Doing some cool stuff in /etc/pacman.conf...\n' + sudo sed_i "/^#Color/c\\Color\\nILoveCandy" /etc/pacman.conf + sudo sed_i "/^#VerbosePkgLists/c\\VerbosePkgLists" /etc/pacman.conf + sudo sed_i "/^#ParallelDownloads/c\\ParallelDownloads = 5" /etc/pacman.conf + sudo sed_i '/^#\[multilib\]/,+1 s/^#//' /etc/pacman.conf # https://aur.chaotic.cx/docs - if [[ ! -f /etc/pacman.d/chaotic-mirrorlist ]]; then - echo -e "Configuring Chaotic-AUR..." - sudo pacman-key --recv-key 3056513887B78AEB --keyserver keyserver.ubuntu.com - sudo pacman-key --lsign-key 3056513887B78AEB - sudo pacman -U --noconfirm 'https://cdn-mirror.chaotic.cx/chaotic-aur/chaotic-keyring.pkg.tar.zst' - sudo pacman -U --noconfirm 'https://cdn-mirror.chaotic.cx/chaotic-aur/chaotic-mirrorlist.pkg.tar.zst' + if [ ! -f /etc/pacman.d/chaotic-mirrorlist ]; then + printf 'Configuring Chaotic-AUR...\n' + sudo pacman-key --recv-key 3056513887B78AEB --keyserver keyserver.ubuntu.com 2>/dev/null || printf 'Warning: Failed to receive key\n' >&2 + sudo pacman-key --lsign-key 3056513887B78AEB 2>/dev/null || printf 'Warning: Failed to sign key\n' >&2 + sudo pacman -U --noconfirm 'https://cdn-mirror.chaotic.cx/chaotic-aur/chaotic-keyring.pkg.tar.zst' 2>/dev/null || printf 'Warning: Failed to install chaotic-keyring\n' >&2 + sudo pacman -U --noconfirm 'https://cdn-mirror.chaotic.cx/chaotic-aur/chaotic-mirrorlist.pkg.tar.zst' 2>/dev/null || printf 'Warning: Failed to install chaotic-mirrorlist\n' >&2 fi - chaoticAurAppend="$( - grep "chaotic-aur" /etc/pacman.conf >/dev/null 2>&1 - echo $? - )" - if [[ "${chaoticAurAppend}" -ne 0 ]]; then - echo "Appending Chaotic-AUR in pacman.conf..." - echo -e | sudo tee -a /etc/pacman.conf - echo -e "[chaotic-aur]" | sudo tee -a /etc/pacman.conf - echo -e "Include = /etc/pacman.d/chaotic-mirrorlist" | sudo tee -a /etc/pacman.conf + if ! grep -q "chaotic-aur" /etc/pacman.conf; then + printf 'Appending Chaotic-AUR in pacman.conf...\n' + printf '\n[chaotic-aur]\nInclude = /etc/pacman.d/chaotic-mirrorlist\n' | sudo tee -a /etc/pacman.conf >/dev/null fi refresh_package_sources - echo -e "Installing some stuffs..." - [[ -f /etc/mkinitcpio.conf ]] && install_pkgs "mkinitcpio-firmware" + printf 'Installing some packages...\n' + [ -f /etc/mkinitcpio.conf ] && install_pkgs "mkinitcpio-firmware" pamacvar='aur' if command_exists flatpak; then @@ -79,15 +68,12 @@ setup_arch() { install_pkgs "pamac-${pamacvar}" # Configure pamac - sudo sed -i "/RemoveUnrequiredDeps/s/^#//g - /NoUpdateHideIcon/s/^#//g - /KeepNumPackages/c\KeepNumPackages = 1 - /RefreshPeriod/c\RefreshPeriod = 0" /etc/pamac.conf + sudo sed_i "/RemoveUnrequiredDeps/s/^#//g; /NoUpdateHideIcon/s/^#//g; /KeepNumPackages/c\\KeepNumPackages = 1; /RefreshPeriod/c\\RefreshPeriod = 0" /etc/pamac.conf 2>/dev/null || true # misc - flagstocopy=(code electron chromium chrome microsoft-edge-stable) - for i in "${flagstocopy[@]}"; do - copy_file ~/.config/"${i}"-flags.conf "${BASE_REPO_LOCATION}"home/.config/"${i}"-flags.conf + flagstocopy='code electron chromium chrome microsoft-edge-stable' + for i in $flagstocopy; do + copy_file ~/.config/"${i}"-flags.conf "${BASE_REPO_LOCATION}home/.config/${i}-flags.conf" || true done } @@ -95,4 +81,4 @@ setup_arch_cinnamon() { setup_cinnamon_theme } -echo -e "Done arch.sh..." +printf 'Done arch.sh...\n' diff --git a/distros/debian.aliases b/distros/debian.aliases index 8c97e1e..b4fc596 100644 --- a/distros/debian.aliases +++ b/distros/debian.aliases @@ -1,11 +1,8 @@ #!/bin/sh -# shellcheck disable=SC2139 -# shellcheck disable=SC3009 -# shellcheck disable=SC3020 alias sudo='sudo -E -H ' alias e='sudo systemctl --failed --no-pager; sudo journalctl -p 3 -b' alias cls='clear' -alias u='sudo apt update && sudo apt full-upgrade; command -v flatpak &> /dev/null && flatpak update; command -v snap &> /dev/null && sudo snap refresh; command -v pipx &> /dev/null && pipx upgrade-all' +alias u='sudo apt update && sudo apt full-upgrade; command -v flatpak >/dev/null 2>&1 && flatpak update; command -v snap >/dev/null 2>&1 && sudo snap refresh; command -v pipx >/dev/null 2>&1 && pipx upgrade-all' alias uu='sudo nala update && sudo nala upgrade' alias i='sudo apt install' alias ii='sudo nala install' @@ -18,8 +15,8 @@ alias b='apt list --installed | cut -d'/' -f1 | uniq > pkglist.txt' alias c='sudo apt autoremove && sudo apt autopurge && sudo apt clean' alias cc='sudo nala autoremove && sudo nala autopurge && sudo nala clean' alias x='exit' -command -v gnome-text-editor &> /dev/null && alias {gte,gted}='gnome-text-editor' -if command -v fastfetch &> /dev/null; then +command -v gnome-text-editor >/dev/null 2>&1 && alias gte='gnome-text-editor' && alias gted='gnome-text-editor' +if command -v fastfetch >/dev/null 2>&1; then alias neofetch='fastfetch' else alias fastfetch='neofetch' diff --git a/distros/debian.sh b/distros/debian.sh index 0c5ad76..70b92af 100644 --- a/distros/debian.sh +++ b/distros/debian.sh @@ -1,6 +1,5 @@ -#!/bin/bash +#!/bin/sh -# shellcheck disable=SC2034 REFRESH_CMD="sudo apt-get update" UPDATE_CMD="sudo apt-get update && sudo apt-get full-upgrade -y" INSTALL_CMD="sudo apt-get install -y" @@ -8,29 +7,29 @@ UNINSTALL_CMD="sudo apt-get purge --ignore-missing --auto-remove -y" UNINSTALL_ONLY_CMD="sudo apt-get purge --ignore-missing -y" REQUIREMENTS="curl wget unzip dconf-cli jq crudini" -SYSTEM_PACKAGES_TO_INSTALL="fwupd mesa-vulkan-drivers alsa-{firmware-loaders,ucm-conf} firmware-sof-signed fprintd libpam-fprintd power-profiles-daemon" +SYSTEM_PACKAGES_TO_INSTALL="fwupd mesa-vulkan-drivers alsa-firmware-loaders alsa-ucm-conf firmware-sof-signed fprintd libpam-fprintd power-profiles-daemon" INTEL_PACKAGES_TO_INSTALL="intel-media-va-driver-non-free va-driver-all" VMWARE_PACKAGES_TO_INSTALL="open-vm-tools-desktop" VBOX_PACKAGES_TO_INSTALL="virtualbox-guest-x11" HYPERV_PACKAGES_TO_INSTALL="hyperv-daemons" VIRT_PACKAGES_TO_INSTALL="qemu-guest-agent" -FONTS_TO_INSTALL="fonts-{recommended,noto-core,noto-ui-core,noto-color-emoji,jetbrains-mono}" +FONTS_TO_INSTALL="fonts-recommended fonts-noto-core fonts-noto-ui-core fonts-noto-color-emoji fonts-jetbrains-mono" TERM_PACKAGES_TO_INSTALL="bash-completion nano starship fastfetch" -APP_PACKAGES_TO_INSTALL="firefox{,-locale-en*,-l10n-en*} w{american,british} gnome-keyring seahorse vlc onboard" +APP_PACKAGES_TO_INSTALL="firefox firefox-locale-en-gb firefox-locale-en-us firefox-l10n-en-gb firefox-l10n-en-us wamerican wbritish gnome-keyring seahorse vlc onboard" DEV_PACKAGES_TO_INSTALL="git build-essential python3-pip shfmt diffutils meld gh code" -GTK_PACKAGES_TO_INSTALL="xdg-desktop-portal-gtk gnome-themes-extra{,-data}" +GTK_PACKAGES_TO_INSTALL="xdg-desktop-portal-gtk gnome-themes-extra gnome-themes-extra-data" QT_PACKAGES_TO_INSTALL="qtwayland5 qt6-wayland" -QT_PATCHES_TO_INSTALL="qt{5,6}-style-kvantum{,-themes} qt{5,6}ct" -GNOME_PACKAGES_TO_INSTALL="gnome-{menus,tweaks,terminal,text-editor} evolution-data-server python3-nautilus pipx $QT_PATCHES_TO_INSTALL" +QT_PATCHES_TO_INSTALL="qt5-style-kvantum qt5-style-kvantum-themes qt6-style-kvantum qt6-style-kvantum-themes qt5ct qt6ct" +GNOME_PACKAGES_TO_INSTALL="gnome-menus gnome-tweaks gnome-terminal gnome-text-editor evolution-data-server python3-nautilus pipx $QT_PATCHES_TO_INSTALL" GNOME_EXT_MGR_PKG="gnome-shell-extension-manager" KDE_PACKAGES_TO_INSTALL="kde-plasma-desktop gwenview kcalc kfind kwrite okular kde-spectacle" -CINNAMON_PACKAGES_TO_INSTALL="xed xreader xviewer{,-plugins} mint-{themes,y-icons} $QT_PATCHES_TO_INSTALL" +CINNAMON_PACKAGES_TO_INSTALL="xed xreader xviewer xviewer-plugins mint-themes mint-y-icons $QT_PATCHES_TO_INSTALL" XFCE_PACKAGES_TO_INSTALL="xfce4 xfce4-whiskermenu-plugin xfce4-clipman-plugin xfce4-screenshooter xfce4-taskmanager light-locker slick-greeter $QT_PATCHES_TO_INSTALL" XFCE_MENU_LOGO="distributor-logo-debian" PACKAGES_TO_REMOVE="" setup_debian() { - echo -e "Setting up apt..." + printf 'Setting up apt...\n' install_pkgs "software-properties-common python3-launchpadlib nala gpg apt-transport-https" sudo apt-add-repository contrib -y @@ -41,25 +40,25 @@ setup_debian() { sudo mkdir -p -m 755 /etc/apt/keyrings # microsoft - wget -qO- https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor >packages.microsoft.gpg + wget -qO- https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor > packages.microsoft.gpg sudo install -D -o root -g root -m 644 packages.microsoft.gpg /etc/apt/keyrings/packages.microsoft.gpg - echo -e "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/packages.microsoft.gpg] https://packages.microsoft.com/repos/code stable main" | sudo tee /etc/apt/sources.list.d/vscode.list >/dev/null - echo -e "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/packages.microsoft.gpg] https://packages.microsoft.com/repos/edge stable main" | sudo tee /etc/apt/sources.list.d/microsoft-edge.list >/dev/null + printf "deb [arch=%s signed-by=/etc/apt/keyrings/packages.microsoft.gpg] https://packages.microsoft.com/repos/code stable main\n" "$(dpkg --print-architecture)" | sudo tee /etc/apt/sources.list.d/vscode.list >/dev/null + printf "deb [arch=%s signed-by=/etc/apt/keyrings/packages.microsoft.gpg] https://packages.microsoft.com/repos/edge stable main\n" "$(dpkg --print-architecture)" | sudo tee /etc/apt/sources.list.d/microsoft-edge.list >/dev/null rm -f packages.microsoft.gpg # google wget -q -O - https://dl.google.com/linux/linux_signing_key.pub | gpg --dearmor | sudo tee /etc/apt/keyrings/google.gpg >/dev/null - echo -e "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/google.gpg] https://dl.google.com/linux/chrome/deb/ stable main" | sudo tee /etc/apt/sources.list.d/google-chrome.list >/dev/null + printf "deb [arch=%s signed-by=/etc/apt/keyrings/google.gpg] https://dl.google.com/linux/chrome/deb/ stable main\n" "$(dpkg --print-architecture)" | sudo tee /etc/apt/sources.list.d/google-chrome.list >/dev/null # github - wget -qO- https://cli.github.com/packages/githubcli-archive-keyring.gpg | sudo tee /etc/apt/keyrings/githubcli-archive-keyring.gpg >/dev/null && + wget -qO- https://cli.github.com/packages/githubcli-archive-keyring.gpg | sudo tee /etc/apt/keyrings/githubcli-archive-keyring.gpg >/dev/null && \ sudo chmod go+r /etc/apt/keyrings/githubcli-archive-keyring.gpg - echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" | sudo tee /etc/apt/sources.list.d/github-cli.list >/dev/null + printf "deb [arch=%s signed-by=/etc/apt/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main\n" "$(dpkg --print-architecture)" | sudo tee /etc/apt/sources.list.d/github-cli.list >/dev/null rm -f .wget-hsts # add some ppa if ubuntu based - if [[ $DIST_ID == *ubuntu* || $ID_LIKE == *ubuntu* ]]; then + if echo "$DIST_ID" | grep -q 'ubuntu' || echo "$ID_LIKE" | grep -q 'ubuntu'; then sudo add-apt-repository ppa:papirus/papirus -y # for qt6-style-kvantum sudo add-apt-repository ppa:zhangsongcui3371/fastfetch -y fi @@ -68,12 +67,12 @@ setup_debian() { # synaptic sudo mkdir -p /root/.synaptic/ - copy_file "$TEMP_DIR"/synaptic.conf "${BASE_REPO_LOCATION}"system/root/.synaptic/synaptic.conf - sudo mv -f "$TEMP_DIR"/synaptic.conf /root/.synaptic/ + copy_file "$TEMP_DIR/synaptic.conf" "${BASE_REPO_LOCATION}system/root/.synaptic/synaptic.conf" + sudo mv -f "$TEMP_DIR/synaptic.conf" /root/.synaptic/ } setup_debian_cinnamon() { setup_cinnamon_theme } -echo -e "Done debian.sh..." +printf 'Done debian.sh...\n' diff --git a/distros/fedora.aliases b/distros/fedora.aliases index 6f30aa3..594896a 100644 --- a/distros/fedora.aliases +++ b/distros/fedora.aliases @@ -1,11 +1,8 @@ #!/bin/sh -# shellcheck disable=SC2139 -# shellcheck disable=SC3009 -# shellcheck disable=SC3020 alias sudo='sudo -E -H ' alias e='sudo systemctl --failed --no-pager; sudo journalctl -p 3 -b' alias cls='clear' -alias u='sudo dnf update --refresh; command -v flatpak &> /dev/null && flatpak update; command -v snap &> /dev/null && sudo snap refresh; command -v pipx &> /dev/null && pipx upgrade-all' +alias u='sudo dnf update --refresh; command -v flatpak >/dev/null 2>&1 && flatpak update; command -v snap >/dev/null 2>&1 && sudo snap refresh; command -v pipx >/dev/null 2>&1 && pipx upgrade-all' #alias uu='sudo dnf update --refresh' alias i='sudo dnf install' #alias ii='sudo dnf install' @@ -18,8 +15,8 @@ alias b='dnf list installed > pkglist.txt' alias c='sudo dnf clean all' alias cc='sudo dnf autoremove $(dnf repoquery --installonly --latest-limit=-1 -q)' alias x='exit' -command -v gnome-text-editor &> /dev/null && alias {gte,gted}='gnome-text-editor' -if command -v fastfetch &> /dev/null; then +command -v gnome-text-editor >/dev/null 2>&1 && alias gte='gnome-text-editor' && alias gted='gnome-text-editor' +if command -v fastfetch >/dev/null 2>&1; then alias neofetch='fastfetch' else alias fastfetch='neofetch' diff --git a/distros/fedora.sh b/distros/fedora.sh index 4f231ee..8828669 100644 --- a/distros/fedora.sh +++ b/distros/fedora.sh @@ -1,6 +1,5 @@ -#!/bin/bash +#!/bin/sh -# shellcheck disable=SC2034 REFRESH_CMD="sudo dnf check-update --refresh" UPDATE_CMD="sudo dnf update --refresh -y" INSTALL_CMD="sudo dnf install -y" @@ -10,39 +9,37 @@ UNINSTALL_ONLY_CMD="sudo dnf remove -y" FLATPAK_INSTALL_CMD="flatpak install --user --assumeyes flathub" REQUIREMENTS="curl wget2-wget unzip xrdb dconf jq crudini" -SYSTEM_PACKAGES_TO_INSTALL="fwupd-efi fuse mesa-vulkan-drivers vulkan-loader alsa-{firmware,ucm,sof-firmware} fprintd fprintd-pam power-profiles-daemon" +SYSTEM_PACKAGES_TO_INSTALL="fwupd-efi fuse mesa-vulkan-drivers vulkan-loader alsa-firmware alsa-ucm alsa-sof-firmware fprintd fprintd-pam power-profiles-daemon" INTEL_PACKAGES_TO_INSTALL="intel-media-driver" VMWARE_PACKAGES_TO_INSTALL="open-vm-tools-desktop" VBOX_PACKAGES_TO_INSTALL="virtualbox-guest-additions" -HYPERV_PACKAGES_TO_INSTALL="hyperv-{daemons,tools}" +HYPERV_PACKAGES_TO_INSTALL="hyperv-daemons hyperv-tools" VIRT_PACKAGES_TO_INSTALL="qemu-guest-agent" -FONTS_TO_INSTALL="{liberation,google-noto}-fonts-common google-noto-{emoji,color-emoji}-fonts jetbrains-mono-fonts" +FONTS_TO_INSTALL="liberation-fonts-common google-noto-fonts-common google-noto-emoji-fonts google-noto-color-emoji-fonts jetbrains-mono-fonts" TERM_PACKAGES_TO_INSTALL="bash-completion nano starship fastfetch" -APP_PACKAGES_TO_INSTALL="firefox{,-langpacks} mozilla-openh264 gnome-keyring seahorse vlc onboard" +APP_PACKAGES_TO_INSTALL="firefox firefox-langpacks mozilla-openh264 gnome-keyring seahorse vlc onboard" DEV_PACKAGES_TO_INSTALL="git make automake gcc gcc-c++ python3-pip shfmt diffutils meld gh code" GTK_PACKAGES_TO_INSTALL="xdg-desktop-portal-gtk gnome-themes-extra" -QT_PACKAGES_TO_INSTALL="qt{5,6}-qtwayland" -QT_PATCHES_TO_INSTALL="kvantum{,-qt5} qt{5,6}ct" -GNOME_PACKAGES_TO_INSTALL="gnome-{menus,tweaks,terminal,text-editor} evolution-data-server nautilus-python pipx $QT_PATCHES_TO_INSTALL" +QT_PACKAGES_TO_INSTALL="qt5-qtwayland qt6-qtwayland" +QT_PATCHES_TO_INSTALL="kvantum kvantum-qt5 qt5ct qt6ct" +GNOME_PACKAGES_TO_INSTALL="gnome-menus gnome-tweaks gnome-terminal gnome-text-editor evolution-data-server nautilus-python pipx $QT_PATCHES_TO_INSTALL" GNOME_EXT_MGR_PKG="" -KDE_PACKAGES_TO_INSTALL="plasma-workspace{,-x11} gwenview kate kcalc kfind kwrite okular spectacle" -CINNAMON_PACKAGES_TO_INSTALL="xed xreader xviewer{,-plugins} nemo-emblems nemo-fileroller nemo-preview nemo-python mint-{themes,y-icons} $QT_PATCHES_TO_INSTALL" +KDE_PACKAGES_TO_INSTALL="plasma-workspace plasma-workspace-x11 gwenview kate kcalc kfind kwrite okular spectacle" +CINNAMON_PACKAGES_TO_INSTALL="xed xreader xviewer xviewer-plugins nemo-emblems nemo-fileroller nemo-preview nemo-python mint-themes mint-y-icons $QT_PATCHES_TO_INSTALL" XFCE_PACKAGES_TO_INSTALL="xfce4-whiskermenu-plugin xfce4-clipman-plugin xfce4-screenshooter xfce4-taskmanager light-locker slick-greeter $QT_PATCHES_TO_INSTALL" XFCE_MENU_LOGO="distributor-logo-fedora" PACKAGES_TO_REMOVE="" setup_fedora() { - echo -e "Updating dnf.conf..." + printf 'Updating dnf.conf...\n' sudo crudini --ini-options=nospace --set /etc/dnf/dnf.conf main max_parallel_downloads 10 sudo crudini --ini-options=nospace --set /etc/dnf/dnf.conf main fastestmirror True sudo crudini --ini-options=nospace --set /etc/dnf/dnf.conf main clean_requirements_on_remove True sudo crudini --ini-options=nospace --set /etc/dnf/dnf.conf main skip_if_unavailable True install_pkgs "fedora-workstation-repositories" - echo -e "Setting up RPM Fusion..." - # https://rpmfusion.org/Configuration - # shellcheck disable=SC2046 - sudo dnf install -y https://mirrors.rpmfusion.org/free/fedora/rpmfusion-free-release-$(rpm -E %fedora).noarch.rpm https://mirrors.rpmfusion.org/nonfree/fedora/rpmfusion-nonfree-release-$(rpm -E %fedora).noarch.rpm + printf 'Setting up RPM Fusion...\n' + sudo dnf install -y "https://mirrors.rpmfusion.org/free/fedora/rpmfusion-free-release-$(rpm -E %fedora).noarch.rpm" "https://mirrors.rpmfusion.org/nonfree/fedora/rpmfusion-nonfree-release-$(rpm -E %fedora).noarch.rpm" sudo dnf config-manager --enable fedora-cisco-openh264 sudo dnf update -y @core sudo dnf update -y @multimedia --setopt="install_weak_deps=False" --exclude=PackageKit-gstreamer-plugin @@ -51,21 +48,21 @@ setup_fedora() { #sudo dnf swap mesa-va-drivers mesa-va-drivers-freeworld --allowerasing #sudo dnf swap mesa-vdpau-drivers mesa-vdpau-drivers-freeworld --allowerasing - echo -e "Disabling some not needed repos..." + printf 'Disabling some not needed repos...\n' sudo dnf config-manager --disable *PyCharm* *nvidia* *steam* - echo -e "Adding some needed repos..." + printf 'Adding some needed repos...\n' # google sudo dnf config-manager --enable google-chrome # microsoft sudo rpm --import https://packages.microsoft.com/keys/microsoft.asc sudo dnf config-manager --add-repo https://packages.microsoft.com/yumrepos/vscode sudo dnf config-manager --add-repo https://packages.microsoft.com/yumrepos/edge - sudo sed -i "/name=/c\name=microsoft-vscode" /etc/yum.repos.d/packages.microsoft.com_yumrepos_vscode.repo - sudo sed -i "/name=/c\name=microsoft-edge" /etc/yum.repos.d/packages.microsoft.com_yumrepos_edge.repo + sudo sed_i "/name=/c\\name=microsoft-vscode" /etc/yum.repos.d/packages.microsoft.com_yumrepos_vscode.repo + sudo sed_i "/name=/c\\name=microsoft-edge" /etc/yum.repos.d/packages.microsoft.com_yumrepos_edge.repo - command_exists flatpak && flatpak remote-add --user --if-not-exists flathub https://dl.flathub.org/repo/flathub.flatpakrepo \ - && sudo flatpak remote-modify --disable fedora + command_exists flatpak && flatpak remote-add --user --if-not-exists flathub https://dl.flathub.org/repo/flathub.flatpakrepo && \ + sudo flatpak remote-modify --disable fedora #install_pkgs dnfdragora-gui @@ -87,4 +84,4 @@ setup_fedora_xfce() { setup_xfce_panel } -echo -e "Done fedora.sh..." +printf 'Done fedora.sh...\n' diff --git a/distros/opensuse.aliases b/distros/opensuse.aliases index cce4ddf..84dad38 100644 --- a/distros/opensuse.aliases +++ b/distros/opensuse.aliases @@ -1,11 +1,8 @@ #!/bin/sh -# shellcheck disable=SC2139 -# shellcheck disable=SC3009 -# shellcheck disable=SC3020 alias sudo='sudo -E -H ' alias e='sudo systemctl --failed --no-pager; sudo journalctl -p 3 -b' alias cls='clear' -alias u='sudo zypper refresh && sudo zypper dup --allow-vendor-change; command -v flatpak &> /dev/null && flatpak update; command -v snap &> /dev/null && sudo snap refresh; command -v pipx &> /dev/null && pipx upgrade-all' +alias u='sudo zypper refresh && sudo zypper dup --allow-vendor-change; command -v flatpak >/dev/null 2>&1 && flatpak update; command -v snap >/dev/null 2>&1 && sudo snap refresh; command -v pipx >/dev/null 2>&1 && pipx upgrade-all' alias uu='sudo zypperoni ref && sudo zypperoni dup --allow-vendor-change' alias zu='(curl https://raw.githubusercontent.com/pavinjosdev/zypperoni/main/zypperoni | sudo tee /usr/bin/zypperoni > /dev/null) && sudo chmod 755 /usr/bin/zypperoni' alias i='sudo zypper install' @@ -19,8 +16,8 @@ alias b='zypper search --installed-only > pkglist.txt' alias c='zypper packages --orphaned && sudo zypper clean --all' alias cc='sudo zypper purge-kernels' alias x='exit' -command -v gnome-text-editor &> /dev/null && alias {gte,gted}='gnome-text-editor' -if command -v fastfetch &> /dev/null; then +command -v gnome-text-editor >/dev/null 2>&1 && alias gte='gnome-text-editor' && alias gted='gnome-text-editor' +if command -v fastfetch >/dev/null 2>&1; then alias neofetch='fastfetch' else alias fastfetch='neofetch' diff --git a/distros/opensuse.sh b/distros/opensuse.sh index b903496..704d964 100644 --- a/distros/opensuse.sh +++ b/distros/opensuse.sh @@ -1,6 +1,5 @@ -#!/bin/bash +#!/bin/sh -# shellcheck disable=SC2034 REFRESH_CMD="sudo zypper --gpg-auto-import-keys refresh" UPDATE_CMD="sudo zypper dup --allow-vendor-change -y" INSTALL_CMD="sudo zypper install -y" @@ -11,51 +10,50 @@ FLATPAK_INSTALL_CMD="sudo flatpak install --assumeyes flathub" FLATPAK_UPDATE_CMD="sudo flatpak update --assumeyes" REQUIREMENTS="curl wget unzip xrdb dconf jq crudini" -SYSTEM_PACKAGES_TO_INSTALL="fwupd Mesa-vulkan-{device-select,overlay} alsa-{firmware,ucm-conf} sof-firmware fprintd fprintd-pam power-profiles-daemon at-spi2-core" +SYSTEM_PACKAGES_TO_INSTALL="fwupd Mesa-vulkan-device-select Mesa-vulkan-overlay alsa-firmware alsa-ucm-conf sof-firmware fprintd fprintd-pam power-profiles-daemon at-spi2-core" INTEL_PACKAGES_TO_INSTALL="intel-media-driver" VMWARE_PACKAGES_TO_INSTALL="open-vm-tools-desktop" VBOX_PACKAGES_TO_INSTALL="virtualbox-guest-tools" HYPERV_PACKAGES_TO_INSTALL="" VIRT_PACKAGES_TO_INSTALL="qemu-guest-agent" -FONTS_TO_INSTALL="{liberation,dejavu,ubuntu}-fonts google-noto-{coloremoji,sans,serif,sans-mono}-fonts google-roboto-fonts jetbrains-mono-fonts" +FONTS_TO_INSTALL="liberation-fonts dejavu-fonts ubuntu-fonts google-noto-coloremoji-fonts google-noto-sans-fonts google-noto-serif-fonts google-noto-sans-mono-fonts google-roboto-fonts jetbrains-mono-fonts" TERM_PACKAGES_TO_INSTALL="bash-completion nano starship fastfetch" -APP_PACKAGES_TO_INSTALL="MozillaFirefox{,-translations-common} mozilla-openh264 gnome-keyring seahorse vlc onboard" +APP_PACKAGES_TO_INSTALL="MozillaFirefox MozillaFirefox-translations-common mozilla-openh264 gnome-keyring seahorse vlc onboard" DEV_PACKAGES_TO_INSTALL="git patterns-devel-base-devel_basis python3-pip shfmt diffutils meld gh" GTK_PACKAGES_TO_INSTALL="xdg-desktop-portal-gtk gnome-themes-extra" QT_PACKAGES_TO_INSTALL="qt6-wayland" -QT_PATCHES_TO_INSTALL="kvantum-{manager,qt5,qt6,themes} qt{5,6}ct" -GNOME_PACKAGES_TO_INSTALL="gnome-{menus,tweaks,terminal,text-editor} evolution-data-server python3-nautilus python3-pipx $QT_PATCHES_TO_INSTALL" +QT_PATCHES_TO_INSTALL="kvantum-manager kvantum-qt5 kvantum-qt6 kvantum-themes qt5ct qt6ct" +GNOME_PACKAGES_TO_INSTALL="gnome-menus gnome-tweaks gnome-terminal gnome-text-editor evolution-data-server python3-nautilus python3-pipx $QT_PATCHES_TO_INSTALL" GNOME_EXT_MGR_PKG="extension-manager" KDE_PACKAGES_TO_INSTALL="patterns-kde-kde_plasma gwenview kcalc kfind kwrite okular spectacle" -CINNAMON_PACKAGES_TO_INSTALL="patterns-cinnamon-cinnamon{,_basis} xed xreader xviewer metatheme-mint-common mint-y-icon-theme $QT_PATCHES_TO_INSTALL" -XFCE_PACKAGES_TO_INSTALL="patterns-xfce-xfce{,_basis} xfce4-whiskermenu-plugin xfce4-clipman-plugin xfce4-screenshooter xfce4-taskmanager light-locker lightdm-slick-greeter $QT_PATCHES_TO_INSTALL" +CINNAMON_PACKAGES_TO_INSTALL="patterns-cinnamon-cinnamon patterns-cinnamon-cinnamon_basis xed xreader xviewer metatheme-mint-common mint-y-icon-theme $QT_PATCHES_TO_INSTALL" +XFCE_PACKAGES_TO_INSTALL="patterns-xfce-xfce patterns-xfce-xfce_basis xfce4-whiskermenu-plugin xfce4-clipman-plugin xfce4-screenshooter xfce4-taskmanager light-locker lightdm-slick-greeter $QT_PATCHES_TO_INSTALL" XFCE_MENU_LOGO="xfce4-button-opensuse" PACKAGES_TO_REMOVE="icewm*" setup_opensuse() { #sudo zypper al totem - echo -e "Setting up repo and packman..." + printf 'Setting up repo and packman...\n' # https://en.opensuse.org/Additional_package_repositories # http://packman.links2linux.org/mirrors sudo zypper rr packman - # shellcheck disable=SC2154 - if [[ $releasever == '' ]]; then + if [ -z "$releasever" ]; then install_pkgs openSUSE-repos-Tumbleweed sudo zypper ar -cfp 90 'http://mirror.karneval.cz/pub/linux/packman/suse/openSUSE_Tumbleweed/' packman else install_pkgs openSUSE-repos-Leap - sudo zypper ar -cfp 90 'http://mirror.karneval.cz/pub/linux/packman/suse/openSUSE_Leap_$releasever/' packman + sudo zypper ar -cfp 90 "http://mirror.karneval.cz/pub/linux/packman/suse/openSUSE_Leap_${releasever}/" packman fi refresh_package_sources sudo zypper dup --from packman --allow-vendor-change -y - echo -e "Installing some stuffs..." + printf 'Installing some stuffs...\n' install_pkgs "opi" opi codecs -n opi vscode -n refresh_package_sources - echo -e "Installing zypperoni for faster zypper download..." + printf 'Installing zypperoni for faster zypper download...\n' curl https://raw.githubusercontent.com/pavinjosdev/zypperoni/main/zypperoni | sudo tee /usr/bin/zypperoni >/dev/null sudo chmod 755 /usr/bin/zypperoni } @@ -71,4 +69,4 @@ setup_opensuse_xfce() { sudo crudini --ini-options=nospace --set /usr/share/lightdm/lightdm.conf.d/99-custom.conf SeatDefaults greeter-session slick-greeter } -echo -e "Done opensuse.sh..." +printf 'Done opensuse.sh...\n' diff --git a/home/.bashrc b/home/.bashrc index cb1634c..dbcfdf2 100644 --- a/home/.bashrc +++ b/home/.bashrc @@ -1,5 +1,3 @@ -# shellcheck disable=SC2148 - # ~custom-setup~ # Shell customization HISTSIZE=20 @@ -9,8 +7,7 @@ export SYSTEMD_PAGER= export PATH="$PATH:~/.local/bin" # My aliiases -# shellcheck disable=SC1090 -[[ -f ~/.aliases ]] && . ~/.aliases +[ -f ~/.aliases ] && . ~/.aliases # Cool shell prompt -command -v starship &> /dev/null && eval "$(starship init bash)" +command -v starship >/dev/null 2>&1 && eval "$(starship init bash)" diff --git a/home/.profile b/home/.profile index 0251f34..059c53d 100644 --- a/home/.profile +++ b/home/.profile @@ -1,5 +1,3 @@ -# shellcheck disable=SC2148 - # ~custom-setup~ #export QT_QPA_PLATFORM=wayland export QT_QPA_PLATFORMTHEME=qt5ct diff --git a/home/.xinitrc b/home/.xinitrc index 46d5db5..622f196 100644 --- a/home/.xinitrc +++ b/home/.xinitrc @@ -1,5 +1,2 @@ -# shellcheck disable=SC2148 - # ~custom-setup~ -# shellcheck disable=SC1090 if [ -r ~/.profile ]; then . ~/.profile; fi diff --git a/home/.xprofile b/home/.xprofile index 46d5db5..622f196 100644 --- a/home/.xprofile +++ b/home/.xprofile @@ -1,5 +1,2 @@ -# shellcheck disable=SC2148 - # ~custom-setup~ -# shellcheck disable=SC1090 if [ -r ~/.profile ]; then . ~/.profile; fi diff --git a/home/.xsessionrc b/home/.xsessionrc index 46d5db5..622f196 100644 --- a/home/.xsessionrc +++ b/home/.xsessionrc @@ -1,5 +1,2 @@ -# shellcheck disable=SC2148 - # ~custom-setup~ -# shellcheck disable=SC1090 if [ -r ~/.profile ]; then . ~/.profile; fi diff --git a/scripts/setup-guide.sh b/scripts/setup-guide.sh index 3f0dea9..36ee0f4 100644 --- a/scripts/setup-guide.sh +++ b/scripts/setup-guide.sh @@ -1,11 +1,8 @@ -#!/bin/bash -# shellcheck disable=SC2046 -# shellcheck disable=SC1091 -# shellcheck disable=SC2164 -# shellcheck disable=SC2103 +#!/bin/sh +# This is example documentation - shellcheck not applied ## option #1 -curl -fsSL https://raw.githubusercontent.com/krish-gh/linux-setup/main/setup.sh | bash +curl -fsSL https://raw.githubusercontent.com/krish-gh/linux-setup/main/setup.sh | sh ## option #2 git clone https://github.com/krish-gh/linux-setup.git && diff --git a/scripts/setup-main.sh b/scripts/setup-main.sh index 5d71f9c..582f802 100644 --- a/scripts/setup-main.sh +++ b/scripts/setup-main.sh @@ -1,11 +1,9 @@ -#!/bin/bash -# shellcheck disable=SC2034 +#!/bin/sh -# shellcheck disable=SC2128 -scriptDir=$(dirname -- "$(readlink -f -- "$BASH_SOURCE")") +scriptDir=$(cd -- "$(dirname -- "$0")" && pwd) || { printf 'Failed to determine script directory\n' >&2; exit 1; } repoDir="$(dirname "$scriptDir")" -if [[ -d $repoDir/.git && -f $repoDir/scripts/setup-main.sh ]]; then - BASE_REPO_LOCATION=$repoDir/ +if [ -d "$repoDir/.git" ] && [ -f "$repoDir/scripts/setup-main.sh" ]; then + BASE_REPO_LOCATION="$repoDir/" else BASE_REPO_LOCATION="https://raw.githubusercontent.com/krish-gh/linux-setup/main/" fi @@ -16,191 +14,215 @@ command_exists() { DISTRO_TYPE='' PKG_MGR='' -command_exists pacman && PKG_MGR=pacman && DISTRO_TYPE=arch -command_exists apt && PKG_MGR=apt && DISTRO_TYPE=debian -command_exists dnf && PKG_MGR=dnf && DISTRO_TYPE=fedora -command_exists zypper && PKG_MGR=zypper && DISTRO_TYPE=opensuse -if [[ $DISTRO_TYPE == '' ]]; then - >&2 echo "You are not running supported Linux distrbution..." +if command_exists pacman; then + PKG_MGR=pacman + DISTRO_TYPE=arch +elif command_exists apt; then + PKG_MGR=apt + DISTRO_TYPE=debian +elif command_exists dnf; then + PKG_MGR=dnf + DISTRO_TYPE=fedora +elif command_exists zypper; then + PKG_MGR=zypper + DISTRO_TYPE=opensuse +fi + +if [ -z "$DISTRO_TYPE" ]; then + printf 'Error: Unsupported Linux distribution\n' >&2 exit 1 fi if ! command_exists curl; then - >&2 echo "curl required, but not found..." + printf 'Error: curl is required but not found\n' >&2 exit 2 fi DIST_ID='' -# shellcheck disable=SC1091 -[[ -f /etc/os-release ]] && source /etc/os-release && DIST_ID=$ID - -# shellcheck disable=SC2086 -DESKTOP=$(echo ${XDG_CURRENT_DESKTOP##*:} | tr '[:upper:]' '[:lower:]' | sed 's/^x-//') -CURRENT_TERMINAL=$(ps -p $PPID -o comm= | sed 's/-$//') - -echo -e "#################################################################" -echo -e "BASE_REPO_LOCATION=$BASE_REPO_LOCATION" -echo -e "DISTRO_TYPE=$DISTRO_TYPE" -echo -e "PACKAGE_MANAGER=$PKG_MGR" -echo -e "DESKTOP=$DESKTOP" -echo -e "TERMINAL=$CURRENT_TERMINAL" -echo -e "DISTRO_ID=$DIST_ID" -echo -e "#################################################################" +if [ -f /etc/os-release ]; then + . /etc/os-release + DIST_ID="${ID:-}" +fi + +DESKTOP=$(printf '%s\n' "$XDG_CURRENT_DESKTOP" | sed 's/.*://; s/^x-//; y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/') +CURRENT_TERMINAL=$(ps -p "$PPID" -o comm= | sed 's/-$//') + +printf '#################################################################\n' +printf 'BASE_REPO_LOCATION=%s\n' "$BASE_REPO_LOCATION" +printf 'DISTRO_TYPE=%s\n' "$DISTRO_TYPE" +printf 'PACKAGE_MANAGER=%s\n' "$PKG_MGR" +printf 'DESKTOP=%s\n' "$DESKTOP" +printf 'TERMINAL=%s\n' "$CURRENT_TERMINAL" +printf 'DISTRO_ID=%s\n' "$DIST_ID" +printf '#################################################################\n' cat /etc/os-release -echo -e "#################################################################" - -REFRESH_CMD="" #override from DISTRO_TYPE specific script -UPDATE_CMD="" #override from DISTRO_TYPE specific script -INSTALL_CMD="" #override from DISTRO_TYPE specific script -UNINSTALL_CMD="" #override from DISTRO_TYPE specific script -UNINSTALL_ONLY_CMD="" #override from DISTRO_TYPE specific script - -FLATPAK_INSTALL_CMD="flatpak install --assumeyes flathub" #override from DISTRO_TYPE specific script -FLATPAK_UPDATE_CMD="flatpak update --assumeyes" #override from DISTRO_TYPE specific script - -REQUIREMENTS="" #override from DISTRO_TYPE specific script -SYSTEM_PACKAGES_TO_INSTALL="" #override from DISTRO_TYPE specific script -INTEL_PACKAGES_TO_INSTALL="" #override from DISTRO_TYPE specific script -VMWARE_PACKAGES_TO_INSTALL="" #override from DISTRO_TYPE specific script -VBOX_PACKAGES_TO_INSTALL="" #override from DISTRO_TYPE specific script -HYPERV_PACKAGES_TO_INSTALL="" #override from DISTRO_TYPE specific script -VIRT_PACKAGES_TO_INSTALL="" #override from DISTRO_TYPE specific script -FONTS_TO_INSTALL="" #override from DISTRO_TYPE specific script -TERM_PACKAGES_TO_INSTALL="" #override from DISTRO_TYPE specific script -APP_PACKAGES_TO_INSTALL="" #override from DISTRO_TYPE specific script -DEV_PACKAGES_TO_INSTALL="" #override from DISTRO_TYPE specific script -GTK_PACKAGES_TO_INSTALL="" #override from DISTRO_TYPE specific script -QT_PACKAGES_TO_INSTALL="" #override from DISTRO_TYPE specific script -QT_PATCHES_TO_INSTALL="" #override from DISTRO_TYPE specific script -GNOME_PACKAGES_TO_INSTALL="" #override from DISTRO_TYPE specific script -GNOME_EXT_MGR_PKG="" #override from DISTRO_TYPE specific script -KDE_PACKAGES_TO_INSTALL="" #override from DISTRO_TYPE specific script -CINNAMON_PACKAGES_TO_INSTALL="" #override from DISTRO_TYPE specific script -XFCE_PACKAGES_TO_INSTALL="" #override from DISTRO_TYPE specific script -XFCE_MENU_LOGO="" #override from DISTRO_TYPE specific script -PACKAGES_TO_REMOVE="" #override from DISTRO_TYPE specific script +printf '#################################################################\n' + +REFRESH_CMD="" +UPDATE_CMD="" +INSTALL_CMD="" +UNINSTALL_CMD="" +UNINSTALL_ONLY_CMD="" + +FLATPAK_INSTALL_CMD="flatpak install --assumeyes flathub" +FLATPAK_UPDATE_CMD="flatpak update --assumeyes" + +REQUIREMENTS="" +SYSTEM_PACKAGES_TO_INSTALL="" +INTEL_PACKAGES_TO_INSTALL="" +VMWARE_PACKAGES_TO_INSTALL="" +VBOX_PACKAGES_TO_INSTALL="" +HYPERV_PACKAGES_TO_INSTALL="" +VIRT_PACKAGES_TO_INSTALL="" +FONTS_TO_INSTALL="" +TERM_PACKAGES_TO_INSTALL="" +APP_PACKAGES_TO_INSTALL="" +DEV_PACKAGES_TO_INSTALL="" +GTK_PACKAGES_TO_INSTALL="" +QT_PACKAGES_TO_INSTALL="" +QT_PATCHES_TO_INSTALL="" +GNOME_PACKAGES_TO_INSTALL="" +GNOME_EXT_MGR_PKG="" +KDE_PACKAGES_TO_INSTALL="" +CINNAMON_PACKAGES_TO_INSTALL="" +XFCE_PACKAGES_TO_INSTALL="" +XFCE_MENU_LOGO="" +PACKAGES_TO_REMOVE="" TERMINAL_TO_INSTALL=none -GUI_TEXT_EDITOR="" #override from desktop specific script +GUI_TEXT_EDITOR="" -TEMP_DIR=/tmp/linux-setup -mkdir -p $TEMP_DIR +TEMP_DIR=$(mktemp -d) || { printf 'Failed to create temp directory\n' >&2; exit 1; } +trap 'rm -rf "$TEMP_DIR"' EXIT + +# Portable sed -i that works on both GNU and BSD systems +sed_i() { + if sed --version >/dev/null 2>&1; then + # GNU sed + sed -i "$@" + else + # BSD sed requires an empty string for in-place editing + sed -i '' "$@" + fi +} +export -f sed_i # arg1 = destination path, arg2 = source path copy_file() { - if [[ $2 == http* ]]; then - curl -f -o "$1" "$2?$(date +%s)" - curl_exit_status=$? - [[ $curl_exit_status != 0 ]] && >&2 echo -e "Error downloading $2" + local dest="$1" src="$2" + if echo "$src" | grep -q '^http'; then + curl -f -o "$dest" "$src?$(date +%s)" || { printf 'Error downloading %s\n' "$src" >&2; return 1; } else - cp -f "$2" "$1" + cp -f "$src" "$dest" || { printf 'Error copying %s\n' "$src" >&2; return 1; } fi } # arg1 = source path copy_content() { - if [[ $1 == http* ]]; then - curl -f "$1?$(date +%s)" - curl_exit_status=$? - [[ $curl_exit_status != 0 ]] && >&2 echo -e "Error downloading $1" + local src="$1" + if echo "$src" | grep -q '^http'; then + curl -f "$src?$(date +%s)" || { printf 'Error downloading %s\n' "$src" >&2; return 1; } else - cat "$1" + cat "$src" || { printf 'Error reading %s\n' "$src" >&2; return 1; } fi } refresh_package_sources() { - eval "$REFRESH_CMD" + sh -c "$REFRESH_CMD" || { printf 'Error refreshing package sources\n' >&2; return 1; } } update_packages() { - eval "$UPDATE_CMD" - command_exists flatpak && $FLATPAK_UPDATE_CMD + sh -c "$UPDATE_CMD" || { printf 'Error updating packages\n' >&2; return 1; } + if command_exists flatpak; then + sh -c "$FLATPAK_UPDATE_CMD" || printf 'Warning: flatpak update failed\n' >&2 + fi } install_pkgs() { - #doing in loop to avoid abort in case something is wrong - # shellcheck disable=SC2207 - pkgs=($(eval echo "$1")) - for i in "${pkgs[@]}"; do eval "$INSTALL_CMD $i"; done + # Install packages one by one to avoid aborting on individual failures + # Use word splitting instead of bash arrays for POSIX compatibility + for pkg in $1; do + sh -c "$INSTALL_CMD $pkg" || printf 'Warning: Failed to install %s\n' "$pkg" >&2 + done } uninstall_pkgs() { - #doing in loop to avoid abort in case something is wrong - # shellcheck disable=SC2207 - pkgs=($(eval echo "$1")) - for i in "${pkgs[@]}"; do eval "$UNINSTALL_CMD $i"; done + # Uninstall packages one by one to avoid aborting on individual failures + for pkg in $1; do + sh -c "$UNINSTALL_CMD $pkg" || printf 'Warning: Failed to uninstall %s\n' "$pkg" >&2 + done } uninstall_only_pkgs() { - #doing in loop to avoid abort in case something is wrong - # shellcheck disable=SC2207 - pkgs=($(eval echo "$1")) - for i in "${pkgs[@]}"; do eval "$UNINSTALL_ONLY_CMD $i"; done + # Uninstall packages (without dependencies) one by one to avoid aborting on individual failures + for pkg in $1; do + sh -c "$UNINSTALL_ONLY_CMD $pkg" || printf 'Warning: Failed to uninstall %s\n' "$pkg" >&2 + done } debloat_pkgs() { - echo -e "Debloating..." - copy_file $TEMP_DIR/$DISTRO_TYPE.txt "${BASE_REPO_LOCATION}"debloat/$DISTRO_TYPE.txt - while read -r pkg; do + printf 'Debloating...\n' + local debloat_file="$TEMP_DIR/$DISTRO_TYPE.txt" + copy_file "$debloat_file" "${BASE_REPO_LOCATION}debloat/$DISTRO_TYPE.txt" || { printf 'Warning: Could not download debloat list\n' >&2; return; } + while IFS= read -r pkg; do + [ -z "$pkg" ] || echo "$pkg" | grep -q '^#' && continue uninstall_pkgs "$pkg" - done <$TEMP_DIR/$DISTRO_TYPE.txt - rm -f $TEMP_DIR/$DISTRO_TYPE.txt + done < "$debloat_file" + rm -f "$debloat_file" - if [[ $PACKAGES_TO_REMOVE != "" ]]; then - echo -e "Removing additional packages..." + if [ -n "$PACKAGES_TO_REMOVE" ]; then + printf 'Removing additional packages...\n' uninstall_only_pkgs "$PACKAGES_TO_REMOVE" fi } # override with DISTRO_TYPE specific stuffs -echo -e "Executing common $DISTRO_TYPE specific script..." -copy_file $TEMP_DIR/"$DISTRO_TYPE".sh "${BASE_REPO_LOCATION}"distros/"$DISTRO_TYPE".sh -if [[ ! -f $TEMP_DIR/"$DISTRO_TYPE".sh ]]; then - >&2 echo "Error: $DISTRO_TYPE specific script not found!" +printf 'Executing common %s specific script...\n' "$DISTRO_TYPE" +copy_file "$TEMP_DIR/$DISTRO_TYPE.sh" "${BASE_REPO_LOCATION}distros/$DISTRO_TYPE.sh" || { printf 'Error: Failed to download %s specific script\n' "$DISTRO_TYPE" >&2; exit 3; } +if [ ! -f "$TEMP_DIR/$DISTRO_TYPE.sh" ]; then + printf 'Error: %s specific script not found!\n' "$DISTRO_TYPE" >&2 exit 3 fi -# shellcheck disable=SC1090 -source $TEMP_DIR/"$DISTRO_TYPE".sh -rm -f $TEMP_DIR/"$DISTRO_TYPE".sh +. "$TEMP_DIR/$DISTRO_TYPE.sh" || { printf 'Error: Failed to source %s specific script\n' "$DISTRO_TYPE" >&2; exit 3; } +rm -f "$TEMP_DIR/$DISTRO_TYPE.sh" # desktop environment specific stuffs -copy_file $TEMP_DIR/"$DESKTOP".sh "${BASE_REPO_LOCATION}"desktop/"$DESKTOP".sh -# shellcheck disable=SC1090 -[[ -f $TEMP_DIR/"$DESKTOP".sh ]] && source $TEMP_DIR/"$DESKTOP".sh -rm -f $TEMP_DIR/"$DESKTOP".sh +copy_file "$TEMP_DIR/$DESKTOP.sh" "${BASE_REPO_LOCATION}desktop/$DESKTOP.sh" +[ -f "$TEMP_DIR/$DESKTOP.sh" ] && . "$TEMP_DIR/$DESKTOP.sh" +rm -f "$TEMP_DIR/$DESKTOP.sh" # execute exact distro specic stuffs if exists e.g. linux mint, ubuntu, manjaro etc. Optional. -if [[ $DIST_ID != '' ]]; then - copy_file $TEMP_DIR/"$DIST_ID".sh "${BASE_REPO_LOCATION}"specific/"$DIST_ID".sh - # shellcheck disable=SC1090 - [[ -f $TEMP_DIR/"$DIST_ID".sh ]] && source $TEMP_DIR/"$DIST_ID".sh - rm -f $TEMP_DIR/"$DIST_ID".sh +if [ -n "$DIST_ID" ]; then + copy_file "$TEMP_DIR/$DIST_ID.sh" "${BASE_REPO_LOCATION}specific/$DIST_ID.sh" + [ -f "$TEMP_DIR/$DIST_ID.sh" ] && . "$TEMP_DIR/$DIST_ID.sh" + rm -f "$TEMP_DIR/$DIST_ID.sh" fi setup_system() { install_pkgs "virt-what" - SYSTEM_TO_SETUP=$(sudo virt-what) + SYSTEM_TO_SETUP=$(sudo virt-what 2>/dev/null) - if [[ $SYSTEM_TO_SETUP != '' ]]; then - echo -e "SYSTEM=$SYSTEM_TO_SETUP" + if [ -n "$SYSTEM_TO_SETUP" ]; then + printf 'SYSTEM=%s\n' "$SYSTEM_TO_SETUP" - case $SYSTEM_TO_SETUP in + case "$SYSTEM_TO_SETUP" in vmware) install_pkgs "$VMWARE_PACKAGES_TO_INSTALL" - sudo systemctl enable --now vmtoolsd.service - #sudo systemctl disable --now vmware-vmblock-fuse.service + sudo systemctl enable --now vmtoolsd.service 2>/dev/null || true ;; virtualbox) install_pkgs "$VBOX_PACKAGES_TO_INSTALL" - sudo systemctl enable --now vboxservice.service + sudo systemctl enable --now vboxservice.service 2>/dev/null || true ;; hyperv) install_pkgs "$HYPERV_PACKAGES_TO_INSTALL" - sudo systemctl enable --now hv_{fcopy,kvp,vss}_daemon.service + for _svc in hv_fcopy_daemon hv_kvp_daemon hv_vss_daemon; do + sudo systemctl enable --now "${_svc}.service" 2>/dev/null || true + done ;; qemu | kvm | xen | virt) @@ -208,300 +230,258 @@ setup_system() { ;; *) - echo "Ahh! Taking a note..." + printf 'Ahh! Taking a note...\n' ;; esac else # TODO detect bare metal - SYSTEM_TO_SETUP=intel - echo -e "SYSTEM=$SYSTEM_TO_SETUP" + SYSTEM_TO_SETUP=intel + printf 'SYSTEM=%s\n' "$SYSTEM_TO_SETUP" - case $SYSTEM_TO_SETUP in + case "$SYSTEM_TO_SETUP" in intel) install_pkgs "$INTEL_PACKAGES_TO_INSTALL" ;; *) - echo "Ahh! Taking a note..." + printf 'Ahh! Taking a note...\n' ;; - esac + esac fi install_pkgs "$SYSTEM_PACKAGES_TO_INSTALL" - echo -e "Tweaking some system stuffs..." - sudo mkdir -p /etc/sysctl.d /etc/systemd/{journald.conf.d,coredump.conf.d} - copy_content "${BASE_REPO_LOCATION}"system/etc/sysctl.d/999-sysctl.conf | sudo tee /etc/sysctl.d/999-sysctl.conf - copy_content "${BASE_REPO_LOCATION}"system/etc/systemd/journald.conf.d/00-journal-size.conf | sudo tee /etc/systemd/journald.conf.d/00-journal-size.conf - sudo journalctl --rotate --vacuum-size=10M - copy_content "${BASE_REPO_LOCATION}"system/etc/systemd/coredump.conf.d/custom.conf | sudo tee /etc/systemd/coredump.conf.d/custom.conf + printf 'Tweaking some system stuffs...\n' + sudo mkdir -p /etc/sysctl.d /etc/systemd/journald.conf.d /etc/systemd/coredump.conf.d + copy_content "${BASE_REPO_LOCATION}system/etc/sysctl.d/999-sysctl.conf" | sudo tee /etc/sysctl.d/999-sysctl.conf >/dev/null + copy_content "${BASE_REPO_LOCATION}system/etc/systemd/journald.conf.d/00-journal-size.conf" | sudo tee /etc/systemd/journald.conf.d/00-journal-size.conf >/dev/null + sudo journalctl --rotate --vacuum-size=10M 2>/dev/null || true + copy_content "${BASE_REPO_LOCATION}system/etc/systemd/coredump.conf.d/custom.conf" | sudo tee /etc/systemd/coredump.conf.d/custom.conf >/dev/null # env var mkdir -p ~/.config/environment.d - copy_file ~/.config/environment.d/10-defaults.conf "${BASE_REPO_LOCATION}"home/.config/environment.d/10-defaults.conf - - #mkdir -p ~/.config/systemd/user/service.d - #copy_file ~/.config/systemd/user/service.d/env.conf ${BASE_REPO_LOCATION}home/.config/systemd/user/service.d/env.conf + copy_file ~/.config/environment.d/10-defaults.conf "${BASE_REPO_LOCATION}home/.config/environment.d/10-defaults.conf" || true - profileAppend="$( - grep "~custom-setup~" ~/.profile >/dev/null 2>&1 - echo $? - )" - if [[ "${profileAppend}" -ne 0 ]]; then - copy_content "${BASE_REPO_LOCATION}"home/.profile >>~/.profile - fi - - xprofileAppend="$( - grep "~custom-setup~" ~/.xprofile >/dev/null 2>&1 - echo $? - )" - if [[ "${xprofileAppend}" -ne 0 ]]; then - copy_content "${BASE_REPO_LOCATION}"home/.xprofile >>~/.xprofile - fi - - xsessionrcAppend="$( - grep "~custom-setup~" ~/.xsessionrc >/dev/null 2>&1 - echo $? - )" - if [[ "${xsessionrcAppend}" -ne 0 ]]; then - copy_content "${BASE_REPO_LOCATION}"home/.xsessionrc >>~/.xsessionrc - fi + # Helper function for appending to config files + append_if_missing() { + local file="$1" marker="$2" content_source="$3" + if ! grep -q "$marker" "$file" 2>/dev/null; then + copy_content "$content_source" >> "$file" || printf 'Warning: Failed to append to %s\n' "$file" >&2 + fi + } - # DO NOT have .xinitrc for now due to some problems - #xinitrcAppend="$( - # grep "~custom-setup~" ~/.xinitrc >/dev/null 2>&1 - # echo $? - #)" - #if [[ "${xinitrcAppend}" -ne 0 ]]; then - # copy_content ${BASE_REPO_LOCATION}home/.xinitrc >>~/.xinitrc - #fi + append_if_missing ~/.profile "~custom-setup~" "${BASE_REPO_LOCATION}home/.profile" + append_if_missing ~/.xprofile "~custom-setup~" "${BASE_REPO_LOCATION}home/.xprofile" + append_if_missing ~/.xsessionrc "~custom-setup~" "${BASE_REPO_LOCATION}home/.xsessionrc" - echo -e "Setting up keyring..." + printf 'Setting up keyring...\n' mkdir -p ~/.local/share/keyrings/ - copy_file ~/.local/share/keyrings/Default_keyring.keyring "${BASE_REPO_LOCATION}"home/.local/share/keyrings/Default_keyring.keyring - copy_file ~/.local/share/keyrings/default "${BASE_REPO_LOCATION}"home/.local/share/keyrings/default - chmod og= ~/.local/share/keyrings/ - chmod og= ~/.local/share/keyrings/Default_keyring.keyring + copy_file ~/.local/share/keyrings/Default_keyring.keyring "${BASE_REPO_LOCATION}home/.local/share/keyrings/Default_keyring.keyring" || true + copy_file ~/.local/share/keyrings/default "${BASE_REPO_LOCATION}home/.local/share/keyrings/default" || true + chmod og= ~/.local/share/keyrings/ 2>/dev/null || true + chmod og= ~/.local/share/keyrings/Default_keyring.keyring 2>/dev/null || true - echo -e "Updating some sudo stuffs..." + printf 'Updating some sudo stuff...\n' sudo mkdir -p /etc/sudoers.d - echo -e Defaults:"$(whoami)" \!authenticate | sudo tee /etc/sudoers.d/99-custom + printf 'Defaults:%s !authenticate\n' "$(whoami)" | sudo tee /etc/sudoers.d/99-custom >/dev/null # autologin capability - sudo groupadd -r autologin - sudo gpasswd -a "$(whoami)" autologin + sudo groupadd -r autologin 2>/dev/null || true + sudo gpasswd -a "$(whoami)" autologin 2>/dev/null || true - systemctl is-enabled casper-md5check.service && sudo systemctl disable casper-md5check.service + systemctl is-enabled casper-md5check.service 2>/dev/null && sudo systemctl disable casper-md5check.service sudo systemctl daemon-reload } setup_font() { - echo -e "Installing fonts..." + printf 'Installing fonts...\n' install_pkgs "$FONTS_TO_INSTALL" - echo -e "Making font look better..." + printf 'Making font look better...\n' mkdir -p ~/.config/fontconfig/conf.d - copy_file ~/.config/fontconfig/fonts.conf "${BASE_REPO_LOCATION}"home/.config/fontconfig/fonts.conf - copy_file ~/.config/fontconfig/conf.d/20-no-embedded.conf "${BASE_REPO_LOCATION}"home/.config/fontconfig/conf.d/20-no-embedded.conf - copy_file ~/.Xresources "${BASE_REPO_LOCATION}"home/.Xresources - xrdb -merge ~/.Xresources - [[ -f /etc/profile.d/freetype2.sh ]] && sudo sed -i '/export FREETYPE_PROPERTIES=/s/^#//g' /etc/profile.d/freetype2.sh - sudo ln -s /usr/share/fontconfig/conf.avail/10-sub-pixel-rgb.conf /etc/fonts/conf.d/ - sudo ln -s /usr/share/fontconfig/conf.avail/10-hinting-slight.conf /etc/fonts/conf.d/ - sudo ln -s /usr/share/fontconfig/conf.avail/11-lcdfilter-default.conf /etc/fonts/conf.d/ - [[ -f /usr/share/fontconfig/conf.avail/10-nerd-font-symbols.conf ]] && sudo ln -s /usr/share/fontconfig/conf.avail/10-nerd-font-symbols.conf /etc/fonts/conf.d/ - if [[ $(fc-list | grep -i "JetBrainsMono Nerd") == "" ]]; then - echo -e "Installing Nerd Font manually as not found..." + copy_file ~/.config/fontconfig/fonts.conf "${BASE_REPO_LOCATION}home/.config/fontconfig/fonts.conf" || true + copy_file ~/.config/fontconfig/conf.d/20-no-embedded.conf "${BASE_REPO_LOCATION}home/.config/fontconfig/conf.d/20-no-embedded.conf" || true + copy_file ~/.Xresources "${BASE_REPO_LOCATION}home/.Xresources" || true + xrdb -merge ~/.Xresources 2>/dev/null || true + [ -f /etc/profile.d/freetype2.sh ] && sudo sed_i '/export FREETYPE_PROPERTIES=/s/^#//g' /etc/profile.d/freetype2.sh + sudo ln -sf /usr/share/fontconfig/conf.avail/10-sub-pixel-rgb.conf /etc/fonts/conf.d/ 2>/dev/null + sudo ln -sf /usr/share/fontconfig/conf.avail/10-hinting-slight.conf /etc/fonts/conf.d/ 2>/dev/null + sudo ln -sf /usr/share/fontconfig/conf.avail/11-lcdfilter-default.conf /etc/fonts/conf.d/ 2>/dev/null + [ -f /usr/share/fontconfig/conf.avail/10-nerd-font-symbols.conf ] && sudo ln -sf /usr/share/fontconfig/conf.avail/10-nerd-font-symbols.conf /etc/fonts/conf.d/ 2>/dev/null + if ! fc-list | grep -qi "JetBrainsMono Nerd"; then + printf 'Installing Nerd Font manually as not found...\n' mkdir -p ~/.local/bin - curl -fs https://ohmyposh.dev/install.sh | bash -s -- -d ~/.local/bin - ~/.local/bin/oh-my-posh font install JetBrainsMono + curl -fsS https://ohmyposh.dev/install.sh | bash -s -- -d ~/.local/bin || printf 'Warning: Failed to install oh-my-posh\n' >&2 + ~/.local/bin/oh-my-posh font install JetBrainsMono 2>/dev/null || printf 'Warning: Failed to install JetBrainsMono font\n' >&2 fi - sudo fc-cache -fv - fc-cache -fv + sudo fc-cache -fv >/dev/null || printf 'Warning: fc-cache failed\n' >&2 + fc-cache -fv >/dev/null || printf 'Warning: fc-cache failed\n' >&2 } setup_terminal() { - echo -e "Configuring shell stuffs..." + printf 'Configuring shell stuff...\n' install_pkgs "$TERM_PACKAGES_TO_INSTALL" if ! command_exists starship; then mkdir -p ~/.local/bin - curl -fsS https://starship.rs/install.sh | sh -s -- -y --bin-dir ~/.local/bin - fi - #starship preset no-nerd-font -o ~/.config/starship.toml - copy_file ~/.aliases "${BASE_REPO_LOCATION}"distros/$DISTRO_TYPE.aliases - bashrcAppend="$( - grep "~custom-setup~" ~/.bashrc >/dev/null 2>&1 - echo $? - )" - if [[ "${bashrcAppend}" -ne 0 ]]; then - copy_content "${BASE_REPO_LOCATION}"home/.bashrc >>~/.bashrc + curl -fsS https://starship.rs/install.sh | sh -s -- -y --bin-dir ~/.local/bin || printf 'Warning: starship installation failed\n' >&2 fi + copy_file ~/.aliases "${BASE_REPO_LOCATION}distros/$DISTRO_TYPE.aliases" || true + append_if_missing ~/.bashrc "~custom-setup~" "${BASE_REPO_LOCATION}home/.bashrc" # nano mkdir -p ~/.config/nano - copy_file ~/.config/nano/nanorc "${BASE_REPO_LOCATION}"home/.config/nano/nanorc - if [[ -d /usr/share/nano-syntax-highlighting/ ]]; then - nanorcAppend="$( - grep "nano-syntax-highlighting" ~/.config/nano/nanorc >/dev/null 2>&1 - echo $? - )" - if [[ "${nanorcAppend}" -ne 0 ]]; then - echo -e 'include "/usr/share/nano-syntax-highlighting/*.nanorc"' >>~/.config/nano/nanorc + copy_file ~/.config/nano/nanorc "${BASE_REPO_LOCATION}home/.config/nano/nanorc" || true + if [ -d /usr/share/nano-syntax-highlighting/ ]; then + if ! grep -q "nano-syntax-highlighting" ~/.config/nano/nanorc 2>/dev/null; then + printf '%s\n' 'include "/usr/share/nano-syntax-highlighting/*.nanorc"' >> ~/.config/nano/nanorc fi fi # if fastfetch not found at this point fallback to neofetch, otherwise remove neofetch - if ! which fastfetch; then + if ! command_exists fastfetch; then install_pkgs neofetch else uninstall_pkgs neofetch fi - # fastfetch - #mkdir p ~/.config/fastfetch - #copy_file ~/.config/fastfetch/config.jsonc ${BASE_REPO_LOCATION}home/.config/fastfetch/config.jsonc - - echo -e "Installing terminal $TERMINAL_TO_INSTALL..." - case $TERMINAL_TO_INSTALL in + printf 'Installing terminal %s...\n' "$TERMINAL_TO_INSTALL" + case "$TERMINAL_TO_INSTALL" in alacritty) - install_pkgs $TERMINAL_TO_INSTALL + install_pkgs "$TERMINAL_TO_INSTALL" mkdir -p ~/.config/alacritty - copy_file ~/.config/alacritty/catppuccin-mocha.toml https://raw.githubusercontent.com/catppuccin/alacritty/main/catppuccin-mocha.toml - copy_file ~/.config/alacritty/alacritty.toml "${BASE_REPO_LOCATION}"home/.config/alacritty/alacritty.toml + copy_file ~/.config/alacritty/catppuccin-mocha.toml https://raw.githubusercontent.com/catppuccin/alacritty/main/catppuccin-mocha.toml || true + copy_file ~/.config/alacritty/alacritty.toml "${BASE_REPO_LOCATION}home/.config/alacritty/alacritty.toml" || true ;; kitty) - install_pkgs $TERMINAL_TO_INSTALL + install_pkgs "$TERMINAL_TO_INSTALL" mkdir -p ~/.config/kitty - copy_file ~/.config/kitty/mocha.conf https://raw.githubusercontent.com/catppuccin/kitty/main/themes/mocha.conf - copy_file ~/.config/kitty/kitty.conf "${BASE_REPO_LOCATION}"home/.config/kitty/kitty.conf + copy_file ~/.config/kitty/mocha.conf https://raw.githubusercontent.com/catppuccin/kitty/main/themes/mocha.conf || true + copy_file ~/.config/kitty/kitty.conf "${BASE_REPO_LOCATION}home/.config/kitty/kitty.conf" || true ;; wezterm) - install_pkgs $TERMINAL_TO_INSTALL + install_pkgs "$TERMINAL_TO_INSTALL" mkdir -p ~/.config/wezterm - copy_file ~/.config/wezterm/wezterm.lua "${BASE_REPO_LOCATION}"home/.config/wezterm/wezterm.lua + copy_file ~/.config/wezterm/wezterm.lua "${BASE_REPO_LOCATION}home/.config/wezterm/wezterm.lua" || true ;; *) - echo -e "No additional terminal installed..." + printf 'No additional terminal installed...\n' ;; esac # gnome terminal if command_exists gnome-terminal; then - tprofileid=$(gsettings get org.gnome.Terminal.ProfilesList default | tr -d "'") - copy_file $TEMP_DIR/gterm.dconf "${BASE_REPO_LOCATION}"desktop/gterm.dconf - sed -i "s/DEFAULT_PROFILE/$tprofileid/g" $TEMP_DIR/gterm.dconf - dconf load /org/gnome/terminal/ <$TEMP_DIR/gterm.dconf - rm -f $TEMP_DIR/gterm.dconf + tprofileid=$(gsettings get org.gnome.Terminal.ProfilesList default 2>/dev/null | tr -d "'" || echo "default") + copy_file "$TEMP_DIR/gterm.dconf" "${BASE_REPO_LOCATION}desktop/gterm.dconf" && { + sed_i "s/DEFAULT_PROFILE/$tprofileid/g" "$TEMP_DIR/gterm.dconf" + dconf load /org/gnome/terminal/ < "$TEMP_DIR/gterm.dconf" 2>/dev/null || printf 'Warning: Failed to load dconf settings\n' >&2 + rm -f "$TEMP_DIR/gterm.dconf" + } fi - - #source ~/.bashrc } setup_common_ui() { install_pkgs "$GTK_PACKAGES_TO_INSTALL" install_pkgs "$QT_PACKAGES_TO_INSTALL" - gtktheme=$(gsettings get org.gnome.desktop.interface gtk-theme | tr -d \'\") - echo -e "CURRENT_GTK_THEME=$gtktheme" - # shellcheck disable=SC2086 - # shellcheck disable=SC2143 + gtktheme=$(gsettings get org.gnome.desktop.interface gtk-theme 2>/dev/null | tr -d "'" || echo "") + printf 'CURRENT_GTK_THEME=%s\n' "$gtktheme" # make it dark - if [[ $gtktheme != '' && ! $(echo $gtktheme | grep -i dark) ]]; then - gsettings set org.gnome.desktop.interface gtk-theme "$gtktheme"-dark + if [ -n "$gtktheme" ] && ! echo "$gtktheme" | grep -q -- '-dark$'; then + gsettings set org.gnome.desktop.interface gtk-theme "$gtktheme-dark" 2>/dev/null || true fi - copy_file $TEMP_DIR/common.dconf "${BASE_REPO_LOCATION}"desktop/common.dconf - dconf load / <$TEMP_DIR/common.dconf - rm -f $TEMP_DIR/common.dconf + copy_file "$TEMP_DIR/common.dconf" "${BASE_REPO_LOCATION}desktop/common.dconf" && { + dconf load / < "$TEMP_DIR/common.dconf" 2>/dev/null || printf 'Warning: Failed to load dconf settings\n' >&2 + rm -f "$TEMP_DIR/common.dconf" + } - mkdir -p ~/.config/gtk-{3,4}.0 - if [[ ! -f ~/.config/gtk-3.0/settings.ini ]]; then - echo -e "[Settings]" >~/.config/gtk-3.0/settings.ini && echo -e "#gtk-application-prefer-dark-theme=true" >>~/.config/gtk-3.0/settings.ini + mkdir -p ~/.config/gtk-3.0 ~/.config/gtk-4.0 + if [ ! -f ~/.config/gtk-3.0/settings.ini ]; then + printf '[Settings]\n' > ~/.config/gtk-3.0/settings.ini + printf '#gtk-application-prefer-dark-theme=true\n' >> ~/.config/gtk-3.0/settings.ini fi - if [[ ! -f ~/.config/gtk-4.0/settings.ini ]]; then - cp ~/.config/gtk-3.0/settings.ini ~/.config/gtk-4.0/ - echo -e "gtk-hint-font-metrics=1" >>~/.config/gtk-4.0/settings.ini + if [ ! -f ~/.config/gtk-4.0/settings.ini ]; then + cp ~/.config/gtk-3.0/settings.ini ~/.config/gtk-4.0/ || true + printf 'gtk-hint-font-metrics=1\n' >> ~/.config/gtk-4.0/settings.ini fi - mkdir -p ~/.local/share/gtksourceview-{3.0,4,5}/styles - copy_file ~/.local/share/gtksourceview-3.0/styles/mocha.xml https://raw.githubusercontent.com/catppuccin/xed/main/src/mocha.xml - for i in ~/.local/share/gtksourceview-{4,5}/styles; do - cp -s -f ~/.local/share/gtksourceview-3.0/styles/mocha.xml "$i" + mkdir -p ~/.local/share/gtksourceview-3.0/styles ~/.local/share/gtksourceview-4/styles ~/.local/share/gtksourceview-5/styles + copy_file ~/.local/share/gtksourceview-3.0/styles/mocha.xml https://raw.githubusercontent.com/catppuccin/xed/main/src/mocha.xml || true + for _gv in ~/.local/share/gtksourceview-4/styles ~/.local/share/gtksourceview-5/styles; do + cp -sf ~/.local/share/gtksourceview-3.0/styles/mocha.xml "$_gv" 2>/dev/null || true done - echo -e "Setting up QT apps to look like GTK.." - mkdir -p ~/.config/Kvantum ~/.config/qt{5,6}ct - copy_file ~/.config/Kvantum/kvantum.kvconfig "${BASE_REPO_LOCATION}"home/.config/Kvantum/kvantum.kvconfig + printf 'Setting up QT apps to look like GTK...\n' + mkdir -p ~/.config/Kvantum ~/.config/qt5ct ~/.config/qt6ct + copy_file ~/.config/Kvantum/kvantum.kvconfig "${BASE_REPO_LOCATION}home/.config/Kvantum/kvantum.kvconfig" || true for i in 5 6; do - copy_file ~/.config/qt${i}ct/qt${i}ct.conf "${BASE_REPO_LOCATION}"home/.config/qt${i}ct/qt${i}ct.conf + copy_file ~/.config/qt"${i}"ct/qt"${i}"ct.conf "${BASE_REPO_LOCATION}home/.config/qt${i}ct/qt${i}ct.conf" || true done - # wallpaper - #mkdir -p ~/.local/share/backgrounds - #copy_file ~/.local/share/backgrounds/wallpaper ${BASE_REPO_LOCATION}home/.local/share/backgrounds/wallpaper - - if [[ -d /etc/lightdm ]]; then - echo -e "Configuring lightdm stuffs..." - grep -rl greeter-hide-users /etc/lightdm /usr/share/lightdm \ - | xargs sudo sed -i "/greeter-hide-users=true/c\greeter-hide-users=false - /greeter-hide-users = true/c\greeter-hide-users = false" + if [ -d /etc/lightdm ]; then + printf 'Configuring lightdm stuff...\n' + lightdm_files=$(grep -rl greeter-hide-users /etc/lightdm /usr/share/lightdm 2>/dev/null) || true + if [ -n "$lightdm_files" ]; then + printf '%s\n' "$lightdm_files" | xargs sudo sed_i "/greeter-hide-users=true/c\\greeter-hide-users=false" 2>/dev/null || true + fi fi } setup_apps() { - echo -e "Installing some apps..." + printf 'Installing some apps...\n' install_pkgs "$APP_PACKAGES_TO_INSTALL" - echo -e "Installing some dev stuffs..." + printf 'Installing some dev stuff...\n' install_pkgs "$DEV_PACKAGES_TO_INSTALL" - #python -m pip install --user --upgrade pip # vlc mkdir -p ~/.config/vlc - copy_file ~/.config/vlc/vlcrc "${BASE_REPO_LOCATION}"home/.config/vlc/vlcrc + copy_file ~/.config/vlc/vlcrc "${BASE_REPO_LOCATION}home/.config/vlc/vlcrc" || true if command_exists yad; then - gsettings set yad.settings terminal "$CURRENT_TERMINAL"' -e "%s"' + gsettings set yad.settings terminal "$CURRENT_TERMINAL"' -e "%s"' 2>/dev/null || true fi - echo -e "Setting up file associations..." - copy_file ~/.config/mimeapps.list "${BASE_REPO_LOCATION}"home/.config/mimeapps.list - sed -i "s/DEFAULT_TEXT_EDITOR/$GUI_TEXT_EDITOR/g" ~/.config/mimeapps.list + printf 'Setting up file associations...\n' + copy_file ~/.config/mimeapps.list "${BASE_REPO_LOCATION}home/.config/mimeapps.list" || true + [ -f ~/.config/mimeapps.list ] && sed_i "s/DEFAULT_TEXT_EDITOR/$GUI_TEXT_EDITOR/g" ~/.config/mimeapps.list mkdir -p ~/.local/share/applications - ln -sf ~/.config/mimeapps.list ~/.local/share/applications/mimeapps.list + ln -sf ~/.config/mimeapps.list ~/.local/share/applications/mimeapps.list 2>/dev/null || true } debloat_pkgs refresh_package_sources -echo -e "Installing some needed stuffs..." +printf 'Installing required packages...\n' install_pkgs "$REQUIREMENTS" -[[ $(type -t setup_"$DISTRO_TYPE") == function ]] && setup_"$DISTRO_TYPE" +if (command -v setup_"$DISTRO_TYPE" >/dev/null 2>&1); then + setup_"$DISTRO_TYPE" +fi install_pkgs crudini -if [[ $(type -t setup_specific_"$DIST_ID") == function ]]; then - echo -e "Executing additional $DIST_ID specific script..." +if (command -v setup_specific_"$DIST_ID" >/dev/null 2>&1); then + printf 'Executing additional %s specific script...\n' "$DIST_ID" setup_specific_"$DIST_ID" fi update_packages setup_system setup_font setup_apps -[[ $(type -t setup_"$DESKTOP") == function ]] && setup_"$DESKTOP" +if (command -v setup_"$DESKTOP" >/dev/null 2>&1); then + setup_"$DESKTOP" +fi setup_common_ui -if [[ $(type -t setup_"$DISTRO_TYPE"_"$DESKTOP") == function ]]; then - echo -e "Executing additional $DISTRO_TYPE $DESKTOP specific script..." +if (command -v setup_"$DISTRO_TYPE"_"$DESKTOP" >/dev/null 2>&1); then + printf 'Executing additional %s %s specific script...\n' "$DISTRO_TYPE" "$DESKTOP" setup_"$DISTRO_TYPE"_"$DESKTOP" fi -if [[ $(type -t setup_specific_"$DIST_ID"_"$DESKTOP") == function ]]; then - echo -e "Executing additional $DIST_ID $DESKTOP specific script..." +if (command -v setup_specific_"$DIST_ID"_"$DESKTOP" >/dev/null 2>&1); then + printf 'Executing additional %s %s specific script...\n' "$DIST_ID" "$DESKTOP" setup_specific_"$DIST_ID"_"$DESKTOP" fi setup_terminal update_packages -alias reboot='sudo reboot' -echo -e "" -echo -e "Done...Reboot..." -#disown -ar +printf '\n%s\n' "Setup complete! Please reboot your system." + diff --git a/setup.sh b/setup.sh index f96e4e3..3fa3dd7 100644 --- a/setup.sh +++ b/setup.sh @@ -1,13 +1,17 @@ -#!/bin/bash -# shellcheck disable=SC1091 -# shellcheck disable=SC2128 +#!/bin/sh timestamp=$(date '+%Y-%m-%d-%H:%M:%S') -scriptDir=$(dirname -- "$(readlink -f -- "$BASH_SOURCE")") -if [[ -d "$scriptDir"/.git && -f "$scriptDir"/scripts/setup-main.sh ]]; then - echo -e "Running from local clone..." - . "$scriptDir"/scripts/setup-main.sh 2>&1 | tee ~/setup-"$timestamp".log +scriptDir=$(cd -- "$(dirname -- "$0")" && pwd) || { printf 'Error: Failed to determine script directory\n' >&2; exit 1; } + +if [ -d "$scriptDir/.git" ] && [ -f "$scriptDir/scripts/setup-main.sh" ]; then + printf 'Running from local clone...\n' + . "$scriptDir/scripts/setup-main.sh" 2>&1 | tee ~/setup-"$timestamp".log else - echo -e "Running from remote on the fly..." - eval "$(curl -fsSL https://raw.githubusercontent.com/krish-gh/linux-setup/main/scripts/setup-main.sh?"$timestamp")" 2>&1 | tee ~/setup-"$timestamp".log + printf 'Running from remote sources...\n' + # Download and execute the main setup script + if ! curl -fsSL "https://raw.githubusercontent.com/krish-gh/linux-setup/main/scripts/setup-main.sh?$timestamp" | sh 2>&1 | tee ~/setup-"$timestamp".log; then + printf 'Error: Failed to download or execute setup script\n' >&2 + exit 1 + fi fi + diff --git a/specific/arch.sh b/specific/arch.sh index 0412efe..37ea4b7 100644 --- a/specific/arch.sh +++ b/specific/arch.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/sh setup_specific_arch_xfce() { install_pkgs "materia-gtk-theme papirus-icon-theme" @@ -7,4 +7,4 @@ setup_specific_arch_xfce() { setup_xfce_panel } -echo -e "Done arch.sh..." +printf 'Done arch.sh...\n' diff --git a/specific/debian.sh b/specific/debian.sh index f934802..c58a350 100644 --- a/specific/debian.sh +++ b/specific/debian.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/sh setup_specific_debian() { install_pkgs "pipewire-audio" @@ -10,4 +10,4 @@ setup_specific_debian_xfce() { setup_xfce_panel } -echo -e "Done debian.sh..." +printf 'Done debian.sh...\n' diff --git a/specific/linuxmint.sh b/specific/linuxmint.sh index 1788da8..381547b 100644 --- a/specific/linuxmint.sh +++ b/specific/linuxmint.sh @@ -1,6 +1,5 @@ -#!/bin/bash +#!/bin/sh -# shellcheck disable=SC2034 GUI_TEXT_EDITOR=xed.desktop setup_specific_linuxmint() { @@ -9,9 +8,9 @@ setup_specific_linuxmint() { # just ensuring this meta package was not uninstalled, it will wait for confirmation if it was sudo apt-get install mint-meta-"$DESKTOP" install_pkgs "mint-meta-core mint-meta-codecs" - copy_file "$TEMP_DIR"/linuxmint.dconf "${BASE_REPO_LOCATION}"specific/linuxmint.dconf - dconf load / <"$TEMP_DIR"/linuxmint.dconf - rm -f "$TEMP_DIR"/linuxmint.dconf + copy_file "$TEMP_DIR/linuxmint.dconf" "${BASE_REPO_LOCATION}specific/linuxmint.dconf" + dconf load / < "$TEMP_DIR/linuxmint.dconf" 2>/dev/null || printf 'Warning: Failed to load dconf settings\n' >&2 + rm -f "$TEMP_DIR/linuxmint.dconf" } setup_specific_linuxmint_xfce() { @@ -22,4 +21,4 @@ setup_specific_linuxmint_xfce() { xfconf-query -c xfwm4 -v -n -p /general/theme -t string -s Mint-Y-Dark } -echo -e "Done linuxmint.sh..." +printf 'Done linuxmint.sh...\n' diff --git a/specific/neon.sh b/specific/neon.sh index 57ad458..a08bad1 100644 --- a/specific/neon.sh +++ b/specific/neon.sh @@ -1,8 +1,8 @@ -#!/bin/bash +#!/bin/sh setup_specific_neon() { # just ensuring this meta package was not uninstalled, it will wait for confirmation if it was sudo apt-get install neon-desktop neon-essentials-desktop ubuntu-minimal } -echo -e "Done neon.sh..." +printf 'Done neon.sh...\n' diff --git a/specific/ubuntu.sh b/specific/ubuntu.sh index 02751c2..0fd9713 100644 --- a/specific/ubuntu.sh +++ b/specific/ubuntu.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/sh setup_specific_ubuntu() { # echo -e "Replacing snap version of firefox with native one..." @@ -12,4 +12,4 @@ setup_specific_ubuntu() { sudo apt-get install ubuntu-desktop-minimal } -echo -e "Done ubuntu.sh..." +printf 'Done ubuntu.sh...\n'