Add Arch Linux support; Various tweaks

This commit is contained in:
2025-08-05 19:41:13 +01:00
parent 1df7b20fc5
commit 549aa12b46
17 changed files with 215 additions and 661 deletions

View File

@@ -1,33 +0,0 @@
#! /bin/sh
RED="\e[31m"
GREEN="\e[32m"
YELLOW="\e[33m"
MAGENTA="\e[35m"
CYAN="\e[36m"
BOLD="\e[1m"
NC="\e[0m"
BATTERY_INFO=$(upower -i "$(upower -e | grep 'BAT')")
BATTERY_PERCENT=$(echo "$BATTERY_INFO" | grep -oP 'percentage:\s+\K\d+')
BATTERY_STATUS=$(echo "$BATTERY_INFO" | grep -oP 'state:\s+\K\w+')
CHARGE_CYCLES=$(echo "$BATTERY_INFO" | grep -oP 'cycle-count:\s+\K\d+')
WARNING_LEVEL=$(echo "$BATTERY_INFO" | grep -oP 'warning-level:\s+\K\w+')
if [ "$BATTERY_STATUS" = "charging" ] || [ "$BATTERY_STATUS" = "pending" ]; then
COLOR=$CYAN
elif [ "$BATTERY_PERCENT" -ge 80 ]; then
COLOR=$GREEN
elif [ "$BATTERY_PERCENT" -ge 30 ]; then
COLOR=$YELLOW
else
COLOR=$RED
fi
echo "${BOLD}Battery: ${COLOR}$BATTERY_PERCENT% ($BATTERY_STATUS)${NC}"
if [ -n "$CHARGE_CYCLES" ]; then
echo "${BOLD}Charge Cycles: ${MAGENTA}$CHARGE_CYCLES${NC}"
fi
if [ "$WARNING_LEVEL" != "none" ]; then
echo "${BOLD}Warning Level: ${RED}$WARNING_LEVEL${NC}"
fi

View File

@@ -1,40 +0,0 @@
#! /bin/sh
YELLOW="\e[33m"
NC="\e[0m"
echo "\n${YELLOW}Downloading APT dependencies...${NC}\n"
sudo apt install build-essential git -y
sudo apt build-dep linux -y
echo "\n${YELLOW}Downloading kernel source...${NC}\n"
mkdir linux-parent && cd linux-parent || exit 1
git clone --depth 1 https://github.com/torvalds/linux
cd linux || exit 1
cp /boot/config-"$(uname -r)" .config # Copy current kernel config
make nconfig # Edit the current kernel configuration
diff /boot/config-"$(uname -r)" .config # Check your changes
# Do not include debugging symbols. Alternatively, use `strip` to remove them. (these configs are working as of 6.14)
scripts/config --undefine GDB_SCRIPTS
scripts/config --undefine DEBUG_INFO
scripts/config --undefine DEBUG_INFO_SPLIT
scripts/config --undefine DEBUG_INFO_REDUCED
scripts/config --undefine DEBUG_INFO_COMPRESSED
scripts/config --set-val DEBUG_INFO_NONE y
scripts/config --set-val DEBUG_INFO_DWARF5 n
scripts/config --disable DEBUG_INFO_DWARF_TOOLCHAIN_DEFAULT
echo "\n${YELLOW}Compiling the kernel...${NC}\n"
make -j"$(nproc)" deb-pkg LOCALVERSION=-custom
echo "\n${YELLOW}Installing the generated dpkg packages...${NC}\n"
sudo dpkg -i ../linux-headers*-custom*.deb
sudo dpkg -i ../linux-image*-custom*.deb
echo "\n${YELLOW}Cleaning up...${NC}\n"
cd ../..
rm -rf linux-parent
dpkg --list | grep linux-image

View File

