Skip to content

Commit

Permalink
refact: fix (almost) all shellcheck and shfmt errors
Browse files Browse the repository at this point in the history
the only files i didn't fix:
- core/tabs/utils/ssh.sh (ref #996)
- core/tabs/system-setup/arch/server-setup.sh
  • Loading branch information
adamperkowski committed Jan 11, 2025
1 parent d91a44e commit d93d81a
Show file tree
Hide file tree
Showing 23 changed files with 156 additions and 151 deletions.
2 changes: 1 addition & 1 deletion core/tabs/applications-setup/android-debloat.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ install_adb() {
"$ESCALATION_TOOL" "$PACKAGER" add android-tools
;;
*)
printf "%b\n" "${RED}Unsupported package manager: "$PACKAGER"${RC}"
printf "%b\n" "${RED}Unsupported package manager: $PACKAGER${RC}"
exit 1
;;
esac
Expand Down
4 changes: 2 additions & 2 deletions core/tabs/applications-setup/browsers/librewolf.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ installLibreWolf() {
case "$PACKAGER" in
apt-get|nala)
"$ESCALATION_TOOL" "$PACKAGER" install -y gnupg lsb-release apt-transport-https ca-certificates
distro=`if echo " una bookworm vanessa focal jammy bullseye vera uma " | grep -q " $(lsb_release -sc) "; then lsb_release -sc; else echo focal; fi`
distro=$(if echo " una bookworm vanessa focal jammy bullseye vera uma " | grep -q "$(lsb_release -sc)"; then "$(lsb_release -sc)"; else echo 'focal'; fi)
curl -fsSL https://deb.librewolf.net/keyring.gpg | "$ESCALATION_TOOL" gpg --dearmor -o /usr/share/keyrings/librewolf.gpg
echo "Types: deb
URIs: https://deb.librewolf.net
Expand Down Expand Up @@ -49,4 +49,4 @@ Signed-By: /usr/share/keyrings/librewolf.gpg" | "$ESCALATION_TOOL" tee /etc/apt/
checkEnv
checkEscalationTool
checkAURHelper
installLibreWolf
installLibreWolf
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ installDiscord() {
"$ESCALATION_TOOL" "$PACKAGER" -S --needed --noconfirm discord
;;
dnf)
"$ESCALATION_TOOL" "$PACKAGER" install -y https://download1.rpmfusion.org/nonfree/fedora/rpmfusion-nonfree-release-$(rpm -E %fedora).noarch.rpm
"$ESCALATION_TOOL" "$PACKAGER" install -y "https://download1.rpmfusion.org/nonfree/fedora/rpmfusion-nonfree-release-$(rpm -E %fedora).noarch.rpm"
"$ESCALATION_TOOL" "$PACKAGER" install -y discord
;;
apk)
Expand All @@ -36,4 +36,4 @@ installDiscord() {

checkEnv
checkEscalationTool
installDiscord
installDiscord
52 changes: 26 additions & 26 deletions core/tabs/applications-setup/communication-apps/signal-setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,31 +6,31 @@ installSignal() {
if ! command_exists org.signal.Signal && ! command_exists signal; then
printf "%b\n" "${YELLOW}Installing Signal...${RC}"
case "$PACKAGER" in
apt-get|nala)
curl -fsSL https://updates.signal.org/desktop/apt/keys.asc | gpg --dearmor > signal-desktop-keyring.gpg
cat signal-desktop-keyring.gpg | "$ESCALATION_TOOL" tee /usr/share/keyrings/signal-desktop-keyring.gpg > /dev/null
printf "%b\n" 'deb [arch=amd64 signed-by=/usr/share/keyrings/signal-desktop-keyring.gpg] https://updates.signal.org/desktop/apt xenial main' | "$ESCALATION_TOOL" tee /etc/apt/sources.list.d/signal-xenial.list
"$ESCALATION_TOOL" "$PACKAGER" update
"$ESCALATION_TOOL" "$PACKAGER" -y install signal-desktop
;;
zypper)
"$ESCALATION_TOOL" "$PACKAGER" --non-interactive install signal-desktop
;;
pacman)
"$ESCALATION_TOOL" "$PACKAGER" -S --noconfirm signal-desktop
;;
dnf)
checkFlatpak
flatpak install -y flathub org.signal.Signal
;;
apk)
checkFlatpak
flatpak install -y flathub org.signal.Signal
;;
*)
printf "%b\n" "${RED}Unsupported package manager: ""$PACKAGER""${RC}"
exit 1
;;
apt-get | nala)
curl -fsSL https://updates.signal.org/desktop/apt/keys.asc | gpg --dearmor >signal-desktop-keyring.gpg
"$ESCALATION_TOOL" tee /usr/share/keyrings/signal-desktop-keyring.gpg <signal-desktop-keyring.gpg >/dev/null
printf "%b\n" 'deb [arch=amd64 signed-by=/usr/share/keyrings/signal-desktop-keyring.gpg] https://updates.signal.org/desktop/apt xenial main' | "$ESCALATION_TOOL" tee /etc/apt/sources.list.d/signal-xenial.list
"$ESCALATION_TOOL" "$PACKAGER" update
"$ESCALATION_TOOL" "$PACKAGER" -y install signal-desktop
;;
zypper)
"$ESCALATION_TOOL" "$PACKAGER" --non-interactive install signal-desktop
;;
pacman)
"$ESCALATION_TOOL" "$PACKAGER" -S --noconfirm signal-desktop
;;
dnf)
checkFlatpak
flatpak install -y flathub org.signal.Signal
;;
apk)
checkFlatpak
flatpak install -y flathub org.signal.Signal
;;
*)
printf "%b\n" "${RED}Unsupported package manager: ""$PACKAGER""${RC}"
exit 1
;;
esac
else
printf "%b\n" "${GREEN}Signal is already installed.${RC}"
Expand All @@ -39,4 +39,4 @@ installSignal() {

checkEnv
checkEscalationTool
installSignal
installSignal
4 changes: 2 additions & 2 deletions core/tabs/applications-setup/dwmtitus-setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ setupDisplayManager() {
"$ESCALATION_TOOL" "$PACKAGER" install -y xorg-x11-xinit xorg-x11-server-Xorg
;;
*)
printf "%b\n" "${RED}Unsupported package manager: "$PACKAGER"${RC}"
printf "%b\n" "${RED}Unsupported package manager: $PACKAGER${RC}"
exit 1
;;
esac
Expand Down Expand Up @@ -244,7 +244,7 @@ setupDisplayManager() {
"$ESCALATION_TOOL" "$PACKAGER" install -y "$DM"
;;
*)
printf "%b\n" "${RED}Unsupported package manager: "$PACKAGER"${RC}"
printf "%b\n" "${RED}Unsupported package manager: $PACKAGER${RC}"
exit 1
;;
esac
Expand Down
2 changes: 1 addition & 1 deletion core/tabs/applications-setup/linutil-installer.sh
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ installLinutil() {
;;
*)
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
. $HOME/.cargo/env
. "$HOME/.cargo/env"
;;
esac
fi
Expand Down
40 changes: 20 additions & 20 deletions core/tabs/applications-setup/linutil-updater.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,26 +10,26 @@ updateLinutil() {

if ! command_exists cargo; then
printf "%b\n" "${YELLOW}Installing rustup...${RC}"
case "$PACKAGER" in
pacman)
"$ESCALATION_TOOL" "$PACKAGER" -S --needed --noconfirm rustup
;;
zypper)
"$ESCALATION_TOOL" "$PACKAGER" install -n curl gcc make
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
. $HOME/.cargo/env
;;
apk)
"$ESCALATION_TOOL" "$PACKAGER" add build-base
"$ESCALATION_TOOL" "$PACKAGER" add rustup
rustup-init
# shellcheck disable=SC1091
. "$HOME/.cargo/env"
;;
*)
"$ESCALATION_TOOL" "$PACKAGER" install -y rustup
;;
esac
case "$PACKAGER" in
pacman)
"$ESCALATION_TOOL" "$PACKAGER" -S --needed --noconfirm rustup
;;
zypper)
"$ESCALATION_TOOL" "$PACKAGER" install -n curl gcc make
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
. "$HOME/.cargo/env"
;;
apk)
"$ESCALATION_TOOL" "$PACKAGER" add build-base
"$ESCALATION_TOOL" "$PACKAGER" add rustup
rustup-init
# shellcheck disable=SC1091
. "$HOME/.cargo/env"
;;
*)
"$ESCALATION_TOOL" "$PACKAGER" install -y rustup
;;
esac
fi

