treefetch icon indicating copy to clipboard operation
treefetch copied to clipboard

macOS/Windows version of treefetch

Open angelofallars opened this issue 3 years ago • 3 comments

( Help wanted )

treefetch in its current state only supports Linux. Use Rust conditional compilation in the fields.rs file to write separate code for each OS; Windows and macOS. You may also modify the main.rs a bit if needed.

The fetch information you need to implement for either Windows or macOS are:

  • username / hostname
  • OS name
  • kernel (if applicable)
  • Shell name
  • Uptime
  • Memory usage

You can make a PR implementing only Windows or only macOS support for now if you want.

I suggest doing something like this:

#[cfg(target_os = "linux")]
pub fn get_memory() -> Result<String, String> {
    ...
}

#[cfg(target_os = "macos")]
pub fn get_memory() -> Result<String, String> {
    ...
}

#[cfg(target_os = "windows")]
pub fn get_memory() -> Result<String, String> {
    ...
}

angelofallars avatar Jan 16 '22 06:01 angelofallars

Check these two out: whoami sysinfo. They both support multiple platforms.

EdenQwQ avatar Jan 20 '22 08:01 EdenQwQ

Hi, I'm the author of systemstat, would you accept a PR that uses systemstat for uptime and memory and adds more things systemstat supports (such as battery percentage and disk usage)?

valpackett avatar Feb 12 '22 23:02 valpackett

Hi, I'm the author of systemstat, would you accept a PR that uses systemstat for uptime and memory and adds more things systemstat supports (such as battery percentage and disk usage)?

@unrelentingtech Sure! I'd love to see how you would implement this in treefetch.

angelofallars avatar Feb 12 '22 23:02 angelofallars