macchina-cli / macchina Goto Github PK
View Code? Open in Web Editor NEWA system information frontend with an emphasis on performance.
Home Page: https://crates.io/crates/macchina
License: MIT License
A system information frontend with an emphasis on performance.
Home Page: https://crates.io/crates/macchina
License: MIT License
To further extend the capabilities of Macchina, a new argument: --random-sep-color
will be introduced to let Macchina pick a random separator
color for you, it can be used in conjunction with --random-color
.
I can never settle on what color to use, and always find myself changing the color every now and then, so I made --random-color
.
But now I've noticed that it's the same case with the separator.
I made the auto complete for custom themes work with the fish shell completions.
It needed a little bit on manual tweaking.
As long as there are no breaking changes this can probably be automated.
I can probably make a patch that would apply to the macchina.fish
generated from clap but I have no clue where to apply it.
The best way to apply it would probably be in the PKGBUILD or whatever packaging system is being used.
I found in the pciutils repository the following:
In runs on the following systems:
Linux (via /sys/bus/pci, /proc/bus/pci or i386 ports)
FreeBSD (via /dev/pci)
NetBSD (via libpci)
OpenBSD (via /dev/pci)
GNU/kFreeBSD (via /dev/pci)
Solaris/i386 (direct port access)
Aix (via /dev/pci and odmget)
GNU Hurd (direct port access)
Windows (direct port access, see README.Windows for caveats)
CYGWIN (direct port access)
BeOS (via syscalls)
Haiku (via /dev/misc/poke)
Darwin (via IOKit)
DOS/DJGPP (via i386 ports)
SylixOS (via /proc/pci)
There are many possible places to search, depending on the kernel (or operating system). But in some cases it's a matter of reading a plain text file. In order not to make the issue too long, I recommend the first part of this article. As you can see in the article, it is possible to read the vendor identifier, device identifier and class identifier.
I quote again the previous repository, the following:
The database of PCI IDs (the pci.ids file) gets out of date much faster
than I release new versions of this package, so it is maintained separately.It lives at https://pci-ids.ucw.cz/, where you can browse the database,
download the most recent pci.ids file (e.g., by running the update-ids utility)
and also submit new entries.
If we go through that website, we can corroborate that the GPU information (in addition to other devices that are not relevant) can be obtained from these ID's.
At first I thought that the pci.ids
file should be downloaded regularly to keep it updated but, at least in Arch Linux, I found it in /usr/share/hwdata/pci.ids
.
I'm not sure this is the best way to solve it, but I think it can work, without relying on system commands or external crates.
Macchina's theming implementation is very simple, but it is not modular, extensible or clean in any way.
Elements
is currently stuffed with miscellaneous fields, that should be grouped together and put under a new theme
structure.
It would be interesting to show the number of global packages from:
Important consideration: How do we avoid a performance hit?
I have added Macchina as a package in Termux, so it can now be installed on Android through Termux with the apt
package manager:
apt install macchina
If you wish I can edit the Wiki to add the Termux installation option.
Edit: You can close the issue when you see it, it is for information purposes only.
Describe the bug
In the machine field there are no longer spaces
To Reproduce
macchina
Expected behavior
Formatting like 0.6.2
Screenshots
System Information
You don't have to provide this information if you're not comfortable doing so, but it'll help us solve the issue a lot faster.
Should the latest release be 0.8.2
rather than 0.8.21
?
Hello, it's me again.
As the title says, not every machine name is contained in "/sys/class/dmi/id/product_version". In fact, my Dell XPS 15 shows no model name in it.
There is, however, a more generalized command that works on every Linux pc: to find my model I usually do cat /sys/devices/virtual/dmi/id/product_name
(this excluding btw the Manufacturer, that is contained in /sys/devices/virtual/dmi/id/sys_vendor
).
So, in the end, to print out the whole line in this way I usually do (on the fish shell): echo (cat /sys/devices/virtual/dmi/id/sys_vendor) (cat /sys/devices/virtual/dmi/id/product_ name)
(or, on bash, echo
Tell me if this works for you because the current implementation doesn't.
EDIT: I just realized that it IS present in /sys/class/dmi/id/product_version, but macchina simply doesn't want it to print out on my terminal.
In order to showcase Macchina's performance across the different platforms it supports, we need to add a macOS specific benchmark, in comparison to Neofetch under the "Benchmarks" section of bothREADME.md
and README_CARGO.md
I discovered console_engine
today, which always a rich control of the terminal and how text / graphics are displayed:
https://crates.io/crates/console_engine
This would allow us to create complex images by using absolute / relative positions instead of printing spacers. Here is an example gif of what is possible (runs on macOS, Windows, Linux, haven't tried netBSD but should work on all UNIX terminals):
Memory usage bar never exceeds 2 blocks, I'm working to fix this issue.
Update: latest commit fixes this issue.
Opening a Terminal Large enough to fit the prompt works fine.
However, when the width of the terminal window is reduced enough...
The text overflows to the next line even though it appears as it should fit.
Steps to reproduce the behavior:
Expected behavior:
Terminal Content should have not changed
macchina --doctor
output
Correct
System Information
I'm not sure if this bug still persists as it was raised before the newer shell implementation that was recently merged into main
.
Describe the bug
Most of the time, shell
output is printed just fine. But in some rare cases, shell
output can begin with a hyphen, e.g.
Shell โ -zsh
To Reproduce
Steps to reproduce the behavior:
macchina
Expected behavior
Shell value should never start with a hyphen.
Screenshots
No screenshot provided
System Information
Describe the bug
macchina on windows has no colors in doctor output.
Also the ascii art is really hard to see in default PowerShell
I honestly have no clue how windows handles it color codes so I don't know how to fix it.
To Reproduce
Steps to reproduce the behavior:
Expected behavior
Colored output like in linux/mac
System Information
You don't have to provide this information if you're not comfortable doing so, but it'll help us solve the issue a lot faster.
Describe the bug
macchina.toml
settings are being ignored
To Reproduce
export XDG_CONFIG_HOME="$HOME/.config"
cd $XDG_CONFIG_HOME && mkdir macchina && cd macchina
wget macchina.toml https://raw.githubusercontent.com/Macchina-CLI/macchina/main/macchina.toml
I have restarted the terminal, re-sourced my shell configurations and so forth, but no changes occur. Must one specify explicitly that macchina
must be reading the config via a flag or so?
Expected behavior
The configuration .toml
changes the appearence of macchina
.
System Information
Describe the bug
When the cpu usage is above 100%
macchina --bar
Shows cpu% as empty
To Reproduce
Steps to reproduce the behavior:
maccina --bar
Expected behavior
I'd hope to see a full bar instead of an empty bar
Screenshots
macchina
macchina --doctor
output
Add a screenshot or copy and paste the output of --doctor
if an element you're supposed to be seeing isn't showing up.
System Information
You don't have to provide this information if you're not comfortable doing so, but it'll help us solve the issue a lot faster.
Not necessarily for you to do, but someone who's familiar with creating AUR packages from rust binaries could do this very easily.
By default macchina
displays all system information in a default format. To change this, one must make use of the many options available (and there seem to be more and more of them). And this can sometimes result in a rather long command.
I'm not sure what the future plans of the project are, but it occurs to me that creating a configuration file from which to read the macchina
defaults might be a good idea. Of course this is not the only way to solve the above problem; on Linux systems you could create an alias
that runs macchina
with the desired options.
I have also tried the different themes offered by the application. My question is, are there any plans to add custom themes? It could be an alternative to the configuration file.
Of course, whichever way you go, it's not something that will be done overnight. But whatever I can do to help, I'm willing.
Describe the bug
Macchina on macOS reports "Login" as terminal, because of a possibly wrong argument being used to fetch the terminal in shared::terminal()
To Reproduce
Steps to reproduce the behavior:
macchina
Expected behavior
Terminal should print the running terminal's name.
System Information
Comparison on Windows shouldn't be done with neofetch. Neofetch on Windows runs with MSys2/Cygwin, which use a POSIX emulation layer. Since it is emulating bash, it will always be slower, no matter what. Bash is not a native shell in Windows.
For a fairer comparison, please use winfetch. Macchina is still faster, but only by 2x (compared to 250x with neofetch ๐ )
Title.
IMO using rust to count output lines it's less efficient than having the count done with pacman -Qq | wc -l
. I've done a test with hyperfine only taking the chunk of code that counts packages and comparing it with that line and ofc the shell command is faster.
Just letting you know, great job btw!
(Also, remember to update the AUR pkg on the releases :D)
EDIT: I have found an alternative implementation, maybe you can import it and use it; https://github.com/alex/line-counter/blob/master/src/main.rs
Would you like to package it for FreeBSD ?
Describe the bug
hyperfine
reports execution time at like 2 seconds.
Benchmark #1: macchina
Time (mean ยฑ ฯ): 2.284 s ยฑ 0.623 s [User: 28.7 ms, System: 28.1 ms]
Range (min โฆ max): 2.045 s โฆ 4.055 s 10 runs
Warning: Statistical outliers were detected. Consider re-running this benchmark on a quiet PC without any interferences from other programs. It might help to use the
'--warmup' or '--prepare' options.
This also occurs in some piped commands.
time macchina | xclip -sel clip
________________________________________________________
Executed in 2.07 secs fish external
usr time 22.48 millis 0.00 millis 22.48 millis
sys time 31.98 millis 2.15 millis 29.82 millis
But not in others
time macchina | tee log
________________________________________________________
Executed in 41.62 millis fish external
usr time 11.07 millis 351.00 micros 10.72 millis
sys time 12.55 millis 131.00 micros 12.42 millis
This also happens in openwrt.
To Reproduce
Steps to reproduce the behavior:
Expected behavior
Should be as fast as printing to terminal
macchina --doctor
output
Add a screenshot or copy and paste the output of --doctor
if an element you're supposed to be seeing isn't showing up.
System Information
Describe the bug
Package count prints an incorrect value for Gentoo.
The current implentation fetches the output of ls /var/db/pkg | wc -l
but this does not provide the user with the correct amount of installed packages.
The correct way fetch the package count, is to print the output of ls -d /var/db/pkg/*/* | wc -l
. However, Rust doesn't support passing glob patterns to a command's args()
, as the documentation states:
"Note that the argument is not passed through a shell, but given literally to the program. This means that shell syntax like quotes, escaped characters, word splitting, glob patterns, substitution, etc. have no effect."
Trying to use glob patterns returns the following error:
ls: cannot access '/var/db/pkg/*/*': No such file or directory
To Reproduce
Steps to reproduce the behavior:
macchina
Expected behavior
Print the correct amount of installed packages in a Gentoo system.
I would like to be able to wrap some custom commands to display information I chose.
Like
# Show available upgrade in Voidlinux
custom_info:
- name: XBPS
command: xbps-query -Mnu | wc -l
I would use your fetcher on remote hosts, and run it at each login to get some useful informations, and display it prettily.
When trying to install on my Raspberry, my pi is throttling the cargo installation. All 4 core go on 100% load and becomes very slow on installing. is there any easier way? im thinking "pkg install macchina".
I'm pretty sure it is not specific to my machine (arch linux).
I added this line in my .config/macchina/macchina.toml
config:
custom_ascii = "~/.config/macchina/arco-theme"
But I get an error:
Error: Os { code: 2, kind: NotFound, message: "No such file or directory" }
And this file exists: when I use the absolute path
custom_ascii = "/home/rambi/macchina/arco-theme"
This works.
If this is not a bug, this is clearly a usefull feature that is missing !
(Or whatever they call it).
This is something I find myself constantly looking after: Ubuntu releases have a version number (20.04 in my case), and a "nickname" (Focal). In many cases I need the latter, and I'm always doubting about which is right.
Granted, I could just cat /etc/os-release
(which is the now standard way of doing it), but I still need to ponder whether I should lsb_release
, or cat /etc/lsb-release
or whatever, and it distracts me from the problem at hand.
Would you add this piece of info to Macchina, I'd adopt it. Deal ?
Cheers, and thanks for your work !
Describe the bug
There are some false information when running macchina on macOS:
To Reproduce
Steps to reproduce the behavior:
Expected behavior
Proper info.
System Information
As it says on the readme - macos support isn't currently implemented. I also get this when building this package via cargo:
error[E0425]: cannot find function `percentage` in module `battery`
--> /Users/theoparis/.cargo/registry/src/github.com-1ecc6299db9ec823/macchina-0.5.4/src/bars.rs:7:20
|
7 | match battery::percentage(fail)
| ^^^^^^^^^^ not found in `battery`
and a ton of other very similar errors.
The extra::which
function, which checks if a program exists, should search in all folder that are given in the PATH variable.
Describe the bug
Using
macchina -t def
causes
memory allocation of 18446744073709551613 bytes failed
[1] 22666 abort (core dumped) macchina -t def
To Reproduce
Steps to reproduce the behavior:
Expected behavior
Run normally
System Information
Additional context
Add any other context about the problem here.
Resolved: commit 6246d63 seems to have fixed this bug.
EDIT: Nevermind that, the bug still persists.
EDIT 2: commit 805c0b8 should fix this issue.
EDIT 3: the bug still persits, but the reason this bug happens is now clear.
EDIT 4: The bug is gone! (e871ae8)
macchina --bar
shows an extra whitespace at the end of the battery bar before the closing bracket.
Yes
/// Return the correct amount of colored blocks: colored blocks are used blocks
pub fn colored_blocks(elems: &Elements, block_count: usize) -> ColoredString {
let colored_blocks = elems.format.bar_glyph.repeat(block_count);
colored_blocks
.chars()
.collect::<Vec<char>>()
.chunks(1)
.map(|c| c.iter().collect::<String>())
.collect::<Vec<String>>()
.join(" ")
.color(elems.format.color)
}
This function is meant to split up the amount of blocks into chunks, add a space between them, color and return them. but, whenever the block_count
is equal to 10, it adds an extra space!
In it's current state, Macchina is limited in the amount of displayed data. We should display more information and this issue is here to collect some ideas:
Macchina will probably get confused when your custom theme has the same name as the built-in theme and choose one over the other, so to avoid this, a conflict warning message needs to be printed to the screen notifying the user that their custom theme name isn't valid as it's already in use by a built-in theme.
EDIT: Currently, Macchina defaults back to the default theme when this issue is encountered, but the error message isn't helpful.
Describe the bug
When running macchina
in ssh
(or et
), the error Cannot open display
is shown multiple times and the WM
data row is still displayed.
To Reproduce
Steps to reproduce the behavior:
ssh
.macchina
.Expected behavior
No error displayed and WM -
row hidden.
System Information
Describe the bug
> macchina
thread 'main' panicked at 'No entry found for key 0x7fe6c5600ba0', /Users/fdncred/.cargo/registry/src/github.com-1ecc6299db9ec823/core-foundation-0.9.1/src/dictionary.rs:233:43
stack backtrace:
0: 0x1080a8d29 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h34f76b2ca42fab41
1: 0x108080fad - core::fmt::write::h8f13d857463c51c1
2: 0x1080a8476 - std::io::Write::write_fmt::h0a6214ccb1a8468b
3: 0x1080a7ba4 - std::panicking::rust_panic_with_hook::h28bf9d6c3916221e
4: 0x1080cb54a - std::panicking::begin_panic_handler::{{closure}}::h99569328be4adae9
5: 0x1080cb4b8 - std::sys_common::backtrace::__rust_end_short_backtrace::h9a7e5cc6475b496b
6: 0x1080cb460 - _rust_begin_unwind
7: 0x1080cb42f - std::panicking::begin_panic_fmt::hc364d6defd6a88b8
8: 0x108095862 - core_foundation::dictionary::CFMutableDictionary<K,V>::get::{{closure}}::h1ef14b3201e41ad6
9: 0x108026032 - macchina::data::get_all_readouts::h822a64d8592cec98
10: 0x1080281dc - macchina::main::hbb20e545ea1f7921
11: 0x10800a84a - std::sys_common::backtrace::__rust_begin_short_backtrace::h41354b2dac9becba
12: 0x10800ac46 - std::rt::lang_start::{{closure}}::hb43fe7bf99502281
13: 0x108033dfb - _main
To Reproduce
Steps to reproduce the behavior:
Expected behavior
not panic
Screenshots
If applicable, add screenshots to help explain your problem.
macchina --doctor
output
macchina --doctor
thread 'main' panicked at 'No entry found for key 0x7f800a501240', /Users/fdncred/.cargo/registry/src/github.com-1ecc6299db9ec823/core-foundation-0.9.1/src/dictionary.rs:233:43
stack backtrace:
0: 0x10ff35d29 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h34f76b2ca42fab41
1: 0x10ff0dfad - core::fmt::write::h8f13d857463c51c1
2: 0x10ff35476 - std::io::Write::write_fmt::h0a6214ccb1a8468b
3: 0x10ff34ba4 - std::panicking::rust_panic_with_hook::h28bf9d6c3916221e
4: 0x10ff5854a - std::panicking::begin_panic_handler::{{closure}}::h99569328be4adae9
5: 0x10ff584b8 - std::sys_common::backtrace::__rust_end_short_backtrace::h9a7e5cc6475b496b
6: 0x10ff58460 - _rust_begin_unwind
7: 0x10ff5842f - std::panicking::begin_panic_fmt::hc364d6defd6a88b8
8: 0x10ff22862 - core_foundation::dictionary::CFMutableDictionary<K,V>::get::{{closure}}::h1ef14b3201e41ad6
9: 0x10feb3032 - macchina::data::get_all_readouts::h822a64d8592cec98
10: 0x10feb51dc - macchina::main::hbb20e545ea1f7921
11: 0x10fe9784a - std::sys_common::backtrace::__rust_begin_short_backtrace::h41354b2dac9becba
12: 0x10fe97c46 - std::rt::lang_start::{{closure}}::hb43fe7bf99502281
13: 0x10fec0dfb - _main
System Information
You don't have to provide this information if you're not comfortable doing so, but it'll help us solve the issue a lot faster.
Describe the bug
I would like to display some information with macchina. These should be without a separator and the categories should be written out (for example, "machine" should be written instead of "mac", etc.).
no_separator = true
gives the error message "conflicting keys in config file: separator_color and no_separator".
So I commented out separator_color
. Which in itself also works without an error message, but now the information is all abbreviated (Host = Hos, Machine = Mac, etc.). The short_shell
parameter doesn't solve the problem either, regardless of whether the flag is true
or false
, the output remains the same.
Long story short: I only get some written out information together with a "conflict" error message but never with no_separator = true
.
To Reproduce
Steps to reproduce the behavior:
no_separator = true
(line 7 )#separator_color
(line 63)macchina
Expected behavior
Display some information without separator and with written out categories ("machine" instead of "mac", etc.)
System Information
You don't have to provide this information if you're not comfortable doing so, but it'll help us solve the issue a lot faster.
Describe the bug
๐ trying to build the latest release, but run into some build issue. The error log is as below:
$ RUST_BACKTRACE=full /usr/local/Cellar/macchina/0.7.3/bin/macchina --doctor
thread 'main' panicked at 'Could not get vm page size.', /Users/rchen/Library/Caches/Homebrew/cargo_cache/registry/src/github.com-1ecc6299db9ec823/libmacchina-0.3.1/src/macos/mod.rs:335:18
stack backtrace:
0: 0x10772b02f - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h04abbaabf148650a
1: 0x1076ff51e - core::fmt::write::h14dac7cadec1cc70
2: 0x107727e3a - std::io::Write::write_fmt::hfaf2e10dfdcc61d8
3: 0x10774a313 - std::panicking::rust_panic_with_hook::h8cdc0a575f4a5a7b
4: 0x10770c8dd - std::panicking::begin_panic::{{closure}}::h1cb5e31eebf53a0a
5: 0x10770c8a8 - std::sys_common::backtrace::__rust_end_short_backtrace::h5289044154439ad3
6: 0x10775d93d - std::panicking::begin_panic::ha9aa3db83f8d0fab
7: 0x10768baf1 - macchina::data::get_all_readouts::h7f00e763b2b7f7aa
8: 0x10769198e - macchina::main::h3272ae73cea80bf8
9: 0x10767b3ca - std::sys_common::backtrace::__rust_begin_short_backtrace::h0fecb7c939f513a5
10: 0x10767bb96 - std::rt::lang_start::{{closure}}::h0cc748e43438e7c3
11: 0x1076a9819 - _main
Full build log is in here, https://github.com/Homebrew/homebrew-core/runs/2488142444
relates to Homebrew/homebrew-core#76473
Describe the bug
machina doesn't report battery status from laptop
It seems that macchina reads battery stats from hardcoded /sys/class/power_supply/BAT0/
folder
But In my system the battery is in /sys/class/power_supply/BAT1/
folder.
The acpi
command seems to correctly report the battery status in my system.
To Reproduce
Steps to reproduce the behavior:
Expected behavior
macchina reports battery stats
System Information
This post has made me aware of the difficulties blind people can come across when using programs.
This will of course be a feature one can enable on their own. It's time fetchers started targeting a wider audience. ๐
If any of you lovely people has any expertise in accessibility features and can help implement this one or can help provide us with ideas, we'd really appreciate it! โค๏ธ
Enhancement
Cargo clippy reports a lot of warnings.
error: aborting due to 3 previous errors; 41 warnings emitted
error: could not compile `macchina`
To Reproduce
Steps to reproduce the behavior:
cargo clippy
This could be fixed to improve code quality and avoid errors.
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.