@@ -10,46 +10,46 @@ BOLD="\e[1m"
NC="\e[0m"
# User and host info
echo "${BOLD}${MAGENTA}${USER}@$(hostname)${NC}"
echo "---------"
printf "%b\n" "${BOLD}${MAGENTA}${USER}@$(hostname)${NC}"
printf "%b\n" "---------"
# OS and architecture
OS=$(grep '^PRETTY_NAME=' /etc/os-release | cut -d= -f2 | tr -d '"')
ARCH=$(uname -m)
echo "${CYAN}OS:${NC} $OS $ARCH"
printf "%b\n" "${CYAN}OS:${NC} $OS $ARCH"
# Host Model
HOST_MODEL=$(cat /sys/class/dmi/id/product_name 2>/dev/null)
HOST_VERSION=$(cat /sys/class/dmi/id/product_version 2>/dev/null)
echo "${CYAN}Host:${NC} ${HOST_VERSION} (${HOST_MODEL})"
printf "%b\n" "${CYAN}Host:${NC} ${HOST_VERSION} (${HOST_MODEL})"
# Kernel version
echo "${CYAN}Kernel:${NC} Linux $(uname -r)"
printf "%b\n" "${CYAN}Kernel:${NC} Linux $(uname -r)"
# Uptime
UPTIME=$(uptime -p | sed 's/up //')
echo "${CYAN}Uptime:${NC} $UPTIME"
printf "%b\n" "${CYAN}Uptime:${NC} $UPTIME"
# Package counts: dpkg and flatpak
PKG_COUNT=$(dpkg-query -f '${binary:Package}\n' -W 2>/dev/null | wc -l)
FLAT_COUNT=$(flatpak list 2>/dev/null | wc -l)
echo "${CYAN}Packages:${NC} ${PKG_COUNT} (dpkg), ${FLAT_COUNT} (flatpak)"
printf "%b\n" "${CYAN}Packages:${NC} ${PKG_COUNT} (dpkg), ${FLAT_COUNT} (flatpak)"
# Shell and version
BASH_VER=$(bash --version | head -n1 | awk '{print $4}' | cut -d'(' -f1)
echo "${CYAN}Shell:${NC} bash ${BASH_VER}"
printf "%b\n" "${CYAN}Shell:${NC} bash ${BASH_VER}"
# Desktop Environment
DE=${XDG_CURRENT_DESKTOP:-"Unknown"}
echo "${CYAN}DE:${NC} $DE"
printf "%b\n" "${CYAN}DE:${NC} $DE"
# CPU model from /proc/cpuinfo
CPU=$(awk -F: '/model name/ {print $2; exit}' /proc/cpuinfo | sed 's/^[ \t]*//')
echo "${CYAN}CPU:${NC} $CPU"
printf "%b\n" "${CYAN}CPU:${NC} $CPU"
# GPU info
GPU=$(lspci | grep -i 'vga\|3d' | head -n1 | cut -d: -f3 | sed 's/^[ \t]*//')
echo "${CYAN}GPU:${NC} $GPU"
printf "%b\n" "${CYAN}GPU:${NC} $GPU"
# Memory usage
mem_info=$(free | awk '/Mem:/ {print $2, $3}')
@@ -68,7 +68,7 @@ fi
mem_total=$(free -h | awk '/Mem:/ {print $2}')
mem_used=$(free -h | awk '/Mem:/ {print $3}')
echo "${CYAN}Memory:${NC} ${mem_used} / ${mem_total} (${percent_color}${percent}%${NC})"
printf "%b\n" "${CYAN}Memory:${NC} ${mem_used} / ${mem_total} (${percent_color}${percent}%${NC})"
# Swap usage
swap_used=$(free -h | awk '/Swap/ {print $3}')
@@ -83,7 +83,7 @@ else
swap_perc_color=$RED
fi
echo "${CYAN}Swap:${NC} ${swap_used} / ${swap_total} (${swap_perc_color}${swap_perc}%${NC})"
printf "%b\n" "${CYAN}Swap:${NC} ${swap_used} / ${swap_total} (${swap_perc_color}${swap_perc}%${NC})"
# Root disk usage
root_line=$(df -h / | awk 'NR==2')
@@ -97,7 +97,7 @@ elif [ "$root_percent" -le 80 ]; then
else
root_color=$RED
fi
echo "${CYAN}Disk (/):${NC} ${root_used} / ${root_total} (${root_color}${root_percent}%${NC})"
printf "%b\n" "${CYAN}Disk (/):${NC} ${root_used} / ${root_total} (${root_color}${root_percent}%${NC})"
# /home disk usage
home_line=$(df -h /home 2>/dev/null | awk 'NR==2')
@@ -112,7 +112,7 @@ if [ -n "$home_line" ]; then
else
home_color=$RED
fi
echo "${CYAN}Disk (/home):${NC} ${home_used} / ${home_total} (${home_color}${home_percent}%${NC})"
printf "%b\n" "${CYAN}Disk (/home):${NC} ${home_used} / ${home_total} (${home_color}${home_percent}%${NC})"
fi
# Determine the primary network interface used for internet access
@@ -120,11 +120,11 @@ PRIMARY_IFACE=$(ip route get 8.8.8.8 2>/dev/null | awk '{print $5; exit}')
if [ -n "$PRIMARY_IFACE" ]; then
LOCAL_IP=$(ip addr show "$PRIMARY_IFACE" | awk '/inet / {print $2}' | cut -d'/' -f1)
echo "${CYAN}Local IP ($PRIMARY_IFACE):${NC} ${LOCAL_IP}"
printf "%b\n" "${CYAN}Local IP ($PRIMARY_IFACE):${NC} ${LOCAL_IP}"
else
echo "${RED}Local IP:${NC} Unable to determine primary network interface."
printf "%b\n" "${RED}Local IP:${NC} Unable to determine primary network interface."
fi
# Current locale setting
LOCALE=$(locale | awk -F= '/^LANG=/{print $2; exit}')
echo "${CYAN}Locale:${NC} $LOCALE"
printf "%b\n" "${CYAN}Locale:${NC} $LOCALE"

