diff --git a/CHANGELOG.md b/CHANGELOG.md index 5e94540..371d3d8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +## 6.3.0 + +- Add a new `--disks` flag, allowing users to specify multiple disks to show disk usage for. + ## `6.2.1` - Fix ratatui dependency issue causing installations to fail diff --git a/Cargo.lock b/Cargo.lock index a461038..dcfcb26 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -108,9 +108,9 @@ dependencies = [ [[package]] name = "anyhow" -version = "1.0.88" +version = "1.0.89" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4e1496f8fb1fbf272686b8d37f523dab3e4a7443300055e74cdaa449f3114356" +checksum = "86fdf8605db99b54d3cd748a44c6d04df638eb5dafb219b135d0149bd0db01f6" [[package]] name = "atty" @@ -214,9 +214,9 @@ dependencies = [ [[package]] name = "cc" -version = "1.1.18" +version = "1.1.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b62ac837cdb5cb22e10a256099b4fc502b1dfe560cb282963a974d7abd80e476" +checksum = "2d74707dde2ba56f86ae90effb3b43ddd369504387e718014de010cec7959800" dependencies = [ "shlex", ] @@ -715,9 +715,9 @@ dependencies = [ [[package]] name = "iana-time-zone" -version = "0.1.60" +version = "0.1.61" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e7ffbb5a1b541ea2561f8c41c087286cc091e21e556a4f09a8f6cbf17b69b141" +checksum = "235e081f3925a06703c2d0117ea8b91f042756fd6e7a6e5d901e8ca1a996b220" dependencies = [ "android_system_properties", "core-foundation-sys 0.8.7", @@ -829,9 +829,8 @@ dependencies = [ [[package]] name = "libmacchina" -version = "7.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8cbc5a1333bb9dff638bbf4d953f27106d4c2ff2c1e4d7c4c90ddf8da500ad66" +version = "8.0.0" +source = "git+https://github.com/Macchina-CLI/libmacchina?branch=8.0.0#4c7ffe10e2968ceadf3b27479b016fd9920d8a6e" dependencies = [ "cfg-if 1.0.0", "core-foundation 0.9.4", @@ -916,7 +915,7 @@ dependencies = [ [[package]] name = "macchina" -version = "6.2.1" +version = "6.3.0" dependencies = [ "ansi-to-tui", "atty", @@ -1107,9 +1106,9 @@ dependencies = [ [[package]] name = "once_cell" -version = "1.19.0" +version = "1.20.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" +checksum = "33ea5043e58958ee56f3e15a90aee535795cd7dfd319846288d93c5b57d85cbe" [[package]] name = "option-ext" @@ -1713,9 +1712,9 @@ checksum = "e91b56cd4cadaeb79bbf1a5645f6b4f8dc5bde8834ad5894a8db35fda9efa1fe" [[package]] name = "unicode-segmentation" -version = "1.11.0" +version = "1.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d4c87d22b6e3f4a18d4d40ef354e97c90fcb14dd91d7dc0aa9d8a1172ebf7202" +checksum = "f6ccf251212114b54433ec949fd6a7841275f9ada20dddd2f29e9ceea4501493" [[package]] name = "unicode-truncate" diff --git a/Cargo.toml b/Cargo.toml index 47cbe01..cc4eebf 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "macchina" -version = "6.2.1" +version = "6.3.0" authors = ["Aziz Ben Ali ", "Marvin Haschker ", "Uttarayan Mondal "] edition = "2021" description = "A system information fetcher with an emphasis on performance." @@ -11,7 +11,7 @@ readme = "README.md" build = "build.rs" [dependencies] -libmacchina = { version = "7.3.1", features = ["version"] } +libmacchina = { git = "https://github.com/Macchina-CLI/libmacchina", branch = "8.0.0", features = ["version"] } bytesize = "1.3.0" shellexpand = "3.1.0" clap = { version = "4.4.6", features = ["derive"] } diff --git a/doc/macchina.1 b/doc/macchina.1 index b48e43c..6896907 100644 --- a/doc/macchina.1 +++ b/doc/macchina.1 @@ -1,341 +1,187 @@ -.\" Generated by scdoc 1.11.2 +.\" Generated by scdoc 1.11.3 .\" Complete documentation for this program is not available as a GNU info page .ie \n(.g .ds Aq \(aq .el .ds Aq ' .nh .ad l .\" Begin generated content: -.TH "MACCHINA" "1" "2024-02-03" -.P +.TH "MACCHINA" "1" "2024-09-29" +.PP .SH NAME -.P +.PP macchina - A system information frontend, with an (unhealthy) emphasis on performance.\& -.P +.PP .SH SYNOPSIS -.P +.PP \fBmacchina\fR [FLAGS] -.P +.PP .SH FLAGS -.P +.PP \fB-d, --doctor\fR .RS 4 Checks the system for failures.\& -.P +.PP .RE \fB-e, --export-config\fR .RS 4 Prints a template configuration file to stdout.\& -.P +.PP .RE \fB-c, --config\fR=\fIFILE\fR .RS 4 Specify a custom path to a configuration file.\& -.P +.PP This is helpful in cases where macchina fails to parse the configuration file from the default path, i.\&e.\& \fB$XDG_CONFIG_HOME/macchina/macchina.\&toml\fR.\& -.P +.PP .RE \fB-l, --list-themes\fR .RS 4 Lists all available themes.\& -.P +.PP Themes are \fBTOML\fR files which must be placed in \fB$XDG_CONFIG_HOME/macchina/themes\fR.\& Whatever this flag returns to the console can be used with the \fB--theme\fR flag.\& -.P +.PP .RE \fB-t, --theme\fR=\fITHEME\fR .RS 4 Specify the name of the theme to use, i.\&e.\& its basename and without the ".\&toml" extension.\& -.P +.PP You should verify whether macchina was able to find your theme with \fB--list-themes\fR.\& -.P +.PP .RE \fB-i, --interface\fR=\fIIF_NAME\fR .RS 4 Specify the network interface for the LocalIP readout, e.\&g.\& "wlan0", "eth0".\& -.P +.PP .RE \fB-s, --current-shell\fR .RS 4 Toggles between the current shell, i.\&e.\& the parent of the terminal emulator, or the default one.\& -.P +.PP .RE \fB-C, --logical-cores\fR .RS 4 Toggles between logical and physical cores for the Processor readout.\& -.P +.PP .RE \fB-K, --long-kernel\fR .RS 4 Lengthens kernel output.\& -.P +.PP .RE \fB-S, --long-shell\fR .RS 4 Lengthens shell output.\& -.P +.PP .RE \fB-U, --long-uptime\fR .RS 4 Lengthens uptime output.\& -.P +.PP .RE \fB-m, --memory-percentage\fR .RS 4 Show memory usage in percentage -.P +.PP +.RE +\fB-D, --disks\fR +.RS 4 +Specify the disks for which the usage percentage will be shown +.PP .RE \fB-p, --disk-space-percentage\fR .RS 4 Show disk space usage in percentage -.P +.PP .RE \fB-h, --help\fR .RS 4 Prints help information.\& -.P +.PP .RE \fB-v, --version\fR .RS 4 Prints version information.\& -.P +.PP .RE \fB-o, --show\fR .RS 4 Display only the specified readouts.\& -.P +.PP Please note that the order these are listed in will be the order that they are displayed in.\& -.P +.PP Possible values are (case-sensitive): -.RS 4 -.ie n \{\ -\h'-04'\(bu\h'+03'\c -.\} -.el \{\ +.PD 0 .IP \(bu 4 -.\} Host -.RE -.RS 4 -.ie n \{\ -\h'-04'\(bu\h'+03'\c -.\} -.el \{\ .IP \(bu 4 -.\} Machine -.RE -.RS 4 -.ie n \{\ -\h'-04'\(bu\h'+03'\c -.\} -.el \{\ .IP \(bu 4 -.\} Kernel -.RE -.RS 4 -.ie n \{\ -\h'-04'\(bu\h'+03'\c -.\} -.el \{\ .IP \(bu 4 -.\} Distribution -.RE -.RS 4 -.ie n \{\ -\h'-04'\(bu\h'+03'\c -.\} -.el \{\ .IP \(bu 4 -.\} OperatingSystem -.RE -.RS 4 -.ie n \{\ -\h'-04'\(bu\h'+03'\c -.\} -.el \{\ .IP \(bu 4 -.\} DesktopEnvironment -.RE -.RS 4 -.ie n \{\ -\h'-04'\(bu\h'+03'\c -.\} -.el \{\ .IP \(bu 4 -.\} WindowManager -.RE -.RS 4 -.ie n \{\ -\h'-04'\(bu\h'+03'\c -.\} -.el \{\ .IP \(bu 4 -.\} Packages -.RE -.RS 4 -.ie n \{\ -\h'-04'\(bu\h'+03'\c -.\} -.el \{\ .IP \(bu 4 -.\} Shell -.RE -.RS 4 -.ie n \{\ -\h'-04'\(bu\h'+03'\c -.\} -.el \{\ .IP \(bu 4 -.\} Terminal -.RE -.RS 4 -.ie n \{\ -\h'-04'\(bu\h'+03'\c -.\} -.el \{\ .IP \(bu 4 -.\} LocalIP -.RE -.RS 4 -.ie n \{\ -\h'-04'\(bu\h'+03'\c -.\} -.el \{\ .IP \(bu 4 -.\} Backlight -.RE -.RS 4 -.ie n \{\ -\h'-04'\(bu\h'+03'\c -.\} -.el \{\ .IP \(bu 4 -.\} Resolution -.RE -.RS 4 -.ie n \{\ -\h'-04'\(bu\h'+03'\c -.\} -.el \{\ .IP \(bu 4 -.\} Uptime -.RE -.RS 4 -.ie n \{\ -\h'-04'\(bu\h'+03'\c -.\} -.el \{\ .IP \(bu 4 -.\} Processor -.RE -.RS 4 -.ie n \{\ -\h'-04'\(bu\h'+03'\c -.\} -.el \{\ .IP \(bu 4 -.\} ProcessorLoad -.RE -.RS 4 -.ie n \{\ -\h'-04'\(bu\h'+03'\c -.\} -.el \{\ .IP \(bu 4 -.\} Memory -.RE -.RS 4 -.ie n \{\ -\h'-04'\(bu\h'+03'\c -.\} -.el \{\ .IP \(bu 4 -.\} Battery -.RE -.RS 4 -.ie n \{\ -\h'-04'\(bu\h'+03'\c -.\} -.el \{\ .IP \(bu 4 -.\} GPU -.RE -.RS 4 -.ie n \{\ -\h'-04'\(bu\h'+03'\c -.\} -.el \{\ .IP \(bu 4 -.\} DiskSpace - -.RE -.P +.PD +.PP .RE \fB--ascii-artists\fR .RS 4 Lists the original artists of the ASCII art used by macchina.\& -.P +.PP .RE .SH SEE ALSO -.P +.PP macchina(7) -.P +.PP .SH AUTHORS -.P +.PP Written and maintained by the Macchina-CLI team: -.RS 4 -.ie n \{\ -\h'-04'\(bu\h'+03'\c -.\} -.el \{\ +.PD 0 .IP \(bu 4 -.\} Taha Aziz Ben Ali -.RE -.RS 4 -.ie n \{\ -\h'-04'\(bu\h'+03'\c -.\} -.el \{\ .IP \(bu 4 -.\} Uttarayan Mondal -.RE -.RS 4 -.ie n \{\ -\h'-04'\(bu\h'+03'\c -.\} -.el \{\ .IP \(bu 4 -.\} Marvin Haschker - -.RE -.P +.PD +.PP .SH RESOURCES -.P +.PP This project is hosted at \fBhttps://github.\&com/Macchina-CLI/macchina\fR.\& diff --git a/doc/macchina.1.scd b/doc/macchina.1.scd index c9d97ea..2476d52 100644 --- a/doc/macchina.1.scd +++ b/doc/macchina.1.scd @@ -58,6 +58,9 @@ on performance. *-m, --memory-percentage* Show memory usage in percentage +*-D, --disks* + Specify the disks for which the usage percentage will be shown + *-p, --disk-space-percentage* Show disk space usage in percentage diff --git a/macchina.toml b/macchina.toml index fd871c3..4ff4253 100644 --- a/macchina.toml +++ b/macchina.toml @@ -17,6 +17,12 @@ current_shell = true # processor. physical_cores = true +# Disks to show disk usage for. Defaults to `["/"]`. +# disks = ["/", "/home/user"] + +# Show percentage next to disk usage +# disk_usage = true + # Themes need to be placed in "$XDG_CONFIG_DIR/macchina/themes" beforehand. # e.g.: # if theme path is /home/foo/.config/macchina/themes/Sodium.toml diff --git a/src/cli.rs b/src/cli.rs index 431b6bd..44c02ac 100644 --- a/src/cli.rs +++ b/src/cli.rs @@ -56,6 +56,16 @@ pub struct Opt { )] pub disk_space_percentage: bool, + #[clap( + short = 'D', + long = "disks", + use_value_delimiter = true, + value_delimiter = ',', + help = "Comma separated list of disk(s) to show disk space readout for, e.g. +'/,/home/user/'" + )] + pub disks: Option>, + #[clap( short = 'C', long = "physical-cores", @@ -165,6 +175,10 @@ impl Opt { if args.interface.is_some() { self.interface = args.interface; } + + if args.disks.is_some() { + self.disks = args.disks + } } pub fn get_options() -> Opt { diff --git a/src/data/mod.rs b/src/data/mod.rs index f1af199..882a57e 100644 --- a/src/data/mod.rs +++ b/src/data/mod.rs @@ -9,6 +9,7 @@ use ratatui::text::{Line, Span, Text}; use serde::{Deserialize, Serialize}; use std::borrow::Cow; use std::fmt::Display; +use std::path::PathBuf; /// This enum contains all the possible keys, e.g. _Host_, _Machine_, _Kernel_, etc. #[allow(clippy::upper_case_acronyms)] @@ -518,18 +519,25 @@ fn handle_readout_disk_space( ) { use crate::format::disk_space as format_disk_space; - match general_readout.disk_space() { - Ok((used, total)) => { - if theme.get_bar().is_visible() { - let bar = create_bar(theme, crate::bars::usage(used, total)); - readout_values.push(Readout::new(ReadoutKey::DiskSpace, bar)) - } else { - readout_values.push(Readout::new( - ReadoutKey::DiskSpace, - format_disk_space(used, total, opt.disk_space_percentage), - )) + let Some(disks) = opt.disks.to_owned() else { + return; + }; + + for disk in disks { + let disk_path = PathBuf::from(disk); + match general_readout.disk_space(&disk_path) { + Ok((used, total)) => { + if theme.get_bar().is_visible() { + let bar = create_bar(theme, crate::bars::usage(used, total)); + readout_values.push(Readout::new(ReadoutKey::DiskSpace, bar)) + } else { + readout_values.push(Readout::new( + ReadoutKey::DiskSpace, + format_disk_space(used, total, opt.disk_space_percentage), + )) + } } + Err(e) => readout_values.push(Readout::new_err(ReadoutKey::DiskSpace, e)), } - Err(e) => readout_values.push(Readout::new_err(ReadoutKey::DiskSpace, e)), } }