INSTALLED_VERSION=$(cargo install --list | grep "linutil_tui" | awk '{print $2}' | tr -d 'v:')
Expand Down
12 changes: 6 additions & 6 deletions core/tabs/system-setup/compile-setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,38 +15,38 @@ installDepend() {
else
printf "%b\n" "${GREEN}Multilib is already enabled.${RC}"
fi
"$AUR_HELPER" -S --needed --noconfirm $DEPENDENCIES
"$AUR_HELPER" -S --needed --noconfirm "$DEPENDENCIES"
;;
apt-get|nala)
COMPILEDEPS='build-essential'
"$ESCALATION_TOOL" "$PACKAGER" update
"$ESCALATION_TOOL" dpkg --add-architecture i386
"$ESCALATION_TOOL" "$PACKAGER" update
"$ESCALATION_TOOL" "$PACKAGER" install -y $DEPENDENCIES $COMPILEDEPS
"$ESCALATION_TOOL" "$PACKAGER" install -y "$DEPENDENCIES" "$COMPILEDEPS"
;;
dnf)
COMPILEDEPS='@development-tools'
"$ESCALATION_TOOL" "$PACKAGER" update
"$ESCALATION_TOOL" "$PACKAGER" config-manager --set-enabled powertools
"$ESCALATION_TOOL" "$PACKAGER" install -y $DEPENDENCIES $COMPILEDEPS
"$ESCALATION_TOOL" "$PACKAGER" install -y "$DEPENDENCIES" "$COMPILEDEPS"
"$ESCALATION_TOOL" "$PACKAGER" install -y glibc-devel.i686 libgcc.i686
;;
zypper)
COMPILEDEPS='patterns-devel-base-devel_basis'
"$ESCALATION_TOOL" "$PACKAGER" refresh
"$ESCALATION_TOOL" "$PACKAGER" --non-interactive install $DEPENDENCIES $COMPILEDEPS
"$ESCALATION_TOOL" "$PACKAGER" --non-interactive install "$DEPENDENCIES" "$COMPILEDEPS"
"$ESCALATION_TOOL" "$PACKAGER" --non-interactive install libgcc_s1-gcc7-32bit glibc-devel-32bit
;;
apk)
"$ESCALATION_TOOL" "$PACKAGER" add build-base multitail tar tree trash-cli unzip cmake jq
;;
*)
"$ESCALATION_TOOL" "$PACKAGER" install -y $DEPENDENCIES
"$ESCALATION_TOOL" "$PACKAGER" install -y "$DEPENDENCIES"
;;
esac
}