View File

@@ -1,27 +0,0 @@
#!/bin/sh
RED="\e[31m"
GREEN="\e[32m"
YELLOW="\e[33m"
NC="\e[0m"
mem_info=$(free | awk '/Mem:/ {print $2, $3}')
set -- $mem_info
total=$1
used=$2
percent=$(awk "BEGIN {printf \"%.0f\", ($used/$total)*100}")
mem_total=$(free -h | awk '/Mem:/ {print $2}')
mem_used=$(free -h | awk '/Mem:/ {print $3}')
if [ -t 1 ]; then
if [ "$percent" -le 60 ]; then
percent_color=$GREEN
elif [ "$percent" -le 80 ]; then
percent_color=$YELLOW
else
percent_color=$RED
fi
echo " ${mem_used} / ${mem_total} (${percent_color}${percent}%${NC})"
else
echo "${mem_used} ${mem_total} ${percent}"
fi

View File

@@ -1,75 +0,0 @@
#! /bin/sh
RED="\e[31m"
GREEN="\e[32m"
YELLOW="\e[33m"
CYAN="\e[36m"
NC="\e[0m"
trap "echo '${CYAN}System Monitor interrupted.${NC}'; exit 1" INT TERM
echo
echo
echo
# Cache in tmpfs to improve speed and reduce SSD load
cache=/tmp/cpu-script-cache
rm /tmp/cpu-script-cache 2>/dev/null
while true; do
# CPU
cpu_stats=$(awk '/^cpu / {print $2 + $3 + $4 + $5, $5}' /proc/stat)
if [ ! -f "$cache" ]; then
echo "$cpu_stats" >"$cache"
cpu_color=$CYAN
usage="--"
else
prev_stats=$(cat "$cache")
total=$(echo "$prev_stats" | awk '{print $1}')
prev_idle=$(echo "$prev_stats" | awk '{print $2}')
curr_total=$(echo "$cpu_stats" | awk '{print $1}')
curr_idle=$(echo "$cpu_stats" | awk '{print $2}')
total_diff=$((curr_total - total))
idle_diff=$((curr_idle - prev_idle))
if [ "$total_diff" -eq 0 ]; then
usage=0 # Avoid division by zero
else
usage=$((100 * (total_diff - idle_diff) / total_diff))
fi
if [ "$usage" -lt 50 ]; then
cpu_color=$GREEN
elif [ "$usage" -lt 70 ]; then
cpu_color=$YELLOW
else
cpu_color=$RED
fi
fi
# MEMORY
mem_info=$(free | awk '/Mem:/ {print $2, $3}')
set -- $mem_info
total=$1
used=$2
percent=$(awk "BEGIN {printf \"%.0f\", ($used/$total)*100}")
mem_total=$(free -h | awk '/Mem:/ {print $2}')
mem_used=$(free -h | awk '/Mem:/ {print $3}')
if [ "$percent" -le 60 ]; then
mem_color=$GREEN
elif [ "$percent" -le 80 ]; then
mem_color=$YELLOW
else
mem_color=$RED
fi
printf "\033[4A"
echo "============================="
echo " ${cpu_color}${usage}%${NC} "
echo " ${mem_used} / ${mem_total} (${mem_color}${percent}%${NC}) "
echo "============================="
echo "$cpu_stats" >"$cache"
sleep 2
done

