From 9500e8c0aa0f64ed231ba700c4eaac75e505312d Mon Sep 17 00:00:00 2001 From: Joanna Hartley Date: Tue, 7 Apr 2026 02:10:05 +0100 Subject: [PATCH] Add support for QNX/Blackberry 10 (#480) * Add support for QNX 8.x/Blackberry 10 * Maybe the real uptime was the friends we made along the way * Detect name of the terminal application * Re-run the list distros script * Fix for incorrect memory utilization, and various copilot suggestions. Removed code providing unreliable detection of the terminal application * Apply suggestion from @Copilot Ignore header lines for qpkg package manager Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Remove erroneous dependencies --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- hyfetch/distros/distro_detector.py | 4 ++ hyfetch/distros/qnx.py | 21 ++++++++ neofetch | 77 ++++++++++++++++++++++++++++-- 3 files changed, 99 insertions(+), 3 deletions(-) create mode 100644 hyfetch/distros/qnx.py diff --git a/hyfetch/distros/distro_detector.py b/hyfetch/distros/distro_detector.py index 9608905c..c304ba8a 100644 --- a/hyfetch/distros/distro_detector.py +++ b/hyfetch/distros/distro_detector.py @@ -1124,6 +1124,10 @@ def detect(name: str) -> AsciiArt | None: from .q4os import q4os return q4os + if name.startswith('qnx') or name.startswith('blackberry 10'): + from .qnx import qnx + return qnx + if name.startswith('qubes'): from .qubes import qubes return qubes diff --git a/hyfetch/distros/qnx.py b/hyfetch/distros/qnx.py new file mode 100644 index 00000000..2a7d88e6 --- /dev/null +++ b/hyfetch/distros/qnx.py @@ -0,0 +1,21 @@ +# This file is automatically generated. Please do not modify. + +from . import AsciiArt + +qnx = AsciiArt(match=r'''"QNX"* | "Blackberry 10"*''', color='1', ascii=r""" +${c1} .KMMMMMbo .KMMMMMbo + aMMMMMMMMb aMMMMMMMMb + ,KMMMMMMMMp ,KMMMMMMMMp + AMMMMMMMP* AMMMMMMMP* ,KMMMMMbo + aMMMMMMMMb + .KMMMMMbo .KMMMMMbo .KMMMMMMMMp + aMMMMMMMMb aMMMMMMMMb AMMMMMMMP* +,KMMMMMMMMp .KMMMMMMMMp +AMMMMMMMP* AMMMMMMMP* .KMMMMMbo + aMMMMMMMMb + .KMMMMMbo ,KMMMMMMMMp + aMMMMMMMMb AMMMMMMMP* + ,KMMMMMMMMp + AMMMMMMMP* +""") + \ No newline at end of file diff --git a/neofetch b/neofetch index 0a685e79..dc970899 100755 --- a/neofetch +++ b/neofetch @@ -891,7 +891,7 @@ image_source="auto" # Tumbleweed, openSUSE Tumbleweed-Slowroll, OPNsense, Oracle, orchid, OS Elbrus, PacBSD, Panwah, # Parabola, parch, Pardus, Parrot, Parsix, PCBSD, PCLinuxOS, pearOS, Pengwin, Pentoo, Peppermint, # Peropesis, phyOS, PikaOS, Pisi, PNM Linux, Pop!_OS, Porteus, PostMarketOS, Profelis SambaBOX, -# Proxmox, PuffOS, Puppy, PureOS, Q4OS, Qubes, Qubyt, Quibian, Radix, Raspbian, ravynOS, Reborn OS, +# Proxmox, PuffOS, Puppy, PureOS, Q4OS, QNX, Qubes, Qubyt, Quibian, Radix, Raspbian, ravynOS, Reborn OS, # Red Star, Redcore, Redhat, Refracted Devuan, Regata, Regolith, RhaymOS, Rhino Linux, rocky, Rosa, # Sabayon, sabotage, Sailfish, SalentOS, Salient OS, Salix, Sasanqua, Scientific, secureblue, semc, # Septor, Serene, SharkLinux, ShastraOS, Siduction, SkiffOS, Slackel, Slackware, SliTaz, SmartOS, @@ -1046,6 +1046,7 @@ get_os() { Interix) os=Interix ;; Ironclad) os=Ironclad;; OSF1) os=digitalUNIX ;; + QNX) os=QNX ;; Linux|GNU*) os=Linux @@ -1523,6 +1524,11 @@ get_distro() { digitalUNIX) distro="digital UNIX ${kernel_version}" ;; + + 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} @@ -1531,7 +1537,7 @@ get_distro() { # Get OS architecture. case $os in - Solaris|illumos|AIX|Haiku|IRIX|FreeMiNT|BSD|digitalUNIX) + Solaris|illumos|AIX|Haiku|IRIX|FreeMiNT|BSD|digitalUNIX|QNX) machine_arch=$(uname -p) ;; @@ -1868,6 +1874,10 @@ get_model() { model="${model/Manufacturer}" model="${model/Model}" ;; + + QNX) + model=$(cat /pps/services/deviceproperties | awk -F'::' '/modelname/ {m=$2} /modelnumber/ {n=$2} END {print m" ("n")"}') + ;; esac # Remove dummy OEM info. @@ -2022,6 +2032,13 @@ get_uptime() { Haiku) s=$(($(system_time) / 1000000)) ;; + + QNX) + boot=$(date -d "$(pidin info | sed -n 's/.*BootTime:\([^$]*\)/\1/p')" +%s) + now=$(date +%s) + + s=$((now - boot)) + ;; esac d="$((s / 60 / 60 / 24)) days" @@ -2402,6 +2419,11 @@ get_packages() { manager=swpkg pkgs_h=3 tot versions -b && ((packages-=3)) ;; + + QNX) + has qpkg && pkgs_h=4 tot qpkg list && ((packages-=4)) + has apk && tot apk info + ;; esac # Count the total number of packages. @@ -3358,6 +3380,17 @@ END cores="$(/dev/fs/C/Windows/System32/wbem/WMIC.exe cpu get NumberOfCores)" cores="${cores/NumberOfCores}" ;; + + "QNX") + # Get CPU name + cpu="$(uname -m | cut -d '_' -f 1)" + + # Get CPU speed + speed="$(pidin info | grep -o '[0-9]\+MHz' | head -1 | tr -d 'MHz')" + + # Get CPU cores + cores="$(pidin info | grep -c '^Processor[0-9]')" + ;; esac # Remove un-needed patterns from cpu output. @@ -3779,6 +3812,14 @@ get_memory() { mem_free="$(( $(showmem -f) * 1000 ))" mem_used="$(( $(showmem -u) * 1000 ))" mem_total="$(( $(showmem -t) * 1000 ))" + ;; + + "QNX") + 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 [[ "$memory_percent" == "on" ]] && ((mem_perc=mem_used * 100 / mem_total)) @@ -4211,6 +4252,10 @@ get_resolution() { # Need to block X11 queries ;; + "QNX") + resolution=$(cat /pps/services/deviceproperties | awk -F'::' '$1 == "screen_res" { print $2 }') + ;; + *) if type -p xrandr >/dev/null && [[ $DISPLAY && -z $WAYLAND_DISPLAY ]]; then case $refresh_rate in @@ -5245,6 +5290,12 @@ get_battery() { battery0now="$(awk -F '[^0-9]*' 'NR==5 {print $4}' /dev/power/acpi_battery/0)" battery="$((battery0full * 100 / battery0now))%" ;; + + "QNX") + battery="$(cat /pps/system/BattMgr/status | sed -n 's/.*"StateOfCharge":\([0-9]*\).*/\1/p')%" + state="$(cat /pps/system/BattMgr/status | sed -n 's/.*"ChargerStatus":"\([^"]*\)".*/\1/p' )" + [[ "$state" == "CHARGING" ]] && battery_state="charging" + ;; esac [[ "$battery_state" ]] && battery+=" Charging" @@ -6674,7 +6725,7 @@ ASCII: OS Elbrus, PacBSD, Panwah, Parabola, parch, Pardus, Parrot, Parsix, PCBSD, PCLinuxOS, pearOS, Pengwin, Pentoo, Peppermint, Peropesis, phyOS, PikaOS, Pisi, PNM Linux, Pop!_OS, Porteus, PostMarketOS, - Profelis SambaBOX, Proxmox, PuffOS, Puppy, PureOS, Q4OS, Qubes, + Profelis SambaBOX, Proxmox, PuffOS, Puppy, PureOS, Q4OS, QNX, Qubes, Qubyt, Quibian, Radix, Raspbian, ravynOS, Reborn OS, Red Star, Redcore, Redhat, Refracted Devuan, Regata, Regolith, RhaymOS, Rhino Linux, rocky, Rosa, Sabayon, sabotage, Sailfish, SalentOS, Salient @@ -13397,6 +13448,26 @@ ${c1}:##############. ${c2}:======: EOF ;; + "QNX"* | "Blackberry 10"*) + set_colors 1 + read -rd '' ascii_data <<'EOF' +${c1} .KMMMMMbo .KMMMMMbo + aMMMMMMMMb aMMMMMMMMb + ,KMMMMMMMMp ,KMMMMMMMMp + AMMMMMMMP* AMMMMMMMP* ,KMMMMMbo + aMMMMMMMMb + .KMMMMMbo .KMMMMMbo .KMMMMMMMMp + aMMMMMMMMb aMMMMMMMMb AMMMMMMMP* +,KMMMMMMMMp .KMMMMMMMMp +AMMMMMMMP* AMMMMMMMP* .KMMMMMbo + aMMMMMMMMb + .KMMMMMbo ,KMMMMMMMMp + aMMMMMMMMb AMMMMMMMP* + ,KMMMMMMMMp + AMMMMMMMP* +EOF + ;; + "Qubes"*) set_colors 4 5 7 6 read -rd '' ascii_data <<'EOF'