checkEnv
checkAURHelper
checkEscalationTool
installDepend
installDepend
74 changes: 37 additions & 37 deletions core/tabs/system-setup/system-cleanup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,30 +6,30 @@
cleanup_system() {
printf "%b\n" "${YELLOW}Performing system cleanup...${RC}"
case "$PACKAGER" in
apt-get|nala)
"$ESCALATION_TOOL" "$PACKAGER" clean
"$ESCALATION_TOOL" "$PACKAGER" autoremove -y
"$ESCALATION_TOOL" du -h /var/cache/apt
;;
zypper)
"$ESCALATION_TOOL" "$PACKAGER" clean -a
"$ESCALATION_TOOL" "$PACKAGER" tidy
"$ESCALATION_TOOL" "$PACKAGER" cc -a
;;
dnf)
"$ESCALATION_TOOL" "$PACKAGER" clean all
"$ESCALATION_TOOL" "$PACKAGER" autoremove -y
;;
pacman)
"$ESCALATION_TOOL" "$PACKAGER" -Sc --noconfirm
"$ESCALATION_TOOL" "$PACKAGER" -Rns $(pacman -Qtdq) --noconfirm > /dev/null || true
;;
apk)
"$ESCALATION_TOOL" "$PACKAGER" cache clean
;;
*)
printf "%b\n" "${RED}Unsupported package manager: ${PACKAGER}. Skipping.${RC}"
;;
apt-get | nala)
"$ESCALATION_TOOL" "$PACKAGER" clean
"$ESCALATION_TOOL" "$PACKAGER" autoremove -y
"$ESCALATION_TOOL" du -h /var/cache/apt
;;
zypper)
"$ESCALATION_TOOL" "$PACKAGER" clean -a
"$ESCALATION_TOOL" "$PACKAGER" tidy
"$ESCALATION_TOOL" "$PACKAGER" cc -a
;;
dnf)
"$ESCALATION_TOOL" "$PACKAGER" clean all
"$ESCALATION_TOOL" "$PACKAGER" autoremove -y
;;
pacman)
"$ESCALATION_TOOL" "$PACKAGER" -Sc --noconfirm
"$ESCALATION_TOOL" "$PACKAGER" -Rns "$(pacman -Qtdq)" --noconfirm >/dev/null || true
;;
apk)
"$ESCALATION_TOOL" "$PACKAGER" cache clean
;;
*)
printf "%b\n" "${RED}Unsupported package manager: ${PACKAGER}. Skipping.${RC}"
;;
esac
}

