mirror of
https://github.com/ClementTsang/bottom
synced 2024-11-22 04:03:06 +00:00
Added dd command on linux.
This commit is contained in:
parent
1b777d27e5
commit
0550402698
6 changed files with 54 additions and 4 deletions
29
README.md
29
README.md
|
@ -4,6 +4,9 @@
|
|||
|
||||
A top clone, written in Rust. Inspired by both [gtop](https://github.com/aksakalli/gtop) and [gotop](https://github.com/cjbassi/gotop)
|
||||
|
||||
![Quick demo recording](assets/recording_1.gif)
|
||||
*Note that the background you see is not part of the app, that's just because I use a slightly transparent background*
|
||||
|
||||
## Installation
|
||||
|
||||
### Linux
|
||||
|
@ -18,6 +21,32 @@ TODO: Test
|
|||
|
||||
Currently, I'm unable to test on MacOS, so I'm not sure how well this will work, if at all. I'll try to source MacOS hardware to test this application.
|
||||
|
||||
## Usage
|
||||
|
||||
### Keybinds (some may not be available on certain operating systems)
|
||||
|
||||
#### General
|
||||
|
||||
* ``q``, ``Esc``, or ``Ctrl-C`` to quit
|
||||
|
||||
* ``Shift-Up/Shift-k``, ``Shift-Down/Shift-j``, ``Shift-Left/Shift-h``, ``Shift-Right/Shift-l`` to navigate between panels
|
||||
|
||||
#### Processes Panel
|
||||
|
||||
* ``dd`` to kill the selected process (currently only on Linux) - **I would highly recommend you to be careful using this, lest you accidentally kill the wrong process**.
|
||||
|
||||
* ``c`` to sort by CPU usage. Sorts in descending order by default. Press again to reverse sorting order.
|
||||
|
||||
* ``m`` to sort by memory usage. Sorts in descending order by default. Press again to reverse sorting order.
|
||||
|
||||
* ``p`` to sort by PID. Sorts in ascending order by default. Press again to reverse sorting order.
|
||||
|
||||
* ``n`` to sort by process name. Sorts in ascending order by default. Press again to reverse sorting order.
|
||||
|
||||
### Mouse Actions
|
||||
|
||||
* Scrolling either scrolls through the list if the panel is a table (Temperature, Disks, Processes), or zooms in and out if it is a chart
|
||||
|
||||
## Thanks
|
||||
|
||||
* As mentioned, this project is very much inspired by both [gotop](https://github.com/cjbassi/gotop) and [gtop](https://github.com/aksakalli/gtop) .
|
||||
|
|
4
TODO.md
4
TODO.md
|
@ -16,7 +16,7 @@
|
|||
|
||||
* Keybindings
|
||||
|
||||
* Legend gets in the way at too small of a height... maybe modify tui a bit more to fix this.
|
||||
~~* Legend gets in the way at too small of a height... maybe modify tui a bit more to fix this.~~
|
||||
|
||||
## After making public
|
||||
|
||||
|
@ -52,4 +52,4 @@
|
|||
|
||||
* Modularity
|
||||
|
||||
* Potentially process managing? Depends on the libraries...
|
||||
*~~Potentially process managing? Depends on the libraries...~~ Done on Linux!
|
||||
|
|
BIN
assets/recording_1.gif
Normal file
BIN
assets/recording_1.gif
Normal file
Binary file not shown.
After Width: | Height: | Size: 2.2 MiB |
21
src/app.rs
21
src/app.rs
|
@ -37,6 +37,7 @@ pub struct App {
|
|||
pub data : data_collection::Data,
|
||||
pub scroll_direction : ScrollDirection,
|
||||
pub previous_process_position : i64,
|
||||
awaiting_d : bool,
|
||||
}
|
||||
|
||||
impl App {
|
||||
|
@ -57,12 +58,22 @@ impl App {
|
|||
data : data_collection::Data::default(),
|
||||
scroll_direction : ScrollDirection::DOWN,
|
||||
previous_process_position : 0,
|
||||
awaiting_d : false,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn on_key(&mut self, c : char) {
|
||||
match c {
|
||||
'q' => self.should_quit = true,
|
||||
'd' => {
|
||||
if self.awaiting_d {
|
||||
self.awaiting_d = false;
|
||||
self.kill_highlighted_process().unwrap_or(()); // TODO: Should this be handled?
|
||||
}
|
||||
else {
|
||||
self.awaiting_d = true;
|
||||
}
|
||||
}
|
||||
'h' => self.on_right(),
|
||||
'j' => self.on_down(),
|
||||
'k' => self.on_up(),
|
||||
|
@ -114,6 +125,16 @@ impl App {
|
|||
}
|
||||
_ => {}
|
||||
}
|
||||
|
||||
if self.awaiting_d && c != 'd' {
|
||||
self.awaiting_d = false;
|
||||
}
|
||||
}
|
||||
|
||||
fn kill_highlighted_process(&self) -> crate::utils::error::Result<()> {
|
||||
let current_pid = u64::from(self.data.list_of_processes[self.currently_selected_process_position as usize].pid);
|
||||
process_killer::kill_process_given_pid(current_pid)?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn on_left(&mut self) {
|
||||
|
|
|
@ -99,7 +99,7 @@ impl DataState {
|
|||
|
||||
set_if_valid(&disks::get_disk_usage_list().await, &mut self.data.list_of_disks);
|
||||
push_if_valid(&disks::get_io_usage_list(false).await, &mut self.data.list_of_io);
|
||||
//push_if_valid(&disks::get_io_usage_list(true).await, &mut self.data.list_of_physical_io);
|
||||
//push_if_valid(&disks::get_io_usage_list(true).await, &mut self.data.list_of_physical_io); // Removed, seems irrelevant for now...
|
||||
set_if_valid(&temperature::get_temperature_data(&self.temperature_type).await, &mut self.data.list_of_temperature_sensor);
|
||||
|
||||
if self.first_run {
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
use std::process::Command;
|
||||
|
||||
/// Kills a process, given a PID.
|
||||
pub fn kill_process_given_pid(pid : i64) -> crate::utils::error::Result<()> {
|
||||
pub fn kill_process_given_pid(pid : u64) -> crate::utils::error::Result<()> {
|
||||
if cfg!(target_os = "linux") {
|
||||
// Linux
|
||||
Command::new("kill").arg(pid.to_string()).output()?;
|
||||
|
|
Loading…
Reference in a new issue