Skip to content

Commit

Permalink
New: CPU Usage Statistic (#65)
Browse files Browse the repository at this point in the history
* Use libmacchina v0.2.2, and include CPU usage

- This PR brings the latest that libmacchina has to offer, starting from
  a new feature, which is quite nice to have, and that is CPU
  usage/load. Did I hear you say "bar"?

Yes you can use bars to visualize your processor's load!

- It also fixes a slight little copy & paste mistake, which I'm happy
  didn't cause any trouble.

- Another neat little feature is the --no-title flag, so if you don't
  like the idea of box titles, you're in luck, you no longer have to use
  --box-title "" to achieve what --no-title's purpose.

* Change up the order of readouts

- This was mostly done to accomodate for CPU usage, so that every
  readout that can display a bar, can have a nice aesthetic because all
  the bars are stacked on top of each other. And another reason, is because
  the order of readouts before this change, did not make much sense, at least to me.

* Update preview images and Changelog.txt

* Update the program's about/description
  • Loading branch information
grtcdr authored Apr 8, 2021
1 parent 71b16e2 commit 7dab224
Show file tree
Hide file tree
Showing 14 changed files with 218 additions and 180 deletions.
5 changes: 4 additions & 1 deletion CHANGELOG.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
# Changelog
- libmacchina: Merge OpenWrt support PR by @uttarayan21
- Reorder the readouts
- libmacchina can now fetch CPU usage, and Macchina can now display it
- Fixed a bug where LocalIP will be marked as failed when username or hostname fails to fetch
- Updated some of the example images in README files
8 changes: 4 additions & 4 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 3 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
[package]
name = "macchina"
version = "0.6.6"
version = "0.6.7"
authors = ["Taha Aziz Ben Ali <[email protected]>", "Marvin Haschker <[email protected]>"]
edition = "2018"
description = "A system information fetcher, with a focus on performance and minimalism."
description = "A system information fetcher, with an emphasis on performance and minimalism."
keywords = ["system", "fetch", "cli"]
repository = "https://github.com/Macchina-CLI/macchina"
license = "MIT"
Expand All @@ -16,8 +16,7 @@ lto = true
codegen-units = 1

[dependencies]
num_cpus = "1.13.0"
libmacchina = "0.2.0"
libmacchina = "0.2.2"
bytesize = "1.0.1"
clap = "2.33.3"
tui = { version = "0.14.0", default-features = false, features = ['crossterm'] }
Expand Down
21 changes: 11 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,15 +88,15 @@ __Summary__: `macchina` runs __18.25 ± 2.16__ times __faster__ than `neofetch`

# Features <a name="features"></a>
## Themes
![Theme preview](screenshots/themes.png)

The [themes wiki page](https://github.com/grtcdr/macchina/wiki/Themes) contains a list of all the built-in themes that you can switch between using the `--theme` flag.

## Bars
![Preview of bar argument](screenshots/bars.png)
![Theme preview](screenshots/theme.png)

## Bars
Bars provide a way to visualize data, and each theme styles them differently. They can be enabled using the `--bar` flag.

![Preview of bar argument](screenshots/bars.png)

## What it fetches
- Host
- Username
Expand All @@ -107,27 +107,28 @@ Bars provide a way to visualize data, and each theme styles them differently. Th
- Operating System
- Desktop Environment
- Window Manager
- Package Count <sup>[[1]](https://github.com/grtcdr/macchina/wiki/Platform-Support)</sup>
- Shell
- Package Count [[1]](https://github.com/grtcdr/macchina/wiki/Platform-Support)
- Terminal
- Shell
- Uptime
- Processor
- Model
- Thread count
- Logical Cores
- Local IP Address
- Uptime
- Processor Usage
- Memory Usage
- Battery
- Percentage
- Status
- Palette

## Meet Doctor
![Doctor flag preview](screenshots/doctor.png)

_Macchina_ comes with a very special flag, allowing you to know why certain elements, for example, your operating system information might not be appearing. It can differentiate between errors, and warnings, and its comprehensive output should help you understand where the issue is coming from.

To use this feature, run `macchina --doctor`

![Doctor flag preview](screenshots/doctor.png)

---

# Usage <a name="usage"></a>
Expand Down
9 changes: 5 additions & 4 deletions README_CARGO.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ __Summary__: `macchina` runs __18.25 ± 2.16__ times __faster__ than `neofetch`

# Features
## Themes
![Theme preview](screenshots/themes.png)
![Theme preview](screenshots/theme.png)

The [themes wiki page](https://github.com/grtcdr/macchina/wiki/Themes) contains a list of all the built-in themes that you can switch between using the `--theme` flag.

Expand All @@ -81,13 +81,14 @@ Bars provide a way to visualize data, and each theme styles them differently. Th
- Desktop Environment
- Window Manager
- Package Count [[1]](https://github.com/grtcdr/macchina/wiki/Platform-Support)
- Shell
- Terminal
- Shell
- Uptime
- Processor
- Model
- Thread count
- Logical Cores
- Local IP Address
- Uptime
- Processor Usage
- Memory Usage
- Battery
- Percentage
Expand Down
Binary file modified screenshots/bars.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified screenshots/doctor.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added screenshots/theme.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed screenshots/themes.png
Binary file not shown.
22 changes: 14 additions & 8 deletions src/bars.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,16 @@
/**
Returns a `usize` whose value can range from 0 up to 10 based on the given `value`.
This is used to calculate the number of blocks to show
in a bar.
/// Returns a usize [0..10] based on the battery percentage,
/// `display::show_bar` takes this function as a parameter to handle
/// displaying the bar
pub fn battery(percentage: u8) -> usize {
match percentage {
For example:
- __CPU Usage__ ranges from 0 to 100%, this function can return a `usize`
that tells the bar how many of its blocks should be represented as being used.
The same goes for __battery percentage__, as it ranges from 0 to 100%.
*/
pub fn num_to_blocks(value: u8) -> usize {
match value {
0..=10 => 1,
11..=20 => 2,
21..=30 => 3,
Expand All @@ -19,9 +26,8 @@ pub fn battery(percentage: u8) -> usize {
}
}

/// Returns a usize [0..10] based on the memory usage,
/// `display::show_bar` takes this function as a parameter to handle
/// displaying the bar
/// Returns a `usize` whose value can range from 0 up to 10 based on the given `value`.
/// This is very similar to `num_to_blocks` but the calculations are done in a different way.
pub fn memory(used: u64, total: u64) -> usize {
let used = used as f64;
let total = total as f64;
Expand Down
Loading

0 comments on commit 7dab224

Please sign in to comment.