Expand All @@ -52,19 +52,19 @@ clean_data() {
printf "%b" "${YELLOW}Clean up old cache files and empty the trash? (y/N): ${RC}"
read -r clean_response
case $clean_response in
y|Y)
printf "%b\n" "${YELLOW}Cleaning up old cache files and emptying trash...${RC}"
if [ -d "$HOME/.cache" ]; then
find "$HOME/.cache/" -type f -atime +5 -delete
fi
if [ -d "$HOME/.local/share/Trash" ]; then
find "$HOME/.local/share/Trash" -mindepth 1 -delete
fi
printf "%b\n" "${GREEN}Cache and trash cleanup completed.${RC}"
;;
*)
printf "%b\n" "${YELLOW}Skipping cache and trash cleanup.${RC}"
;;
y | Y)
printf "%b\n" "${YELLOW}Cleaning up old cache files and emptying trash...${RC}"
if [ -d "$HOME/.cache" ]; then
find "$HOME/.cache/" -type f -atime +5 -delete
fi
if [ -d "$HOME/.local/share/Trash" ]; then
find "$HOME/.local/share/Trash" -mindepth 1 -delete
fi
printf "%b\n" "${GREEN}Cache and trash cleanup completed.${RC}"
;;
*)
printf "%b\n" "${YELLOW}Skipping cache and trash cleanup.${RC}"
;;
esac
}

Expand Down
15 changes: 7 additions & 8 deletions core/tabs/utils/bluetooth-control.sh
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,11 @@ scan_devices() {
printf "%b\n" "$devices"
fi
printf "%b" "Press any key to return to the main menu..."
read -r dummy
read -r _
}

# Function to prompt for MAC address using numbers
prompt_for_mac() {
action=$1
command=$2
prompt_msg=$3
success_msg=$4
Expand All @@ -82,14 +81,14 @@ prompt_for_mac() {
if [ -z "$devices" ]; then
printf "%b\n" "${RED}No devices available. Please scan for devices first.${RC}"
printf "%b" "Press any key to return to the main menu..."
read -r dummy
read -r _
return
fi

# Display devices with numbers
device_list=$(echo "$devices" | tr '\n' '\n')
i=1
echo "$device_list" | while IFS= read -r device; do
for device in $device_list; do
printf "%d. %s\n" "$i" "$device"
i=$((i + 1))
done
Expand All @@ -102,12 +101,12 @@ prompt_for_mac() {
device=$(echo "$device_list" | sed -n "${choice}p")
mac=$(echo "$device" | awk '{print $2}')
if bluetoothctl info "$mac" > /dev/null 2>&1; then
bluetoothctl "$command" "$mac" && {
if bluetoothctl "$command" "$mac"; then
printf "%b\n" "${GREEN}$success_msg${RC}"
break
} || {
else
printf "%b\n" "${RED}$failure_msg${RC}"
}
fi
else
printf "%b\n" "${RED}Invalid MAC address. Please try again.${RC}"
fi
Expand All @@ -118,7 +117,7 @@ prompt_for_mac() {
fi
done
printf "%b" "Press any key to return to the main menu..."
read -r dummy
read -r _
}

# Function to pair with a device
Expand Down
Loading

0 comments on commit d93d81a

Please sign in to comment.