View File

@@ -1,13 +0,0 @@
#!/bin/sh
# Wifi
if [ "$(cat /sys/class/net/w*/operstate 2>/dev/null)" = 'up' ]; then
wifiicon="$(awk '/^[[:space:]]*w/ { gsub(/[[:space:]]+/, " "); print " ", int($3 * 100 / 70) "% " }' /proc/net/wireless)"
elif [ "$(cat /sys/class/net/w*/operstate 2>/dev/null)" = 'down' ]; then
wifiicon=" "
fi
# Ethernet
[ "$(cat /sys/class/net/e*/operstate 2>/dev/null)" = 'up' ] && ethericon="󰛳 " || ethericon="󰅛 "
printf "%s%s\n" "$wifiicon" "$ethericon"

View File

@@ -1,215 +0,0 @@
#! /bin/bash
# Cross-distro package manager UI
RED="\e[31m"
GREEN="\e[32m"
YELLOW="\e[33m"
BLUE="\e[34m"
MAGENTA="\e[35m"
CYAN="\e[36m"
GRAY="\e[90m"
BOLD="\e[1m"
FAINT="\e[2m"
ITALIC="\e[3m"
UNDERLINE="\e[4m"
NC="\e[0m"
pcheck() {
local pms=()
if command -v nix >/dev/null 2>&1; then
pms+=("nix")
fi
if command -v brew >/dev/null 2>&1; then
pms+=("brew")
fi
if command -v apt >/dev/null 2>&1; then
pms+=("apt")
elif command -v pacman >/dev/null 2>&1; then
if command -v paru >/dev/null 2>&1; then
pms+=("paru")
fi
pms+=("pacman")
elif command -v dnf >/dev/null 2>&1; then
pms+=("dnf")
fi
if command -v flatpak >/dev/null 2>&1; then
pms+=("flatpak")
fi
echo "${pms[@]}"
}
p() (
trap "echo -e '\n${RED}p interrupted.${NC}'; exit 1" SIGINT SIGTERM
packageManagers=($(pcheck))
updateP() {
if [[ ${packageManagers[@]} =~ "flatpak" ]]; then
printf "%b\n" "${YELLOW}Updating flatpak...${NC}"
flatpak update
flatpak uninstall --unused --delete-data
fi
if [[ ${packageManagers[@]} =~ "nix" ]]; then
printf "%b\n" "${YELLOW}Updating nix...${NC}"
nix-channel --update
nix-collect-garbage --delete-older-than 7d &>/dev/null
if command -v nixos-rebuild >/dev/null 2>&1; then
sudo nix-channel --update
printf "${YELLOW}Rebuilding NixOS...${NC}\n"
sudo nixos-rebuild switch &>/tmp/nixos_rebuild.log || (
cat /tmp/nixos_rebuild.log | grep --color error && false
)
fi
fi
if [[ ${packageManagers[@]} =~ "brew" ]]; then
printf "%b\n" "${YELLOW}Updating brew...${NC}"
brew update
brew doctor
brew upgrade
fi
if [[ ${packageManagers[@]} =~ "apt" ]]; then
printf "%b\n" "${YELLOW}Updating apt...${NC}"
sudo apt update
sudo apt upgrade
sudo apt dist-upgrade
sudo apt autoremove
sudo apt autoclean
elif [[ ${packageManagers[@]} =~ "pacman" ]]; then
printf "%b\n" "${YELLOW}Updating pacman...${NC}"
sudo sed -i 's/^#ParallelDownloads/ParallelDownloads/' /etc/pacman.conf
if [[ ${packageManagers[@]} =~ "paru" ]]; then
paru -Syu
else
sudo pacman -Syu
fi
sudo pacman -Rsn $(pacman -Qdtq)
if [ ! "$(command -v reflector)" ]; then
printf "%b\n" "${YELLOW}Selecting fastest pacman mirrors...${NC}"
sudo pacman -Sy --noconfirm reflector rsync curl
iso=$(curl -4 ifconfig.co/country-iso)
extra="FR"
sudo reflector -a 48 -c $iso -c $extra -f 5 -l 30 --verbose --sort rate --save /etc/pacman.d/mirrorlist
fi
if [ ! "$(command -v paccache)" ]; then
sudo pacman -Sy --noconfirm pacman-contrib
fi
paccache -rk1
elif [[ ${packageManagers[@]} =~ "dnf" ]]; then
printf "%b\n" "${YELLOW}Updating dnf...${NC}"
sudo dnf upgrade --refresh
sudo dnf autoremove
fi
}
installP() {
for pm in "${packageManagers[@]}"; do
printf "%b\n" "${YELLOW}Attempting ${pm} install...${NC}"
case "$pm" in
flatpak)
flatpak install "$1"
;;
paru)
paru -Sy "$1"
;;
apt)
sudo apt install "$1"
;;
pacman)
sudo pacman -Sy "$1"
;;
dnf)
sudo dnf install "$1"
;;
brew)
brew install "$1"
;;
*)
continue
;;
esac
if [[ $? == 0 ]]; then
return 0
fi
done
printf "%b\n" "${RED}ERROR: $1 not found.${NC}"
return 1
}
removeP() {
for pm in "${packageManagers[@]}"; do
printf "%b\n" "${YELLOW}Attempting ${pm} uninstall...${NC}"
case "$pm" in
flatpak)
flatpak uninstall "$1"
;;
brew)
brew uninstall "$1"
;;
apt)
sudo apt remove "$1"
;;
pacman)
sudo pacman -Rs "$1"
;;
paru)
paru -Rns "$1"
;;
dnf)
sudo dnf remove "$1"
;;
*)
continue
;;
esac
if [[ $? == 0 ]]; then
return 0
fi
done
printf "%b\n" "${RED}ERROR: $1 not found.${NC}"
return 1
}
shellP() {
if [[ ${packageManagers[@]} =~ "nix" ]]; then
printf "%b\n" "${YELLOW}Attempting to create nix shell...${NC}"
nix-shell -p $1
if [[ $? == 0 ]]; then
return 0
fi
fi
}
# If no parameter or u
printf "%b\n" "${CYAN}Detected package managers: ${MAGENTA}${packageManagers[*]}${NC}"
if [ -z $1 ] || [ $1 = "u" ]; then
updateP
return 0
elif [ $1 = "i" ]; then # If first parameter is i (install)
shift
for package in "$@"; do
installP $package
done
elif [ $1 = "r" ]; then # If first parameter is r (remove)
shift
for package in "$@"; do
removeP $package
done
elif [ $1 = "c" ]; then # If first parameter is c (check)
shift
for package in "$@"; do
checkP $package
done
elif [ $1 = "s" ]; then # If first parameter is s (shell)
shift
shellP $@
else
printf "%b\n" "${YELLOW}${UNDERLINE}[i] Usage:${NC}"
printf "%b\n" "p (u) ${FAINT}- update os${NC}"
printf "%b\n" "p i package ${FAINT}- install package${NC}"
printf "%b\n" "p r package ${FAINT}- remove package${NC}"
printf "%b\n" "p s packages ${FAINT}- launch a nix shell with the specified packages${NC}"
printf "%b\n" "${FAINT}Supported package managers: flatpak, nix, brew, apt, paru, pacman, dnf${NC}"
return 1
fi
)

