From 7dc5f79d8cbd7704600ff7cb9cdfd41d4bde4d91 Mon Sep 17 00:00:00 2001 From: Joanna Date: Sun, 8 Mar 2026 17:32:26 +0000 Subject: [PATCH] Fix for incorrect memory utilization, and various copilot suggestions. Removed code providing unreliable detection of the terminal application --- hyfetch/distros/distro_detector.py | 6 +++--- hyfetch/distros/qnx.py | 3 ++- neofetch | 10 +++++----- pyproject.toml | 3 ++- 4 files changed, 12 insertions(+), 10 deletions(-) diff --git a/hyfetch/distros/distro_detector.py b/hyfetch/distros/distro_detector.py index 7e93e786..c304ba8a 100644 --- a/hyfetch/distros/distro_detector.py +++ b/hyfetch/distros/distro_detector.py @@ -1124,9 +1124,9 @@ def detect(name: str) -> AsciiArt | None: from .q4os import q4os return q4os - if name.startswith('blackberry 10') or name.startswith('qnx'): - from .blackberry_10 import blackberry_10 - return blackberry_10 + if name.startswith('qnx') or name.startswith('blackberry 10'): + from .qnx import qnx + return qnx if name.startswith('qubes'): from .qubes import qubes diff --git a/hyfetch/distros/qnx.py b/hyfetch/distros/qnx.py index 2f7f6d50..2a7d88e6 100644 --- a/hyfetch/distros/qnx.py +++ b/hyfetch/distros/qnx.py @@ -2,7 +2,7 @@ from . import AsciiArt -q4os = AsciiArt(match=r'''"Blackberry 10"* | "QNX"*''', color='1', ascii=r""" +qnx = AsciiArt(match=r'''"QNX"* | "Blackberry 10"*''', color='1', ascii=r""" ${c1} .KMMMMMbo .KMMMMMbo aMMMMMMMMb aMMMMMMMMb ,KMMMMMMMMp ,KMMMMMMMMp @@ -18,3 +18,4 @@ AMMMMMMMP* AMMMMMMMP* .KMMMMMbo ,KMMMMMMMMp AMMMMMMMP* """) + \ No newline at end of file diff --git a/neofetch b/neofetch index e29a7b52..5360a3d6 100755 --- a/neofetch +++ b/neofetch @@ -1528,6 +1528,7 @@ get_distro() { QNX) distro=$(cat /pps/services/deviceproperties | awk -F'::' '$1 == "device_os" { print $2 }') distro="${distro} ($(cat /base/etc/os.version))" + ;; esac distro=${distro//Enterprise Server} @@ -1876,6 +1877,7 @@ get_model() { QNX) model=$(cat /pps/services/deviceproperties | awk -F'::' '/modelname/ {m=$2} /modelnumber/ {n=$2} END {print m" ("n")"}') + ;; esac # Remove dummy OEM info. @@ -3810,13 +3812,13 @@ get_memory() { mem_free="$(( $(showmem -f) * 1000 ))" mem_used="$(( $(showmem -u) * 1000 ))" mem_total="$(( $(showmem -t) * 1000 ))" - ;; "QNX") - mem_used="$(( $(pidin info | sed -n 's/.*FreeMem:\([0-9][0-9]*\)MB\/.*/\1/p') * 1024 ))" + mem_free="$(( $(pidin info | sed -n 's/.*FreeMem:\([0-9][0-9]*\)MB\/.*/\1/p') * 1024 ))" mem_total="$(( $(pidin info | sed -n 's|.*MB/||;s|MB Boot.*||p') * 1024 ))" mem_used="$((mem_total - mem_free))" + ;; esac @@ -4663,8 +4665,6 @@ get_term() { *) term="${TERM_PROGRAM/\.app}" ;; esac - [[ $os == QNX ]] && term="$(pidin session 2> /dev/null | awk 'NR==2 {n=split($NF, a, "/"); print a[n]}')" - # Most likely TosWin2 on FreeMiNT - quick check [[ "$TERM" == "tw52" || "$TERM" == "tw100" ]] && term="TosWin2" [[ "$SSH_CONNECTION" ]] && term="$SSH_TTY" @@ -13448,7 +13448,7 @@ ${c1}:##############. ${c2}:======: EOF ;; - "Blackberry 10"* | "QNX"*) + "QNX"* | "Blackberry 10"*) set_colors 1 read -rd '' ascii_data <<'EOF' ${c1} .KMMMMMbo .KMMMMMbo diff --git a/pyproject.toml b/pyproject.toml index c700d2a7..4a40e136 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -26,10 +26,11 @@ classifiers = [ dependencies = [ # Universal dependencies 'typing_extensions; python_version < "3.8"', - # Windows dependencies 'psutil ; platform_system=="Windows"', 'colorama>=0.4.6 ; platform_system=="Windows"', + "regex>=2024.4.16", + "hypy-utils>=1.0.29", ] [project.urls]