CPU, GPU and memory information have been converted to Golang functions

This commit is contained in:
2024-05-14 10:03:18 +03:00
parent 1fc9a9ea79
commit a29a8f1dd9
6 changed files with 268 additions and 139 deletions
+4 -4
View File
@@ -5,11 +5,11 @@ echo -e "${C3}Hostname: ${C4}$(cat /etc/hostname)"
echo -e "${C3}Kernel: ${C4}$(uname -s) $(uname -r)"
echo -e "${C3}Packages: ${C4}$(get_packages)"
echo -e "${C3}Shell: ${C4}$(get_shell)"
echo -e "${C3}CPU: ${C4}$(get_cpu_name) ($(nproc) threads)"
if command_exists lshw; then
echo -e "${C3}GPU: ${C4}$(lshw -class display 2> /dev/null | grep 'product' | cut -d":" -f2 | xargs)"
echo -e "${C3}CPU: ${C4}${CPU_MODEL} (${CPU_THREADS} threads)"
if [ ! -z "$GPU_MODEL" ]; then
echo -e "${C3}GPU: ${C4}${GPU_MODEL})"
fi
echo -e "${C3}Memory: ${C4}$(get_used_mem) MiB / $(get_total_mem) MiB"
echo -e "${C3}Memory: ${C4}${MEM_USED} MiB / ${MEM_TOTAL} MiB"
if xhost >& /dev/null ; then
if get_de_wm &> /dev/null; then
echo -e "${C3}DE/WM: ${C4}$(get_de_wm)"
-16
View File
@@ -34,22 +34,6 @@ get_shell() {
esac
}
get_cpu_name() {
grep -m1 "model name" /proc/cpuinfo | cut -d: -f2 | xargs
}
get_total_mem() {
free --mebi -t | grep 'Total' | tr -s ' ' | cut -d" " -f2
}
get_free_mem() {
free --mebi -t | grep 'Total' | tr -s ' ' | cut -d" " -f4
}
get_used_mem() {
free --mebi -t | grep 'Total' | tr -s ' ' | cut -d" " -f3
}
get_de_wm() {
if ps -e | grep "plasmashell" &> /dev/null ; then
echo "KDE Plasma $(plasmashell --version | awk '{print $2}')"