View File

@@ -1,5 +0,0 @@
#!/bin/bash
paste <(cat /sys/class/thermal/thermal_zone*/type) <(cat /sys/class/thermal/thermal_zone*/temp) |
column -s "$(printf '\t')" -t |
sed 's/\(.\)..$/.\1°C/'

View File

@@ -1,32 +1,38 @@
#! /bin/sh
YELLOW="\e[33m"
GRAY="\e[90m"
NC="\e[0m"
printf "%b\n" "${YELLOW}[+]${NC} Updating repos..."
printf "%b" "${GRAY}"
sudo apt-get update
printf "%b" "${NC}"
if command -v paru >/dev/null 2>&1; then
printf "%b\n" "${YELLOW}[+]${NC} Updating Arch using paru..."
paru
printf "%b\n" "${YELLOW}[+]${NC} Removing orphaned dependencies..."
sudo pacman -Rsn $(pacman -Qdtq)
elif command -v pacman >/dev/null 2>&1; then
printf "%b\n" "${YELLOW}[+]${NC} Updating Arch..."
sudo pacman -Syu
printf "%b\n" "${YELLOW}[+]${NC} Removing orphaned dependencies..."
sudo pacman -Rsn $(pacman -Qdtq)
elif command -v apt >/dev/null 2>&1; then
printf "%b\n" "${YELLOW}[+]${NC} Updating repos..."
sudo apt-get update
printf "%b" "${NC}"
printf "%b\n" "${YELLOW}[+]${NC} Upgrading packages..."
printf "%b" "${GRAY}"
sudo apt-get full-upgrade
printf "%b" "${NC}"
printf "%b\n" "${YELLOW}[+]${NC} Upgrading packages..."
sudo apt-get full-upgrade
printf "%b" "${NC}"
printf "%b\n" "${YELLOW}[+]${NC} Removing orphaned dependencies..."
printf "%b" "${GRAY}"
sudo apt-get autoremove
printf "%b" "${NC}"
printf "%b\n" "${YELLOW}[+]${NC} Removing orphaned dependencies..."
sudo apt-get autoremove
printf "%b" "${NC}"
printf "%b\n" "${YELLOW}[+]${NC} Cleaning up..."
printf "%b" "${GRAY}"
sudo apt-get autoclean
printf "%b" "${NC}"
printf "%b\n" "${YELLOW}[+]${NC} Cleaning up..."
sudo apt-get autoclean
printf "%b" "${NC}"
fi
if command -v flatpak >/dev/null 2>&1; then
printf "%b\n" "${YELLOW}[+]${NC} Updating flatpak packages..."
printf "%b" "${GRAY}"
flatpak update
flatpak uninstall --unused --delete-data
printf "%b" "${NC}"

View File

@@ -1,28 +0,0 @@
#!/bin/sh
# Prints the current volume or  if muted.
vol="$(wpctl get-volume @DEFAULT_AUDIO_SINK@)"
# If muted, print  and exit.
[ "$vol" != "${vol%\[MUTED\]}" ] && echo " " && exit
vol="${vol#Volume: }"
split() {
# For ommiting the . without calling and external program.
IFS=$2
set -- $1
printf '%s' "$@"
}
vol="$(printf "%.0f" "$(split "$vol" ".")")"
case $1 in
$((vol >= 70))) icon=" " ;;
$((vol >= 30))) icon=" " ;;
$((vol >= 1))) icon=" " ;;
*) echo " " && exit ;;
esac
echo "$icon$vol%"