wick3dr0se / sysfetch Goto Github PK
View Code? Open in Web Editor NEWA super tiny system information fetch script written in BASH
License: GNU General Public License v3.0
A super tiny system information fetch script written in BASH
License: GNU General Public License v3.0
Generally provided by uptime (though could use a lot of formatting to match the rest of the output here).
Not used by a lot of desktop users, but very useful for embedded systems, routers, and servers.
Most useful if paired with a core count on the CPU somewhere.
This would include smaller systems that are busybox based, for example.
Proposed fix: test for support of --pretty, present an answer based on plain uptime formatting if flag not supported.
(This is one I might tackle if I get a chance this week, since I have lots of busybox systems to test on.)
Full error:
/usr/share/sysfetch/sys/linux.sh: line 155: 23.4141: syntax error: invalid arithmetic operator (error token is ".4141")
cur_swap=$(sed -n '2p' /proc/swaps | awk '{print $4 / 1024}')
cur_swap2=$(sed -n '3p' /proc/swaps | awk '{print $4 / 1024}')
is $cur_swap *.* && cur_swap=${cur_swap::-3}
cur_swap=$((cur_swap + cur_swap2))
^ Something seems to be going wrong with the addition at the end of the script here. As far as I know, bash itself can't do floating point arithmetic, so you'd either have to round these values to integers, or pipe it to something like bc
This may be a tricky one to fix, as the /proc/cpuinfo
output is very different from Intel/AMD. Current output of fetch for this line:
cpu ~ ash: GenuineIntel: unknown operand
Output of /proc/cpuinfo for this board:
root@Ron:~/bin# cat /proc/cpuinfo
processor : 0
BogoMIPS : 38.40
Features : fp asimd evtstrm crc32 cpuid
CPU implementer : 0x41
CPU architecture: 8
CPU variant : 0x0
CPU part : 0xd03
CPU revision : 4
processor : 1
BogoMIPS : 38.40
Features : fp asimd evtstrm crc32 cpuid
CPU implementer : 0x41
CPU architecture: 8
CPU variant : 0x0
CPU part : 0xd03
CPU revision : 4
processor : 2
BogoMIPS : 38.40
Features : fp asimd evtstrm crc32 cpuid
CPU implementer : 0x41
CPU architecture: 8
CPU variant : 0x0
CPU part : 0xd03
CPU revision : 4
processor : 3
BogoMIPS : 38.40
Features : fp asimd evtstrm crc32 cpuid
CPU implementer : 0x41
CPU architecture: 8
CPU variant : 0x0
CPU part : 0xd03
CPU revision : 4
Hardware : BCM2835
Revision : a02082
Serial : 00000000e85bd3ff
Model : Raspberry Pi 3 Model B Rev 1.2
With no vendor_id to sort from, there's almost no commonality to work with here. For comparison, I'll also include cpuinfo for two other embedded systems I've been working with a lot.
RB750Gr3 (first core only, nothing varies on the other three):
system type : MediaTek MT7621 ver:1 eco:3
machine : MikroTik RouterBOARD 750Gr3
processor : 0
cpu model : MIPS 1004Kc V2.15
BogoMIPS : 584.90
wait instruction : yes
microsecond timers : yes
tlb_entries : 32
extra interrupt vector : yes
hardware watchpoint : yes, count: 4, address/irw mask: [0x0ffc, 0x0ffc, 0x0ffb, 0x0ffb]
isa : mips1 mips2 mips32r1 mips32r2
ASEs implemented : mips16 dsp mt
Options implemented : tlb 4kex 4k_cache prefetch mcheck ejtag llsc pindexed_dcache userlocal vint perf_cntr_intr_bit cdmm nan_legacy nan_2008 perf
shadow register sets : 1
kscratch registers : 0
package : 0
core : 0
VPE : 0
VCED exceptions : not available
VCEI exceptions : not available
MT300Nv2 (single core and very low energy use):
system type : MediaTek MT7628AN ver:1 eco:2
machine : GL-MT300N-V2
processor : 0
cpu model : MIPS 24KEc V5.5
BogoMIPS : 380.92
wait instruction : yes
microsecond timers : yes
tlb_entries : 32
extra interrupt vector : yes
hardware watchpoint : yes, count: 4, address/irw mask: [0x0ffc, 0x0ffc, 0x0ffb, 0x0ffb]
isa : mips1 mips2 mips32r1 mips32r2
ASEs implemented : mips16 dsp
Options implemented : tlb 4kex 4k_cache prefetch mcheck ejtag llsc pindexed_dcache userlocal vint perf_cntr_intr_bit nan_legacy nan_2008 perf
shadow register sets : 1
kscratch registers : 0
package : 0
core : 0
VCED exceptions : not available
VCEI exceptions : not available
Not a lot of commonality. For the non-x86 boards, the most common thing I'm seeing that might be a useful alternative is the "system type" field, but the Pi doesn't even have that.
This issue's definitely a bit of an open-ended question for what to do for non-desktop systems - or how into the weeds you even want to get trying to support them. A fetch script this light has potential to be really useful on these little embedded systems, but there are just so many edge cases!
Caused by this line, which strips the last character off a disk path if it's a number:
disk_path=${disk_path%[0-9]}
Which works fine for paths like /dev/sda1
, but not if you have 10 or more partitions (because /dev/sda10
would be cut to /dev/sda1
). Or in my case, if you're using an NVME drive, because it cuts /dev/nvme0n1p1
to /dev/nvmen0n1p
instead of /dev/nvmen0n1
Β
To be honest, I don't really know a good way to fix this without adding a dependency like lshw
. As far as I know, there's no easy way to differentiate between a device file and a partition file?
One dumb solution I just thought of was using lsblk, and filtering the block devices that are the "root" of their tree:
lsblk -ni | grep '^\w' | awk '{print $1}'
Attempt to measure swap on ash produces the following output:
-ash: ./fetch.sh: pstree: not found
This is the output on Qemu...
./sys/linux.sh: line 145: /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq: No such file or directory
./sys/linux.sh: line 150: /sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq: No such file or directory
./sys/linux.sh: line 173: /sys/devices/virtual/dmi/id/board_vendor: No such file or directory
./sys/linux.sh: line 174: /sys/devices/virtual/dmi/id/board_name: No such file or directory
./sys/linux.sh: line 209: /1024: syntax error: operand expected (error token is "/1024")
paul@X
uptime ~ 405 days, 4 hrs, 23 mins
kernel ~ 4.19.0-16-amd64 arch ~ x86_64
distro ~ VERSION_CODENAME=buster
term ~ paul shell ~ bash
pkgs ~ 459
cpu ~ Intel Xeon (Skylake, IBRS)
gpu ~ 1111 (rev 02)
mobo ~
disk ~ 18G/19G 100% QEMU_HARDDISK
ram ~ 873/1947M swap ~ /M
Ascii art for the following would be nice:
Latest version (666fa88) now tells me I'm using Weston, but I'm not. I'm using XFCE. Some commit must've broken it...
job@job-pc
kernel ~ 5.10.0-9-amd64
uptime ~ 0 weeks, 23 hours, 42 minutes
os ~ Devuan GNU/Linux 4 (chimaera) arch ~ x86_64
de/wm ~ Weston theme ~ Breeze
cpu ~ Intel Core i3-6006U [email protected]
gpu ~ Intel Skylake GT2 HD Graphics 520 (rev 07)
pkgs ~ 4317
ram ~ 3830 MiB swap ~ 5119MiB 12287MiB
term ~ utmp shell ~ bash
Might be caused by 433c555, as there's no /usr/share/xsession
in my system.
Ubuntu 20.04 under WSL2, script throws an error when trying to find CPU frequency:
cpu ~ Intel(R) Core(TM) i7-1065G7 CPU @ 1.30GHzsort: cannot read: '/sys/devices/system/cpu/cpu*/cpufreq/scaling_cur_freq': No such file or directory
GHz
Looks like the required files don't exist:
~$ ls -l /sys/devices/system/cpu/cpu0/
total 0
drwxr-xr-x 6 root root 0 Nov 22 11:28 cache
lrwxrwxrwx 1 root root 0 Nov 22 11:28 driver -> ../../../../bus/cpu/drivers/processor
lrwxrwxrwx 1 root root 0 Nov 22 11:28 firmware_node -> ../../../LNXSYSTM:00/ACPI0007:00
drwxr-xr-x 2 root root 0 Nov 22 11:28 hotplug
lrwxrwxrwx 1 root root 0 Nov 22 11:28 subsystem -> ../../../../bus/cpu
drwxr-xr-x 2 root root 0 Nov 22 11:28 topology
-rw-r--r-- 1 root root 4096 Nov 22 11:28 uevent
This is run via Termux
There are errors about /etc/os-release
, /etc/lib/os-release
(both for getting OS name probably), /etc/issue
, lspci
(likely related to #7), /sys/devices/virtual/dmi/id/board_vendor
and /sys/devices/virtual/dmi/id/board_name
(both for getting mobo).
Add support for Mac and Windows if this is in plan.
recent ARCH installation with gnome
Theme produces error message
[email protected]
kernel ~ 5.15.2-arch1-1
uptime ~ 1 day, 3 hours, 22 minutes
os ~ Arch Linux arch ~ x86_64
de/wm ~ GNOME-Classic;GNOME;GNOMEGNOME theme ~ grep: /home/tpe/.config/gtk-3.0/settings.ini: No such file or directory
cpu ~ Intel(R) Core(TM) i7-2670QM CPU @ [email protected]
gpu ~ Intel Corporation 2nd Generation Core Processor Family Integrated Graphics Controller (rev 09)
GF119M Quadro NVS 4200M (rev a1)
pkgs ~ 1016
ram ~ 7833 MiB swap ~ 8191 MiB
term ~ bash shell ~ bash
Almost the same as #4. I can confirm that #11 fixed #4, but some commit after that seemed to have broken it again.
Output:
job@job-pc
kernel ~ 5.10.0-9-amd64
uptime ~ 44 minutes
os ~ Devuan GNU/Linux 4 (chimaera) arch ~ x86_64
de/wm ~ XFCE theme ~ Breeze
cpu ~ Intel Core i3-6006U [email protected]
gpu ~ Intel Skylake GT2 HD Graphics 520 (rev 07)
pkgs ~ 4317
ram ~ 3830 MiB./fetch.sh: line 141: let: swap_mb = 5242876
12582908 / 1024: syntax error in expression (error token is "12582908 / 1024")
swap ~ 5242876 MiB
term ~ utmp shell ~ bash
EDIT: Seems to have been caused by df4d0c2.
Possibly applies to other ARM-based systems as well.
Full output of script on a RPi4 running Ubuntu 20.04:
indrek@rpi4
kernel ~ 5.4.0-1046-raspi
uptime ~ 3 days, 23 hours, 41 minutes
os ~ Ubuntu 20.04.3 LTS arch ~ aarch64
cpu ~ @1.200 GHz
gpu ~ pkgs ~ 525
ram ~ 3793 MiB./fetch.sh: line 88: let: swap_mb = / 1024: syntax error: operand expected (error token is "/ 1024")
swap ~ MiB
term ~ sshd shell ~ bash
(Swap-related error mentioned under #4.)
No CPU name in proc/cpuinfo
, only the SoC (BCM2835) is listed:
~$ cat /proc/cpuinfo
processor : 0
BogoMIPS : 108.00
Features : fp asimd evtstrm crc32 cpuid
CPU implementer : 0x41
CPU architecture: 8
CPU variant : 0x0
CPU part : 0xd08
CPU revision : 3
processor : 1
BogoMIPS : 108.00
Features : fp asimd evtstrm crc32 cpuid
CPU implementer : 0x41
CPU architecture: 8
CPU variant : 0x0
CPU part : 0xd08
CPU revision : 3
processor : 2
BogoMIPS : 108.00
Features : fp asimd evtstrm crc32 cpuid
CPU implementer : 0x41
CPU architecture: 8
CPU variant : 0x0
CPU part : 0xd08
CPU revision : 3
processor : 3
BogoMIPS : 108.00
Features : fp asimd evtstrm crc32 cpuid
CPU implementer : 0x41
CPU architecture: 8
CPU variant : 0x0
CPU part : 0xd08
CPU revision : 3
Hardware : BCM2835
Revision : c03114
Serial : 1000000022bfb586
Model : Raspberry Pi 4 Model B Rev 1.4
Maybe lscpu
could be used as a fallback?
~$ lscpu
Architecture: aarch64
CPU op-mode(s): 32-bit, 64-bit
Byte Order: Little Endian
CPU(s): 4
On-line CPU(s) list: 0-3
Thread(s) per core: 1
Core(s) per socket: 4
Socket(s): 1
Vendor ID: ARM
Model: 3
Model name: Cortex-A72
Stepping: r0p3
CPU max MHz: 1500.0000
CPU min MHz: 600.0000
BogoMIPS: 108.00
So With the current build, and my computer I'm using that has an extended uptime, I'm getting a strange output in the Weeks and hours it's been on. (I know it's long, it'll be restarted shortly.)
I'm unsure if the intention of the output is to show weeks on, and then total hours on. or if it's supposed to be subracted from the previous values.
Output
th4tkh13m@myarch
kernel ~ 5.10.81-1-lts
uptime ~ 33 minutes
os ~ Arch Linux arch ~ x86_64
de/wm ~ theme ~ cpu ~ Intel Core i5-8365U [email protected]
gpu ~ Intel WhiskeyLake-U GT2 UHD Graphics 620 (rev 02)
pkgs ~ 492
ram ~ 15816 MiB swap ~ 4095 MiB
term ~ st shell ~ bash
Since I did not set GTK theme using settings.ini
but using gsettings set org.gnome.desktop.interface gtk-theme Theme
, it does not show up the theme.
About the de/wm, your edited version did not work for me (printed nothing).
Also, I do think we must handle the case where the user uses the script in a tty (no DE/WM) by using an if/else statement:
if [ -z "${DISPLAY}" ]
then
echo "none"
else
output de/wm
fi
Attempt to read CPU info produces the following erroneous output:
ash: GenuineIntel: unknown operand
Some recent commit introduced an error under WSL2:
de/wm ~ de/wm ~ xprop: unable to open display ''
Presumably the same can happen on other headless systems.
The label is also shown twice, because of line 47.
On a RPi4 running Ubuntu 20.04, xprop
isn't found:
de/wm ~ de/wm ~ ./fetch.sh: line 48: xprop: command not found
Also, the "theme" label is indented, and under WSL2 also prints the path to gsettings
:
theme ~ /usr/bin/gsettings
'Adwaita'
Maybe instead of command -v gsettings
, run which gsettings
and test its return code?
This would include smaller systems that are busybox/ash based, for example.
Proposed fix: while this script is primarily meant for bash-based environments, this is one of the only parts of the script that fails under a simplified shell like ash. This one error would be very easily fixed by using POSIX arithmetic instead of bash let. Link: https://mywiki.wooledge.org/ArithmeticExpression
Fix would be to replace this line:
let "swap_mb = $swap_kb / 1024"
with this:
swap_mb=$(( $swap_kb / 1024 ))
(This is one I might tackle if I get a chance this week, since I have lots of busybox systems to test on.)
When launching Konsole or other terminals from KRunner or Latte Dock in KDE, the term value includes the launcher name along with the terminal name.
Some example cases are:
term ~ latte-dock---konsole
term ~ krunner---konsole
term ~ krunner---cool-retro-term
Is there a possible alternative to to this command for term value?: pstree -sA $$ | head -n1 | sed "s/head//g;s/sysfetch//g;$init_strip;$dewm_strip;$shell_strip;s/^-*//;s/+//;s/-*$//"
Should this include a strip variable / regex for stripping KDE launchers?
In contrast to neofetch:
Terminal: konsole
Terminal: konsole
This makes it more apparent that it is a shell script.
Script at line 88 assumes that the system don't have more than one swap. My system has two: one for zram and another as backup in hard disk.
https://github.com/wick3dr0se/fetch.sh/blob/ad6967c568381e9f52a33d0b8bb021c394994fd8/fetch.sh#L88
Example output:
job@job-pc
kernel ~ 5.10.0-9-amd64
uptime ~ 5 days, 3 hours, 15 minutes
os ~ Devuan GNU/Linux 4 (chimaera) arch ~ x86_64
de/wm ~ XFCE theme ~ grep: /home/job/.config/gtk-3.0/assets: Is a directory
/home/job/.config/gtk 3.0/settings.ini:Breeze
cpu ~ Intel(R) Core(TM) i3-6006U CPU @ [email protected] GHz
gpu ~ Intel Corporation Skylake GT2 HD Graphics 520 (rev 07)
pkgs ~ 4317
ram ~ 3830 MiB./fetch.sh: line 88: let: swap_mb = 5242876
12582908 / 1024: syntax error in expression (error token is "12582908 / 1024")
swap ~ 5242876 MiB
term ~ utmp shell ~ bash
Will file the gtk dir problem in a separate issue.
Debian 10 under WSL2, script throws an error when trying to find a GPU:
gpu ~ ./fetch.sh: line 67: lspci: command not found
Looks like pciutils
might not be installed by default on Debian, at least when running without a desktop.
Having a verbose option which would list whether some parameters were found or not would be nice.
An example:
./fetch.sh
[...]
term ~ alacritty shell ~ bash
bash fetch.sh
[...]
term ~ bash shell ~ bash
Using Bash from MINGW creates an output very similar to #74
$ bash sysfetch
kernel ~ 3.3.3-341.x86_64 arch ~ x86_64
OpenWRT uses opkg as the package tool. The quickest way to get installed package count here is:
opkg list-installed | wc -w
Thanks!
I'm using DWM and a vanilla gtk theme and get the following result
th4tkh13m@myarch
kernel ~ 5.10.80-1-lts
uptime ~ 3 minutes
os ~ Arch Linux arch ~ x86_64
theme ~ cpu ~ Intel(R) Core(TM) i5-8365U CPU @ [email protected] GHz
gpu ~ Intel Corporation WhiskeyLake-U GT2 UHD Graphics 620 (rev 02)
pkgs ~ 487
ram ~ 15816 MiB swap ~ 4095 MiB
term ~ st shell ~ bash
Reason:
Solution:
gsettings get org.gnome.desktop.interface gtk-theme
to find user's theme? It does work for me (showed Adwaita
).$ bash sysfetch
kernel ~ 5.10.16.3-microsoft-standard-WSL2 arch ~ x86_64
Hi @wick3dr0se. Just reporting a few issues:
term
: openrc----supervise-daemo---------x---openbox---xterm---b
. No matter what terminal I use, the result is always the same (except for the terminal name, of course). I guess this might be related to the init system (I use openrc btw), but not sure. Editing the strip lines as follows did the trick for me:init_strip="s/login//g;s/startx//g;s/\<x\>//g;s/xinit//g;s/systemd//g;s/openrc//g;s/init//g"
dewm_strip="s/dwm//g;s/openbox//g"
shell_strip="s/fish//g;s/bash//g;s/zsh//g;s/ash//g"
launcher_strip="s/latte-dock//g;s/krunner//g;s/supervise-daemo//g;s/b+//g"
Perhaps you should add something like misc_strip
to add there miscellaneous stuff like supervise-daemo
and b+
.
you should also expand init_strip
to include alternative init systems.
However, I think there should be a way to get terminal name in a cleaner, simpler way: stripping a string in this way will soon o later fail in some manner.
de/wm
field, I get plain nothing (using openbox
). I edited de-wm_theme.sh
as follows to make it work for me:head /usr/share/xsessions/* | grep -im1 'names=\|name=' | sed 's/DesktopNames=//;s/Name//g;s/CLASSIC//g;s/Ubuntu//;s/ubuntu//g;s/Classic//g;s/GNOME//2g' | tr -d '=:-;\n'
As a last resource, though relying on external applications is not a good idea, you could fallback to wmctrl -m
, if available, in case everything else fails.
ram
has an extra slash. I just removed the ending slash after %d
in cur_mem
(main script)Hope it helps!
As mentioned in issue #4, I also encountered another problem when I ran the script.
Output:
job@job-pc
kernel ~ 5.10.0-9-amd64
uptime ~ 5 days, 3 hours, 15 minutes
os ~ Devuan GNU/Linux 4 (chimaera) arch ~ x86_64
de/wm ~ XFCE theme ~ grep: /home/job/.config/gtk-3.0/assets: Is a directory
/home/job/.config/gtk 3.0/settings.ini:Breeze
cpu ~ Intel(R) Core(TM) i3-6006U CPU @ [email protected] GHz
gpu ~ Intel Corporation Skylake GT2 HD Graphics 520 (rev 07)
pkgs ~ 4317
ram ~ 3830 MiB./fetch.sh: line 88: let: swap_mb = 5242876
12582908 / 1024: syntax error in expression (error token is "12582908 / 1024")
swap ~ 5242876 MiB
term ~ utmp shell ~ bash
This would include smaller systems that are busybox based, for example.
Proposed fix: test for presence of /usr/bin/whoami, and extract the username from /usr/bin/id instead if whoami not present on system.
(This is one I might tackle if I get a chance this week, since I have lots of busybox systems to test on.)
Opening a new issue about this:
I'm beginning to think that a simple check to see if the file exists, and then not outputting anything may be the best way to go forward with this on WSL2, as there is no easy way to get the current CPU Frequency through WSL2.
I do wonder if this shows on other OS's under WSL2, also as I'm running Ubuntu only under WSL2.
# bash sysfetch
sysfetch: line 7: /dev/fd/62: No such file or directory
@
Worth noting that this was run on an emulated Linux machine in the browser: https://bellard.org/jslinux/
Also worth noting: uname -snrmo
(which is in Line 7) does execute fine: Linux localhost 4.12.0-rc6-g48ec1f0-dirty i586 Linux
for some reason the ASCII art won't work. and the OS: prints an extra "NAME="
also i made a list of gruvbox ports. check it out: https://github.com/gentoo-btw/awesome-gruvbox
a star would be appreciating.
Was testing in a Fedora 36 VM, for some reason the script just freezes/gets in an endless loop and does not output anything.
The issue in particular seems to be line 4, as commenting that out makes the script actually progress:
Line 4 in 96e09ca
A declarative, efficient, and flexible JavaScript library for building user interfaces.
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. πππ
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google β€οΈ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.