From 10e5b24f9fd41211af8c46dfd863cfccda24951c Mon Sep 17 00:00:00 2001 From: Caleb Bassi Date: Fri, 19 Jul 2019 17:36:20 -0700 Subject: [PATCH] Initial commit --- .github/ISSUE_TEMPLATE/bug_report.md | 23 + .github/ISSUE_TEMPLATE/other.md | 4 + .gitignore | 2 + .travis.yml | 29 ++ CHANGELOG.md | 16 + Cargo.lock | 734 +++++++++++++++++++++++++++ Cargo.toml | 23 + LICENSE | 19 + README.md | 72 +++ ci/script.sh | 11 + colorschemes/default-dark.json | 21 + colorschemes/default.json | 21 + colorschemes/monokai.json | 21 + colorschemes/solarized-dark.json | 21 + colorschemes/vice.json | 21 + src/args.rs | 76 +++ src/colorscheme.rs | 25 + src/main.rs | 237 +++++++++ src/utils/conversions.rs | 7 + src/utils/mod.rs | 1 + src/widgets/battery.rs | 27 + src/widgets/block.rs | 8 + src/widgets/cpu.rs | 101 ++++ src/widgets/disk.rs | 27 + src/widgets/help_menu.rs | 21 + src/widgets/mem.rs | 27 + src/widgets/mod.rs | 20 + src/widgets/net.rs | 27 + src/widgets/proc.rs | 27 + src/widgets/statusbar.rs | 21 + src/widgets/temp.rs | 27 + 31 files changed, 1717 insertions(+) create mode 100644 .github/ISSUE_TEMPLATE/bug_report.md create mode 100644 .github/ISSUE_TEMPLATE/other.md create mode 100644 .gitignore create mode 100644 .travis.yml create mode 100644 CHANGELOG.md create mode 100644 Cargo.lock create mode 100644 Cargo.toml create mode 100644 LICENSE create mode 100644 README.md create mode 100755 ci/script.sh create mode 100644 colorschemes/default-dark.json create mode 100644 colorschemes/default.json create mode 100644 colorschemes/monokai.json create mode 100644 colorschemes/solarized-dark.json create mode 100644 colorschemes/vice.json create mode 100644 src/args.rs create mode 100644 src/colorscheme.rs create mode 100644 src/main.rs create mode 100644 src/utils/conversions.rs create mode 100644 src/utils/mod.rs create mode 100644 src/widgets/battery.rs create mode 100644 src/widgets/block.rs create mode 100644 src/widgets/cpu.rs create mode 100644 src/widgets/disk.rs create mode 100644 src/widgets/help_menu.rs create mode 100644 src/widgets/mem.rs create mode 100644 src/widgets/mod.rs create mode 100644 src/widgets/net.rs create mode 100644 src/widgets/proc.rs create mode 100644 src/widgets/statusbar.rs create mode 100644 src/widgets/temp.rs diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md new file mode 100644 index 0000000..88aa507 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -0,0 +1,23 @@ +--- +name: Bug report +about: Template to report bugs. +--- + + + +Required information: + +- rtop version (`rtop -V`): +- The output of `uname -a`: + +Include any of the following information if relevant: + +- Terminal emulator (e.g. iTerm or gnome terminal): +- tmux version (`tmux -V`): +- Any relevenat hardware info: + +Please copy or attach `~/.local/state/rtop/errors.log` if it exists and contains logs: diff --git a/.github/ISSUE_TEMPLATE/other.md b/.github/ISSUE_TEMPLATE/other.md new file mode 100644 index 0000000..3edfbb4 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/other.md @@ -0,0 +1,4 @@ +--- +name: Other +about: No template. +--- diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..53eaa21 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +/target +**/*.rs.bk diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..f58d58d --- /dev/null +++ b/.travis.yml @@ -0,0 +1,29 @@ +language: rust + +cache: cargo + +git: + depth: 1 + +matrix: + include: + - env: TARGET=x86_64-unknown-linux-gnu + os: linux + +install: true +script: ./ci/script.sh + +deploy: + provider: releases + api_key: $GITHUB_TOKEN + file_glob: true + file: "./*.tar.gz" + skip_cleanup: true + on: + tags: true + +if: tag IS present + +notifications: + email: + on_success: never diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..dddccc6 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,16 @@ +# Changelog +All notable changes to this project will be documented in this file. + +The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), +and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). + +> **Types of changes**: +> +> - **Added**: for new features. +> - **Changed**: for changes in existing functionality. +> - **Deprecated**: for soon-to-be removed features. +> - **Removed**: for now removed features. +> - **Fixed**: for any bug fixes. +> - **Security**: in case of vulnerabilities. + +## [Unreleased] diff --git a/Cargo.lock b/Cargo.lock new file mode 100644 index 0000000..65014f4 --- /dev/null +++ b/Cargo.lock @@ -0,0 +1,734 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +[[package]] +name = "ansi_term" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "argon2rs" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "blake2-rfc 0.2.18 (registry+https://github.com/rust-lang/crates.io-index)", + "scoped_threadpool 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "arrayvec" +version = "0.4.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "nodrop 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "atty" +version = "0.2.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", + "termion 1.5.1 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "autocfg" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "backtrace" +version = "0.3.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "autocfg 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", + "backtrace-sys 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)", + "cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc-demangle 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "backtrace-sys" +version = "0.1.28" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "cc 1.0.34 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "bitflags" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "blake2-rfc" +version = "0.2.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "arrayvec 0.4.10 (registry+https://github.com/rust-lang/crates.io-index)", + "constant_time_eq 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "cassowary" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "cc" +version = "1.0.34" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "cfg-if" +version = "0.1.9" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "chrono" +version = "0.4.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", + "num-integer 0.1.41 (registry+https://github.com/rust-lang/crates.io-index)", + "num-traits 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", + "time 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "clap" +version = "2.33.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "ansi_term 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", + "atty 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", + "bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", + "strsim 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", + "textwrap 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", + "unicode-width 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", + "vec_map 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "cloudabi" +version = "0.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "constant_time_eq" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "crossbeam-channel" +version = "0.3.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "crossbeam-utils 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", + "smallvec 0.6.9 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "crossbeam-utils" +version = "0.6.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", + "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "crossterm" +version = "0.9.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "crossterm_cursor 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", + "crossterm_input 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", + "crossterm_screen 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", + "crossterm_style 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", + "crossterm_terminal 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", + "crossterm_utils 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "crossterm_cursor" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "crossterm_utils 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", + "crossterm_winapi 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "crossterm_input" +version = "0.3.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "crossterm_screen 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", + "crossterm_utils 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", + "crossterm_winapi 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "crossterm_screen" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "crossterm_utils 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", + "crossterm_winapi 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "crossterm_style" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "crossterm_utils 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", + "crossterm_winapi 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "crossterm_terminal" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "crossterm_cursor 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", + "crossterm_utils 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", + "crossterm_winapi 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "crossterm_utils" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "crossterm_winapi 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "crossterm_winapi" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "dirs" +version = "2.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", + "dirs-sys 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "dirs-sys" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", + "redox_users 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "either" +version = "1.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "failure" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "backtrace 0.3.15 (registry+https://github.com/rust-lang/crates.io-index)", + "failure_derive 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "failure_derive" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.39 (registry+https://github.com/rust-lang/crates.io-index)", + "synstructure 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "fern" +version = "0.5.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "fuchsia-cprng" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "heck" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "unicode-segmentation 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "itertools" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "either 1.5.2 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "itoa" +version = "0.4.4" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "lazy_static" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "libc" +version = "0.2.60" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "log" +version = "0.4.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "nodrop" +version = "0.1.13" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "num-integer" +version = "0.1.41" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "autocfg 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", + "num-traits 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "num-traits" +version = "0.2.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "autocfg 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "num_cpus" +version = "1.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "platform-dirs" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "dirs 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "proc-macro2" +version = "0.4.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "psutil" +version = "1.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "quote" +version = "0.6.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "rand_core" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "rand_core 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "rand_core" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "rand_os" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "cloudabi 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)", + "fuchsia-cprng 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", + "rand_core 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rdrand 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "rdrand" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "rand_core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "redox_syscall" +version = "0.1.53" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "redox_termios" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "redox_syscall 0.1.53 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "redox_users" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "argon2rs 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)", + "failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", + "rand_os 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", + "redox_syscall 0.1.53 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "rtop" +version = "0.1.0" +dependencies = [ + "chrono 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", + "crossbeam-channel 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", + "crossterm 0.9.6 (registry+https://github.com/rust-lang/crates.io-index)", + "fern 0.5.8 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", + "num_cpus 1.10.1 (registry+https://github.com/rust-lang/crates.io-index)", + "platform-dirs 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "psutil 1.6.0 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_json 1.0.40 (registry+https://github.com/rust-lang/crates.io-index)", + "size 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", + "structopt 0.2.18 (registry+https://github.com/rust-lang/crates.io-index)", + "tui 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "rustc-demangle" +version = "0.1.13" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "ryu" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "scoped_threadpool" +version = "0.1.9" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "serde" +version = "1.0.97" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "serde_derive 1.0.92 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "serde_derive" +version = "1.0.92" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.39 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "serde_json" +version = "1.0.40" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "itoa 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)", + "ryu 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "size" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "num-traits 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "smallvec" +version = "0.6.9" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "strsim" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "structopt" +version = "0.2.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "clap 2.33.0 (registry+https://github.com/rust-lang/crates.io-index)", + "structopt-derive 0.2.18 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "structopt-derive" +version = "0.2.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "heck 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.39 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "syn" +version = "0.15.39" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)", + "unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "synstructure" +version = "0.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.39 (registry+https://github.com/rust-lang/crates.io-index)", + "unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "termion" +version = "1.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", + "redox_syscall 0.1.53 (registry+https://github.com/rust-lang/crates.io-index)", + "redox_termios 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "textwrap" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "unicode-width 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "time" +version = "0.1.42" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", + "redox_syscall 0.1.53 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "tui" +version = "0.6.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", + "cassowary 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "crossterm 0.9.6 (registry+https://github.com/rust-lang/crates.io-index)", + "either 1.5.2 (registry+https://github.com/rust-lang/crates.io-index)", + "itertools 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", + "termion 1.5.1 (registry+https://github.com/rust-lang/crates.io-index)", + "unicode-segmentation 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", + "unicode-width 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "unicode-segmentation" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "unicode-width" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "unicode-xid" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "vec_map" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "winapi" +version = "0.3.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "winapi-i686-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi-x86_64-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "winapi-i686-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "winapi-x86_64-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[metadata] +"checksum ansi_term 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ee49baf6cb617b853aa8d93bf420db2383fab46d314482ca2803b40d5fde979b" +"checksum argon2rs 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)" = "3f67b0b6a86dae6e67ff4ca2b6201396074996379fba2b92ff649126f37cb392" +"checksum arrayvec 0.4.10 (registry+https://github.com/rust-lang/crates.io-index)" = "92c7fb76bc8826a8b33b4ee5bb07a247a81e76764ab4d55e8f73e3a4d8808c71" +"checksum atty 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)" = "9a7d5b8723950951411ee34d271d99dddcc2035a16ab25310ea2c8cfd4369652" +"checksum autocfg 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "0e49efa51329a5fd37e7c79db4621af617cd4e3e5bc224939808d076077077bf" +"checksum backtrace 0.3.15 (registry+https://github.com/rust-lang/crates.io-index)" = "f106c02a3604afcdc0df5d36cc47b44b55917dbaf3d808f71c163a0ddba64637" +"checksum backtrace-sys 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)" = "797c830ac25ccc92a7f8a7b9862bde440715531514594a6154e3d4a54dd769b6" +"checksum bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "228047a76f468627ca71776ecdebd732a3423081fcf5125585bcd7c49886ce12" +"checksum blake2-rfc 0.2.18 (registry+https://github.com/rust-lang/crates.io-index)" = "5d6d530bdd2d52966a6d03b7a964add7ae1a288d25214066fd4b600f0f796400" +"checksum cassowary 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "df8670b8c7b9dae1793364eafadf7239c40d669904660c5960d74cfd80b46a53" +"checksum cc 1.0.34 (registry+https://github.com/rust-lang/crates.io-index)" = "30f813bf45048a18eda9190fd3c6b78644146056740c43172a5a3699118588fd" +"checksum cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)" = "b486ce3ccf7ffd79fdeb678eac06a9e6c09fc88d33836340becb8fffe87c5e33" +"checksum chrono 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)" = "77d81f58b7301084de3b958691458a53c3f7e0b1d702f77e550b6a88e3a88abe" +"checksum clap 2.33.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5067f5bb2d80ef5d68b4c87db81601f0b75bca627bc2ef76b141d7b846a3c6d9" +"checksum cloudabi 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "ddfc5b9aa5d4507acaf872de71051dfd0e309860e88966e1051e462a077aac4f" +"checksum constant_time_eq 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "8ff012e225ce166d4422e0e78419d901719760f62ae2b7969ca6b564d1b54a9e" +"checksum crossbeam-channel 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)" = "0f0ed1a4de2235cabda8558ff5840bffb97fcb64c97827f354a451307df5f72b" +"checksum crossbeam-utils 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)" = "f8306fcef4a7b563b76b7dd949ca48f52bc1141aa067d2ea09565f3e2652aa5c" +"checksum crossterm 0.9.6 (registry+https://github.com/rust-lang/crates.io-index)" = "21ac79357981b3c35917a377e6138729b66316db7649f9f96fbb517bb02361e5" +"checksum crossterm_cursor 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)" = "4b8ddb43937bfafbe07d349ee9497754ceac818ee872116afccb076f2de28d3d" +"checksum crossterm_input 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)" = "a23a71b51ddc8f74e13e341179b1a26b20f0030d14ff8fbdd9da45fd0e342bc5" +"checksum crossterm_screen 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "90889b9f1d7867a583dede34deab1e32a10379e9eb70d920ca7895e144aa6d65" +"checksum crossterm_style 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "983596405fe738aac9645656b666073fe6e0a8bf088679b7e256916ee41b61f7" +"checksum crossterm_terminal 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)" = "18792c97c5cdcc5fd3582df58188a793bf290af4a53d5fc8442c7d17e003b356" +"checksum crossterm_utils 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "8321d40908d0ee77cb29335f591eae2b4f7225152f81b9dfa35a161ca3b077dc" +"checksum crossterm_winapi 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "8c061e4a1c47a53952ba0f2396c00a61cd7ab74482eba99b9c9cc77fdca71932" +"checksum dirs 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "1c4ef5a8b902d393339e2a2c7fe573af92ce7e0ee5a3ff827b4c9ad7e07e4fa1" +"checksum dirs-sys 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "937756392ec77d1f2dd9dc3ac9d69867d109a2121479d72c364e42f4cab21e2d" +"checksum either 1.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "5527cfe0d098f36e3f8839852688e63c8fff1c90b2b405aef730615f9a7bcf7b" +"checksum failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "795bd83d3abeb9220f257e597aa0080a508b27533824adf336529648f6abf7e2" +"checksum failure_derive 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "ea1063915fd7ef4309e222a5a07cf9c319fb9c7836b1f89b85458672dbb127e1" +"checksum fern 0.5.8 (registry+https://github.com/rust-lang/crates.io-index)" = "29d26fa0f4d433d1956746e66ec10d6bf4d6c8b93cd39965cceea7f7cc78c7dd" +"checksum fuchsia-cprng 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "a06f77d526c1a601b7c4cdd98f54b5eaabffc14d5f2f0296febdc7f357c6d3ba" +"checksum heck 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "20564e78d53d2bb135c343b3f47714a56af2061f1c928fdb541dc7b9fdd94205" +"checksum itertools 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5b8467d9c1cebe26feb08c640139247fac215782d35371ade9a2136ed6085358" +"checksum itoa 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)" = "501266b7edd0174f8530248f87f99c88fbe60ca4ef3dd486835b8d8d53136f7f" +"checksum lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "bc5729f27f159ddd61f4df6228e827e86643d4d3e7c32183cb30a1c08f604a14" +"checksum libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)" = "d44e80633f007889c7eff624b709ab43c92d708caad982295768a7b13ca3b5eb" +"checksum log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)" = "c275b6ad54070ac2d665eef9197db647b32239c9d244bfb6f041a766d00da5b3" +"checksum nodrop 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)" = "2f9667ddcc6cc8a43afc9b7917599d7216aa09c463919ea32c59ed6cac8bc945" +"checksum num-integer 0.1.41 (registry+https://github.com/rust-lang/crates.io-index)" = "b85e541ef8255f6cf42bbfe4ef361305c6c135d10919ecc26126c4e5ae94bc09" +"checksum num-traits 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)" = "6ba9a427cfca2be13aa6f6403b0b7e7368fe982bfa16fccc450ce74c46cd9b32" +"checksum num_cpus 1.10.1 (registry+https://github.com/rust-lang/crates.io-index)" = "bcef43580c035376c0705c42792c294b66974abbfd2789b511784023f71f3273" +"checksum platform-dirs 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "f1e6f10c0c97e3d27b298374c2c67a057216c98e0a86c44df6bcd1f02bacbe38" +"checksum proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)" = "cf3d2011ab5c909338f7887f4fc896d35932e29146c12c8d01da6b22a80ba759" +"checksum psutil 1.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "058b89e486972f8b5baa07b2039dfaba5151a8282790b25a2e6b4eb8fe4e1564" +"checksum quote 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)" = "6ce23b6b870e8f94f81fb0a363d65d86675884b34a09043c81e5562f11c1f8e1" +"checksum rand_core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7a6fdeb83b075e8266dcc8762c22776f6877a63111121f5f8c7411e5be7eed4b" +"checksum rand_core 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d0e7a549d590831370895ab7ba4ea0c1b6b011d106b5ff2da6eee112615e6dc0" +"checksum rand_os 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "7b75f676a1e053fc562eafbb47838d67c84801e38fc1ba459e8f180deabd5071" +"checksum rdrand 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "678054eb77286b51581ba43620cc911abf02758c91f93f479767aed0f90458b2" +"checksum redox_syscall 0.1.53 (registry+https://github.com/rust-lang/crates.io-index)" = "53848511b7ee6eb9d5c3db48481aaa5779b38fc0131bc133c98cb4f2b2411928" +"checksum redox_termios 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7e891cfe48e9100a70a3b6eb652fef28920c117d366339687bd5576160db0f76" +"checksum redox_users 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3fe5204c3a17e97dde73f285d49be585df59ed84b50a872baf416e73b62c3828" +"checksum rustc-demangle 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)" = "adacaae16d02b6ec37fdc7acfcddf365978de76d1983d3ee22afc260e1ca9619" +"checksum ryu 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "c92464b447c0ee8c4fb3824ecc8383b81717b9f1e74ba2e72540aef7b9f82997" +"checksum scoped_threadpool 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)" = "1d51f5df5af43ab3f1360b429fa5e0152ac5ce8c0bd6485cae490332e96846a8" +"checksum serde 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)" = "d46b3dfedb19360a74316866cef04687cd4d6a70df8e6a506c63512790769b72" +"checksum serde_derive 1.0.92 (registry+https://github.com/rust-lang/crates.io-index)" = "46a3223d0c9ba936b61c0d2e3e559e3217dbfb8d65d06d26e8b3c25de38bae3e" +"checksum serde_json 1.0.40 (registry+https://github.com/rust-lang/crates.io-index)" = "051c49229f282f7c6f3813f8286cc1e3323e8051823fce42c7ea80fe13521704" +"checksum size 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "3e5021178e8e70579d009fb545932e274ec2dde4c917791c6063d1002bee2a56" +"checksum smallvec 0.6.9 (registry+https://github.com/rust-lang/crates.io-index)" = "c4488ae950c49d403731982257768f48fada354a5203fe81f9bb6f43ca9002be" +"checksum strsim 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "8ea5119cdb4c55b55d432abb513a0429384878c15dde60cc77b1c99de1a95a6a" +"checksum structopt 0.2.18 (registry+https://github.com/rust-lang/crates.io-index)" = "16c2cdbf9cc375f15d1b4141bc48aeef444806655cd0e904207edc8d68d86ed7" +"checksum structopt-derive 0.2.18 (registry+https://github.com/rust-lang/crates.io-index)" = "53010261a84b37689f9ed7d395165029f9cc7abb9f56bbfe86bee2597ed25107" +"checksum syn 0.15.39 (registry+https://github.com/rust-lang/crates.io-index)" = "b4d960b829a55e56db167e861ddb43602c003c7be0bee1d345021703fac2fb7c" +"checksum synstructure 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)" = "73687139bf99285483c96ac0add482c3776528beac1d97d444f6e91f203a2015" +"checksum termion 1.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "689a3bdfaab439fd92bc87df5c4c78417d3cbe537487274e9b0b2dce76e92096" +"checksum textwrap 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d326610f408c7a4eb6f51c37c330e496b08506c9457c9d34287ecc38809fb060" +"checksum time 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)" = "db8dcfca086c1143c9270ac42a2bbd8a7ee477b78ac8e45b19abfb0cbede4b6f" +"checksum tui 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)" = "73b422ff4986065d33272b587907654f918a3fe8702786a8110bf68dede0d8ee" +"checksum unicode-segmentation 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "aa6024fc12ddfd1c6dbc14a80fa2324d4568849869b779f6bd37e5e4c03344d1" +"checksum unicode-width 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "882386231c45df4700b275c7ff55b6f3698780a650026380e72dabe76fa46526" +"checksum unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "fc72304796d0818e357ead4e000d19c9c174ab23dc11093ac919054d20a6a7fc" +"checksum vec_map 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "05c78687fb1a80548ae3250346c3db86a80a7cdd77bda190189f2d0a0987c81a" +"checksum winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)" = "f10e386af2b13e47c89e7236a7a14a086791a2b88ebad6df9bf42040195cf770" +"checksum winapi-i686-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" +"checksum winapi-x86_64-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" diff --git a/Cargo.toml b/Cargo.toml new file mode 100644 index 0000000..0edb23a --- /dev/null +++ b/Cargo.toml @@ -0,0 +1,23 @@ +[package] +name = "rtop" +version = "0.1.0" +authors = ["Caleb Bassi "] +license = "MIT" +description = "A TUI system monitor written in Rust" +edition = "2018" + +[dependencies] +chrono = "0.4.7" +crossbeam-channel = "0.3" +crossterm = "0.9.6" +fern = "0.5.8" +log = "0.4.7" +num_cpus = "1.10.1" +platform-dirs = "0.2.0" +# psutil = { path = "../../other-projects/rust-psutil" } +psutil = "1.6.0" +size = "0.1.2" +structopt = "0.2.18" +tui = { version = "0.6.2", features = ["crossterm"] } +serde_json = "1.0.40" +serde = { version = "1.0.97", features = ["derive"] } diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..19b2d1f --- /dev/null +++ b/LICENSE @@ -0,0 +1,19 @@ +Copyright (c) 2019 Caleb Bassi + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/README.md b/README.md new file mode 100644 index 0000000..7d3506e --- /dev/null +++ b/README.md @@ -0,0 +1,72 @@ +# rtop + +
+ +*Another* TUI based resource monitor, this time in Rust! Currently a WIP. + +
+ +## Usage + +### Keybinds + +- Quit: `q` or `` +- Process navigation: + - `k` and ``: up + - `j` and ``: down + - ``: half page up + - ``: half page down + - ``: full page up + - ``: full page down + - `gg` and ``: jump to top + - `G` and ``: jump to bottom +- Process actions: + - ``: toggle process grouping + - `dd`: kill selected process or group of processes +- Process sorting: + - `c`: CPU + - `m`: Mem + - `p`: PID +- Process filtering: + - `/`: start editing filter + - (while editing): + - ``: accept filter + - `` and ``: clear filter +- CPU and Mem graph scaling: + - `h`: scale in + - `l`: scale out +- `?`: toggles keybind help menu + +### Mouse + +- click to select process +- mouse wheel to scroll through processes + +### Colorschemes + +rtop ships with a few colorschemes which can be set with the `-c` flag followed by the name of one. You can find all the colorschemes in the [colorschemes folder](./colorschemes). + +To make a custom colorscheme, copy one of the default ones to `~/.config/rtop/.json` and load it with `rtop -c `. Colorschemes PRs are welcome! + +### CLI Options + +``` +USAGE: + rtop [FLAGS] [OPTIONS] + +FLAGS: + -a, --average-cpu Show average CPU in the CPU widget. + -b, --battery Show Battery widget (overridden by 'minimal' flag). + -f, --fahrenheit Show temperatures in fahrenheit. + -h, --help Prints help information + -m, --minimal Only show the CPU, Mem, and Process widgets. + -p, --per-cpu Show each CPU in the CPU widget. + -s, --statusbar Show a statusbar with the time. + -V, --version Prints version information + +OPTIONS: + -c, --colorscheme Set a colorscheme. [default: default] + -i, --interfaces Comma separated list of network interfaces to show. Prepend an interface with '!' + to hide it. 'all' shows all interfaces. [default: !tun0] + -r, --rate Number of times per second to update the CPU and Mem widgets. [default: 1] +``` diff --git a/ci/script.sh b/ci/script.sh new file mode 100755 index 0000000..c5af644 --- /dev/null +++ b/ci/script.sh @@ -0,0 +1,11 @@ +#!/usr/bin/env bash + +NAME=${TRAVIS_REPO_SLUG#*/} + +function main { + rustup target add $TARGET + cargo build --target $TARGET --release + tar -czf $NAME-$TRAVIS_TAG-$TARGET.tar.gz -C ./target/$TARGET/release/ $NAME +} + +main diff --git a/colorschemes/default-dark.json b/colorschemes/default-dark.json new file mode 100644 index 0000000..a43795c --- /dev/null +++ b/colorschemes/default-dark.json @@ -0,0 +1,21 @@ +{ + "fg": 235, + "bg": -1, + + "titles": 235, + "borders": 6, + + "battery_lines": [4, 3, 2, 1, 5, 6, 7, 8], + + "cpu_lines": [4, 3, 2, 1, 5, 6, 7, 8], + + "mem_main": 5, + "mem_swap": 3, + + "net_bars": 4, + + "proc_cursor": 33, + + "temp_low": 2, + "temp_high": 1 +} diff --git a/colorschemes/default.json b/colorschemes/default.json new file mode 100644 index 0000000..651240f --- /dev/null +++ b/colorschemes/default.json @@ -0,0 +1,21 @@ +{ + "fg": 7, + "bg": -1, + + "titles": 7, + "borders": 6, + + "battery_lines": [4, 3, 2, 1, 5, 6, 7, 8], + + "cpu_lines": [4, 3, 2, 1, 5, 6, 7, 8], + + "mem_main": 5, + "mem_swap": 11, + + "net_bars": 4, + + "proc_cursor": 4, + + "temp_low": 2, + "temp_high": 1 +} diff --git a/colorschemes/monokai.json b/colorschemes/monokai.json new file mode 100644 index 0000000..a4a5732 --- /dev/null +++ b/colorschemes/monokai.json @@ -0,0 +1,21 @@ +{ + "fg": 249, + "bg": -1, + + "titles": 249, + "borders": 239, + + "battery_lines": [81, 70, 208, 197, 249, 141, 221, 186], + + "cpu_lines": [81, 70, 208, 197, 249, 141, 221, 186], + + "mem_main": 208, + "mem_swap": 186, + + "net_bars": 81, + + "proc_cursor": 197, + + "temp_low": 70, + "temp_high": 208 +} diff --git a/colorschemes/solarized-dark.json b/colorschemes/solarized-dark.json new file mode 100644 index 0000000..5cee066 --- /dev/null +++ b/colorschemes/solarized-dark.json @@ -0,0 +1,21 @@ +{ + "fg": 250, + "bg": -1, + + "titles": 250, + "borders": 37, + + "battery_lines": [61, 33, 37, 64, 125, 160, 166, 136], + + "cpu_lines": [61, 33, 37, 64, 125, 160, 166, 136], + + "mem_main": 125, + "mem_swap": 166, + + "net_bars": 33, + + "proc_cursor": 136, + + "temp_low": 64, + "temp_high": 160 +} diff --git a/colorschemes/vice.json b/colorschemes/vice.json new file mode 100644 index 0000000..e5cc620 --- /dev/null +++ b/colorschemes/vice.json @@ -0,0 +1,21 @@ +{ + "fg": 231, + "bg": -1, + + "titles": 123, + "borders": 102, + + "battery_lines": [212, 218, 123, 159, 229, 158, 183, 146], + + "cpu_lines": [212, 218, 123, 159, 229, 158, 183, 146], + + "mem_main": 201, + "mem_swap": 97, + + "net_bars": 183, + + "proc_cursor": 159, + + "temp_low": 49, + "temp_high": 197 +} diff --git a/src/args.rs b/src/args.rs new file mode 100644 index 0000000..a342612 --- /dev/null +++ b/src/args.rs @@ -0,0 +1,76 @@ +use std::str::FromStr; +use structopt::StructOpt; + +pub enum Colorscheme { + Default, + DefaultDark, + Monokai, + SolarizedDark, + Vice, + Custom(String), +} + +impl FromStr for Colorscheme { + type Err = std::io::Error; + + fn from_str(s: &str) -> Result { + Ok(match s { + "default" => Colorscheme::Default, + "default-dark" => Colorscheme::DefaultDark, + "monokai" => Colorscheme::Monokai, + "solarized-dark" => Colorscheme::SolarizedDark, + "vice" => Colorscheme::Vice, + _ => Colorscheme::Custom(s.to_string()), + }) + } +} + +#[derive(StructOpt)] +pub struct Args { + /// Set a colorscheme. + #[structopt( + short = "c", + long = "colorscheme", + default_value = "default", + long_help = r"Colorschemes: + - default + - default-dark (for white backgrounds) + - solarized-dark + - monokai + - vice +" + )] + pub colorscheme: Colorscheme, + + /// Only show the CPU, Mem, and Process widgets. + #[structopt(short = "m", long = "minimal")] + pub minimal: bool, + + /// Number of times per second to update the CPU and Mem widgets. + #[structopt(short = "r", long = "rate", default_value = "1")] + pub rate: f64, + + /// Show each CPU in the CPU widget. + #[structopt(short = "p", long = "per-cpu")] + pub per_cpu: bool, + + /// Show average CPU in the CPU widget. + #[structopt(short = "a", long = "average-cpu")] + pub average_cpu: bool, + + /// Show temperatures in fahrenheit. + #[structopt(short = "f", long = "fahrenheit")] + pub fahrenheit: bool, + + /// Show a statusbar with the time. + #[structopt(short = "s", long = "statusbar")] + pub statusbar: bool, + + /// Show Battery widget (overridden by 'minimal' flag). + #[structopt(short = "b", long = "battery")] + pub battery: bool, + + /// Comma separated list of network interfaces to show. Prepend an interface with '!' to hide it. 'all' shows all interfaces. + #[structopt(short = "i", long = "interfaces", default_value = "!tun0")] + pub interfaces: String, +} diff --git a/src/colorscheme.rs b/src/colorscheme.rs new file mode 100644 index 0000000..e9b1696 --- /dev/null +++ b/src/colorscheme.rs @@ -0,0 +1,25 @@ +use serde::Deserialize; + +#[derive(Deserialize)] +pub struct Colorscheme { + fg: i64, + bg: i64, + + titles: i64, + borders: i64, + + battery_lines: Vec, + + // need at least 8 entries + cpu_lines: Vec, + + mem_main: i64, + mem_swap: i64, + + net_bars: i64, + + proc_cursor: i64, + + temp_low: i64, + temp_high: i64, +} diff --git a/src/main.rs b/src/main.rs new file mode 100644 index 0000000..192ea38 --- /dev/null +++ b/src/main.rs @@ -0,0 +1,237 @@ +mod args; +mod colorscheme; +mod utils; +mod widgets; + +use std::fs; +use std::io; +use std::path::Path; +use std::thread; +use std::time::Duration; + +use crossbeam_channel::{select, tick, unbounded, Receiver}; +use crossterm::{AlternateScreen, InputEvent, KeyEvent, MouseEvent}; +use log::info; +use platform_dirs::{AppDirs, AppUI}; +use structopt::StructOpt; +use tui::backend::{Backend, CrosstermBackend}; +use tui::layout::{Constraint, Direction, Layout}; +use tui::widgets::Widget; +use tui::Terminal; + +use args::Args; + +struct Widgets { + battery_widget: Option, + cpu_widget: widgets::CpuWidget, + disk_widget: Option, + help_menu: widgets::HelpMenu, + mem_widget: widgets::MemWidget, + net_widget: Option, + proc_widget: widgets::ProcWidget, + statusbar: Option, + temp_widget: Option, +} + +fn setup_terminal() -> io::Result> { + let screen = AlternateScreen::to_alternate(true)?; + let backend = CrosstermBackend::with_alternate_screen(screen)?; + let mut terminal = Terminal::new(backend)?; + terminal.hide_cursor()?; + terminal.clear()?; + Ok(terminal) +} + +fn setup_ui_events() -> Receiver { + let (ui_events_sender, ui_events_receiver) = unbounded(); + thread::spawn(move || { + let _screen = crossterm::RawScreen::into_raw_mode().unwrap(); // TODO: unwrap + let input = crossterm::input(); + input.enable_mouse_mode().unwrap(); // TODO: unwrap + let mut reader = input.read_sync(); + loop { + ui_events_sender.send(reader.next().unwrap()).unwrap(); // TODO: unwraps + } + }); + ui_events_receiver +} + +fn setup_logfile(logfile_path: &Path) { + let logfile = fs::OpenOptions::new() + .write(true) + .create(true) + .truncate(true) + .open(logfile_path) + .unwrap(); // TODO: unwrap + fern::Dispatch::new() + .format(|out, message, record| { + out.finish(format_args!( + "{}[{}][{}]: {}", + chrono::Local::now().format("[%Y-%m-%d][%H:%M:%S]"), + record.target(), + record.level(), + message + )) + }) + .chain(logfile) + .apply() + .unwrap(); // TODO: unwrap +} + +fn read_colorscheme( + config_folder: &Path, + colorscheme: &args::Colorscheme, +) -> serde_json::Result { + match colorscheme { + args::Colorscheme::Custom(name) => serde_json::from_str( + &fs::read_to_string(config_folder.join(name).with_extension("json")).unwrap(), // TODO: unwrap + ), + _ => { + let json_string = match colorscheme { + args::Colorscheme::Default => include_str!("../colorschemes/default.json"), + args::Colorscheme::DefaultDark => include_str!("../colorschemes/default-dark.json"), + args::Colorscheme::SolarizedDark => { + include_str!("../colorschemes/solarized-dark.json") + } + args::Colorscheme::Monokai => include_str!("../colorschemes/monokai.json"), + args::Colorscheme::Vice => include_str!("../colorschemes/vice.json"), + _ => unreachable!(), + }; + Ok(serde_json::from_str(json_string).unwrap()) + } + } +} + +fn setup_widgets(args: &Args, colorscheme: &colorscheme::Colorscheme) -> Widgets { + let battery_widget = Some(widgets::BatteryWidget::new()); + let cpu_widget = widgets::CpuWidget::new(Duration::from_secs(1), true, true); + let disk_widget = Some(widgets::DiskWidget::new()); + let help_menu = widgets::HelpMenu::new(); + let mem_widget = widgets::MemWidget::new(Duration::from_secs(1)); + let net_widget = Some(widgets::NetWidget::new()); + let proc_widget = widgets::ProcWidget::new(); + let statusbar = Some(widgets::Statusbar::new()); + let temp_widget = Some(widgets::TempWidget::new()); + + Widgets { + battery_widget, + cpu_widget, + disk_widget, + help_menu, + mem_widget, + net_widget, + proc_widget, + statusbar, + temp_widget, + } +} + +fn update_widgets(widgets: &mut Widgets, ticks: i64) { + // if ticks % widgets.cpu_widget.update_interval == 0 { + // widgets.cpu_widget.update(); + // } +} + +fn draw(terminal: &mut Terminal, widgets: &mut Widgets) -> io::Result<()> { + terminal.draw(|mut frame| { + let vertical_chunks = Layout::default() + .direction(Direction::Vertical) + .constraints( + [ + Constraint::Ratio(1, 3), + Constraint::Ratio(1, 3), + Constraint::Ratio(1, 3), + ] + .as_ref(), + ) + .split(frame.size()); + widgets.cpu_widget.render(&mut frame, vertical_chunks[0]); + let middle_horizontal_chunks = Layout::default() + .direction(Direction::Horizontal) + .constraints([Constraint::Ratio(1, 3), Constraint::Ratio(2, 3)].as_ref()) + .split(vertical_chunks[1]); + widgets + .mem_widget + .render(&mut frame, middle_horizontal_chunks[1]); + let middle_left_vertical_chunks = Layout::default() + .direction(Direction::Vertical) + .constraints([Constraint::Ratio(1, 2), Constraint::Ratio(1, 2)].as_ref()) + .split(middle_horizontal_chunks[0]); + widgets + .disk_widget + .as_mut() + .unwrap() // TODO: unwrap + .render(&mut frame, middle_left_vertical_chunks[0]); + widgets + .temp_widget + .as_mut() + .unwrap() // TODO: unwrap + .render(&mut frame, middle_left_vertical_chunks[1]); + let bottom_horizontal_chunks = Layout::default() + .direction(Direction::Horizontal) + .constraints([Constraint::Ratio(1, 2), Constraint::Ratio(1, 2)].as_ref()) + .split(vertical_chunks[2]); + widgets + .net_widget + .as_mut() + .unwrap() // TODO: unwrap + .render(&mut frame, bottom_horizontal_chunks[0]); + widgets + .proc_widget + .render(&mut frame, bottom_horizontal_chunks[1]); + }) +} + +fn main() { + let args = Args::from_args(); + + let program_name = env!("CARGO_PKG_NAME"); + let app_dirs = AppDirs::new(Some(program_name), AppUI::CommandLine).unwrap(); // TODO: unwrap + let logfile_path = app_dirs.state_dir.join("errors.log"); + + let colorscheme = read_colorscheme(&app_dirs.config_dir, &args.colorscheme).unwrap(); // TODO: unwrap + let mut widgets = setup_widgets(&args, &colorscheme); + + setup_logfile(&logfile_path); + let mut terminal = setup_terminal().unwrap(); // TODO: unwrap + + let ticker = tick(Duration::from_secs(1)); + let ui_events_receiver = setup_ui_events(); + + let mut ticks = 0; + update_widgets(&mut widgets, ticks); + draw(&mut terminal, &mut widgets).unwrap(); // TODO: unwrap + + info!("hello"); + + loop { + select! { + recv(ticker) -> _ => { + ticks = (ticks + 1) % 60; + update_widgets(&mut widgets, ticks); + draw(&mut terminal, &mut widgets).unwrap(); // TODO: unwrap + } + recv(ui_events_receiver) -> message => { + match message.unwrap() { // TODO: unwrap + InputEvent::Keyboard(key_event) => { + match key_event { + KeyEvent::Char(c) => match c { + 'q' => break, + _ => { info!("hello");} + }, + KeyEvent::Ctrl(c) => match c { + 'c' => break, + _ => {}, + }, + _ => {} + } + } + InputEvent::Mouse(mouse_event) => match mouse_event { + _ => {} + } + _ => {} + } + } + } + } +} diff --git a/src/utils/conversions.rs b/src/utils/conversions.rs new file mode 100644 index 0000000..b9f9e30 --- /dev/null +++ b/src/utils/conversions.rs @@ -0,0 +1,7 @@ +pub fn convert_localized_string(s: &str) -> String { + s.replace(',', ".") +} + +pub fn celsius_to_fahrenheit(c: i64) -> i64 { + (c as f64 * (9f64 / 5f64)) as i64 + 32 +} diff --git a/src/utils/mod.rs b/src/utils/mod.rs new file mode 100644 index 0000000..4974d5c --- /dev/null +++ b/src/utils/mod.rs @@ -0,0 +1 @@ +pub mod conversions; diff --git a/src/widgets/battery.rs b/src/widgets/battery.rs new file mode 100644 index 0000000..9a49cee --- /dev/null +++ b/src/widgets/battery.rs @@ -0,0 +1,27 @@ +use std::time::Duration; + +use tui::buffer::Buffer; +use tui::layout::Rect; +use tui::widgets::Widget; + +use crate::widgets::block; + +pub struct BatteryWidget { + title: String, + update_interval: Duration, +} + +impl BatteryWidget { + pub fn new() -> BatteryWidget { + BatteryWidget { + title: " Batteries ".to_string(), + update_interval: Duration::from_secs(60), + } + } +} + +impl Widget for BatteryWidget { + fn draw(&mut self, area: Rect, buf: &mut Buffer) { + block::new().title(&self.title).draw(area, buf); + } +} diff --git a/src/widgets/block.rs b/src/widgets/block.rs new file mode 100644 index 0000000..f926d6b --- /dev/null +++ b/src/widgets/block.rs @@ -0,0 +1,8 @@ +use tui::style::{Color, Style}; +use tui::widgets::{Block, Borders}; + +pub fn new() -> Block<'static> { + Block::default() + .borders(Borders::ALL) + .border_style(Style::default().fg(Color::Cyan)) +} diff --git a/src/widgets/cpu.rs b/src/widgets/cpu.rs new file mode 100644 index 0000000..a10e7f4 --- /dev/null +++ b/src/widgets/cpu.rs @@ -0,0 +1,101 @@ +use std::time::Duration; + +use tui::buffer::Buffer; +use tui::layout::Rect; +use tui::style::{Color, Style}; +use tui::widgets::{Axis, Chart, Dataset, Marker, Widget}; + +use crate::widgets::block; + +pub struct CpuWidget { + title: String, + update_interval: Duration, + + cpu_count: usize, + + show_average_cpu_load: bool, + show_per_cpu_load: bool, + + average_cpu_data: Vec, + per_cpu_data: Vec>, +} + +impl CpuWidget { + pub fn new( + update_interval: Duration, + show_average_cpu_load: bool, + show_per_cpu_load: bool, + ) -> CpuWidget { + let mut cpu_widget = CpuWidget { + title: " CPU Usage ".to_string(), + update_interval, + + cpu_count: num_cpus::get(), + + show_average_cpu_load, + show_per_cpu_load, + + average_cpu_data: Vec::new(), + per_cpu_data: Vec::new(), + }; + + if !(show_average_cpu_load || show_per_cpu_load) { + if cpu_widget.cpu_count <= 8 { + cpu_widget.show_per_cpu_load = true + } else { + cpu_widget.show_average_cpu_load = true + } + } + + cpu_widget + } + + pub fn update(&mut self) { + if self.show_average_cpu_load {} + if self.show_per_cpu_load {} + // let procs = sys.get_processor_list(); + // self.average_cpu_data.push(( + // self.len_data as f64, + // procs[0].get_cpu_usage() as f64 * 100.0, + // )); + // for (i, proc) in procs.iter().skip(1).enumerate() { + // self.per_cpu_data[i].push((self.len_data as f64, proc.get_cpu_usage() as f64 * 100.0)); + // } + // self.len_data += 1; + } +} + +impl Widget for CpuWidget { + fn draw(&mut self, area: Rect, buf: &mut Buffer) { + // let x_bounds = [self.len_data as f64 - 25.0, self.len_data as f64 - 1.0]; + // let mut datasets = vec![]; + // if self.average_cpu { + // datasets.push( + // Dataset::default() + // .name("AVRG") + // .marker(Marker::Braille) + // .style(Style::default().fg(Color::Yellow)) + // .data(&self.average_cpu_data[..]), + // ) + // } + // if self.per_cpu { + // for (i, cpu) in self.per_cpu_data.iter().enumerate() { + // datasets.push( + // Dataset::default() + // .name(&self.cpu_names[i]) + // .marker(Marker::Braille) + // .style(Style::default().fg(Color::Yellow)) + // .data(cpu), + // ) + // } + // } + + // let mut chart: Chart = Chart::default(); + block::new() + .title(&self.title) + // .x_axis(Axis::default().bounds(x_bounds)) + // .y_axis(Axis::default().bounds([0.0, 100.0])) + // .datasets(&datasets) + .draw(area, buf); + } +} diff --git a/src/widgets/disk.rs b/src/widgets/disk.rs new file mode 100644 index 0000000..c3ce8b3 --- /dev/null +++ b/src/widgets/disk.rs @@ -0,0 +1,27 @@ +use std::time::Duration; + +use tui::buffer::Buffer; +use tui::layout::Rect; +use tui::widgets::Widget; + +use crate::widgets::block; + +pub struct DiskWidget { + title: String, + update_interval: Duration, +} + +impl DiskWidget { + pub fn new() -> DiskWidget { + DiskWidget { + title: " Disk Usage ".to_string(), + update_interval: Duration::from_secs(1), + } + } +} + +impl Widget for DiskWidget { + fn draw(&mut self, area: Rect, buf: &mut Buffer) { + block::new().title(&self.title).draw(area, buf); + } +} diff --git a/src/widgets/help_menu.rs b/src/widgets/help_menu.rs new file mode 100644 index 0000000..494d4b6 --- /dev/null +++ b/src/widgets/help_menu.rs @@ -0,0 +1,21 @@ +use tui::buffer::Buffer; +use tui::layout::Rect; +use tui::widgets::Widget; + +use crate::widgets::block; + +const TITLE: &str = " Help Menu "; + +pub struct HelpMenu {} + +impl HelpMenu { + pub fn new() -> HelpMenu { + HelpMenu {} + } +} + +impl Widget for HelpMenu { + fn draw(&mut self, area: Rect, buf: &mut Buffer) { + block::new().title(TITLE).draw(area, buf); + } +} diff --git a/src/widgets/mem.rs b/src/widgets/mem.rs new file mode 100644 index 0000000..bfaf4a9 --- /dev/null +++ b/src/widgets/mem.rs @@ -0,0 +1,27 @@ +use std::time::Duration; + +use tui::buffer::Buffer; +use tui::layout::Rect; +use tui::widgets::Widget; + +use crate::widgets::block; + +pub struct MemWidget { + title: String, + update_interval: Duration, +} + +impl MemWidget { + pub fn new(update_interval: Duration) -> MemWidget { + MemWidget { + title: " Memory Usage ".to_string(), + update_interval, + } + } +} + +impl Widget for MemWidget { + fn draw(&mut self, area: Rect, buf: &mut Buffer) { + block::new().title(&self.title).draw(area, buf); + } +} diff --git a/src/widgets/mod.rs b/src/widgets/mod.rs new file mode 100644 index 0000000..6f5134d --- /dev/null +++ b/src/widgets/mod.rs @@ -0,0 +1,20 @@ +mod battery; +mod block; +mod cpu; +mod disk; +mod help_menu; +mod mem; +mod net; +mod proc; +mod statusbar; +mod temp; + +pub use self::battery::BatteryWidget; +pub use self::cpu::CpuWidget; +pub use self::disk::DiskWidget; +pub use self::help_menu::HelpMenu; +pub use self::mem::MemWidget; +pub use self::net::NetWidget; +pub use self::proc::ProcWidget; +pub use self::statusbar::Statusbar; +pub use self::temp::TempWidget; diff --git a/src/widgets/net.rs b/src/widgets/net.rs new file mode 100644 index 0000000..5e6af06 --- /dev/null +++ b/src/widgets/net.rs @@ -0,0 +1,27 @@ +use std::time::Duration; + +use tui::buffer::Buffer; +use tui::layout::Rect; +use tui::widgets::Widget; + +use crate::widgets::block; + +pub struct NetWidget { + title: String, + update_interval: Duration, +} + +impl NetWidget { + pub fn new() -> NetWidget { + NetWidget { + title: " Network Usage ".to_string(), + update_interval: Duration::from_secs(1), + } + } +} + +impl Widget for NetWidget { + fn draw(&mut self, area: Rect, buf: &mut Buffer) { + block::new().title(&self.title).draw(area, buf); + } +} diff --git a/src/widgets/proc.rs b/src/widgets/proc.rs new file mode 100644 index 0000000..df30a6a --- /dev/null +++ b/src/widgets/proc.rs @@ -0,0 +1,27 @@ +use std::time::Duration; + +use tui::buffer::Buffer; +use tui::layout::Rect; +use tui::widgets::Widget; + +use crate::widgets::block; + +pub struct ProcWidget { + title: String, + update_interval: Duration, +} + +impl ProcWidget { + pub fn new() -> ProcWidget { + ProcWidget { + title: " Processes ".to_string(), + update_interval: Duration::from_secs(1), + } + } +} + +impl Widget for ProcWidget { + fn draw(&mut self, area: Rect, buf: &mut Buffer) { + block::new().title(&self.title).draw(area, buf); + } +} diff --git a/src/widgets/statusbar.rs b/src/widgets/statusbar.rs new file mode 100644 index 0000000..005326d --- /dev/null +++ b/src/widgets/statusbar.rs @@ -0,0 +1,21 @@ +use std::time::Duration; + +use tui::buffer::Buffer; +use tui::layout::Rect; +use tui::widgets::Widget; + +use crate::widgets::block; + +pub struct Statusbar {} + +impl Statusbar { + pub fn new() -> Statusbar { + Statusbar {} + } +} + +impl Widget for Statusbar { + fn draw(&mut self, area: Rect, buf: &mut Buffer) { + block::new().draw(area, buf); + } +} diff --git a/src/widgets/temp.rs b/src/widgets/temp.rs new file mode 100644 index 0000000..ea1c990 --- /dev/null +++ b/src/widgets/temp.rs @@ -0,0 +1,27 @@ +use std::time::Duration; + +use tui::buffer::Buffer; +use tui::layout::Rect; +use tui::widgets::Widget; + +use crate::widgets::block; + +pub struct TempWidget { + title: String, + update_interval: Duration, +} + +impl TempWidget { + pub fn new() -> TempWidget { + TempWidget { + title: " Temperatures ".to_string(), + update_interval: Duration::from_secs(5), + } + } +} + +impl Widget for TempWidget { + fn draw(&mut self, area: Rect, buf: &mut Buffer) { + block::new().title(&self.title).draw(area, buf); + } +}