Compare commits
38 Commits
Author | SHA1 | Date |
---|---|---|
![]() |
60f95a1a74 | |
![]() |
4bf71e6816 | |
![]() |
e7648ffdad | |
![]() |
9a0e464188 | |
![]() |
2725b77917 | |
![]() |
9f8a133493 | |
![]() |
d2eb76ea5b | |
![]() |
89bf185f6b | |
![]() |
ae8d7a9266 | |
![]() |
071cde4a9c | |
![]() |
c76573ac7d | |
![]() |
faaf3ca047 | |
![]() |
b8cb8d34b1 | |
![]() |
4f7b332b15 | |
![]() |
70e844aa26 | |
![]() |
69232ceb0d | |
![]() |
497041d748 | |
![]() |
236e0f7dbb | |
![]() |
e91e0c7905 | |
![]() |
d8f1541afa | |
![]() |
c323816ec2 | |
![]() |
e775a09279 | |
![]() |
d89735c7a4 | |
![]() |
b71ae67eab | |
![]() |
196745fd9d | |
![]() |
30960326cf | |
![]() |
900cdc0a71 | |
![]() |
a21fac6b84 | |
![]() |
190814200c | |
![]() |
d90c456238 | |
![]() |
bb7643d43c | |
![]() |
91fbc4f89d | |
![]() |
6c2cfe70e4 | |
![]() |
f0f302db90 | |
![]() |
90ecb50bbb | |
![]() |
0438470cff | |
![]() |
b7f13c4556 | |
![]() |
4ccd8b9252 |
|
@ -27,11 +27,12 @@ assignees: aristocratos
|
||||||
- Bashtop version:
|
- Bashtop version:
|
||||||
- (Linux) Linux distribution and version:
|
- (Linux) Linux distribution and version:
|
||||||
- (Linux) Data collection type (/proc or psutil):
|
- (Linux) Data collection type (/proc or psutil):
|
||||||
|
- Psutil version: `python3 -c "import psutil; print(psutil.version_info)"` (version 5.7.0 or above is required):
|
||||||
- (OSX/FreeBSD) Os release version:
|
- (OSX/FreeBSD) Os release version:
|
||||||
- Terminal used:
|
- Terminal used:
|
||||||
- Font used:
|
- Font used:
|
||||||
- Bash version, "bash --version" (version 4.4 or above is required):
|
- Bash version, `bash --version` (version 4.4 or above is required):
|
||||||
- Locales: output of "locale -v"
|
- Locales: output of `locale -v`
|
||||||
|
|
||||||
**Additional context**
|
**Additional context**
|
||||||
|
|
||||||
|
|
41
CHANGELOG.md
41
CHANGELOG.md
|
@ -1,5 +1,46 @@
|
||||||
# Changelog
|
# Changelog
|
||||||
|
|
||||||
|
## v0.9.25
|
||||||
|
|
||||||
|
* Fixed: Crash when using "/proc" data collection and filesystem type is 9p, by @bolapara
|
||||||
|
|
||||||
|
## v0.9.24
|
||||||
|
|
||||||
|
* Fixed: Psutil script crash on OSX
|
||||||
|
* Fixed: Error handling for malformed osx-cpu-temp output
|
||||||
|
|
||||||
|
## v0.9.23
|
||||||
|
|
||||||
|
* Fixed: kill/terminate/interrupt process not working in OsX and FreeBSD
|
||||||
|
|
||||||
|
## v0.9.22
|
||||||
|
|
||||||
|
* Added: Added handler for mktemp failure for psutil script
|
||||||
|
* Removed: Secondary mktemp command for psutil script
|
||||||
|
* Fixed: Insecure test import of psutil changed
|
||||||
|
|
||||||
|
## v0.9.21
|
||||||
|
|
||||||
|
* Changed: Config file comments for theme locations
|
||||||
|
* Added: Check for correct theme file path prefix
|
||||||
|
* Added: Support for application cursor mode input
|
||||||
|
* Fixed: Incorrect value calculation for reversed proc gradient
|
||||||
|
|
||||||
|
## v0.9.20
|
||||||
|
|
||||||
|
* Fixed: Psutil script security issue when placed directly in temp folder
|
||||||
|
|
||||||
|
## v0.9.19
|
||||||
|
|
||||||
|
* Added: Option for timestamps with python on bash < 5
|
||||||
|
* Changed: Reverted "date" command timestamps to not using fifo
|
||||||
|
* Added missing # from hex value in monokai theme
|
||||||
|
|
||||||
|
## v0.9.18
|
||||||
|
|
||||||
|
* Fixed: Errors caused by process scroll change
|
||||||
|
* Fixed: Process graph creation ignored for process below 0.5%
|
||||||
|
|
||||||
## v0.9.17
|
## v0.9.17
|
||||||
|
|
||||||
* Changed: Process list now scrolls instead of "page jump" and shows number of processes instead of number of pages
|
* Changed: Process list now scrolls instead of "page jump" and shows number of processes instead of number of pages
|
||||||
|
|
|
@ -6,6 +6,8 @@
|
||||||
* Is it a requested change or feature?
|
* Is it a requested change or feature?
|
||||||
* If not, open a feature request to get feedback before making a pull request.
|
* If not, open a feature request to get feedback before making a pull request.
|
||||||
|
|
||||||
|
* If it's a fix for a unreported bug, make a bug report and link the pull request.
|
||||||
|
|
||||||
* Split up multiple unrelated changes in multiple pull requests.
|
* Split up multiple unrelated changes in multiple pull requests.
|
||||||
|
|
||||||
* [Shellcheck](https://github.com/koalaman/shellcheck) your work. Current shellsheck exceptions at the beginning of [bashtop](bashtop).
|
* [Shellcheck](https://github.com/koalaman/shellcheck) your work. Current shellsheck exceptions at the beginning of [bashtop](bashtop).
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
|
||||||
echo -e "[\033[1;33m removing packet from the system \033[0m]"
|
echo -e "[\033[1;33m removing packet from the system \033[0m]"
|
||||||
|
|
Binary file not shown.
After Width: | Height: | Size: 13 KiB |
118
README.md
118
README.md
|
@ -12,22 +12,34 @@
|
||||||
[](https://github.com/sponsors/aristocratos)
|
[](https://github.com/sponsors/aristocratos)
|
||||||
[](https://ko-fi.com/aristocratos)
|
[](https://ko-fi.com/aristocratos)
|
||||||
|
|
||||||
|
### C++ Version
|
||||||
|
|
||||||
|
##### 18 September 2021
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
The C++ version of bashtop - btop++ is available.
|
||||||
|
|
||||||
|
Get it at https://github.com/aristocratos/btop
|
||||||
|
|
||||||
|
#
|
||||||
|
|
||||||
## Index
|
## Index
|
||||||
|
|
||||||
* [Documents](#documents)
|
* [Documents](#documents)
|
||||||
* [Description](#description)
|
* [Description](#description)
|
||||||
* [Features](#features)
|
* [Features](#features)
|
||||||
* [Themes](#themes) (Updated)
|
* [Themes](#themes)
|
||||||
* [Upcoming](#upcoming) (Python port)
|
|
||||||
* [Support and funding](#support-and-funding)
|
* [Support and funding](#support-and-funding)
|
||||||
* [Compatibility](#compatibility) (OSX and FreeBSD Support)
|
* [Prerequisites](#prerequisites)
|
||||||
* [Dependencies](#dependencies) (Updated)
|
* [Dependencies](#dependencies)
|
||||||
* [Screenshots](#screenshots)
|
* [Screenshots](#screenshots)
|
||||||
* [Installation](#installation) (Updated)
|
* [Installation](#installation)
|
||||||
* [Configurability](#configurability) (Updated)
|
* [Configurability](#configurability)
|
||||||
* [TODO](#todo) (Updated)
|
* [TODO](#todo)
|
||||||
* [License](#license)
|
* [License](#license)
|
||||||
|
|
||||||
|
|
||||||
## Documents
|
## Documents
|
||||||
|
|
||||||
#### [CHANGELOG.md](CHANGELOG.md)
|
#### [CHANGELOG.md](CHANGELOG.md)
|
||||||
|
@ -65,21 +77,6 @@ User created themes should be placed in `$HOME/.config/bashtop/user_themes` to b
|
||||||
|
|
||||||
Let me know if you want to contribute with new themes.
|
Let me know if you want to contribute with new themes.
|
||||||
|
|
||||||
## Upcoming
|
|
||||||
|
|
||||||
~~Currently rewriting to use python3 [psutil](https://github.com/giampaolo/psutil) for data collection instead of linux specific tools.
|
|
||||||
This will add python 3 and psutil as dependencies, but will make bashtop cross platform compatible.~~
|
|
||||||
|
|
||||||
~~This will be integrated in to main version when done and add the possibility to switch between psutil and linux tools for users running linux.~~
|
|
||||||
|
|
||||||
Bashtop is now Mac OS X and FreeBSD compatible!
|
|
||||||
|
|
||||||
#### Python port
|
|
||||||
|
|
||||||
Work on a complete python port ~~will begin this summer~~ has begun. My aim is to keep it compatible with pypy3 for a lot of added efficiency.
|
|
||||||
|
|
||||||
PyPyTop?
|
|
||||||
|
|
||||||
## Support and funding
|
## Support and funding
|
||||||
|
|
||||||
Bug fixes and updates might be slow during normal workdays since I work full time as an industrial worker and don't have much time or energy left during the week.
|
Bug fixes and updates might be slow during normal workdays since I work full time as an industrial worker and don't have much time or energy left during the week.
|
||||||
|
@ -95,21 +92,21 @@ Also added donation links for [paypal](https://paypal.me/aristocratos) and [ko-f
|
||||||
|
|
||||||
Any support is greatly appreciated!
|
Any support is greatly appreciated!
|
||||||
|
|
||||||
## Compatibility
|
## Prerequisites
|
||||||
|
|
||||||
Should work on most modern linux distributions, on Mac OS X and on FreeBSD.
|
#### Mac Os X
|
||||||
|
|
||||||
Will not display correctly on the standard terminal on OSX!
|
Will not display correctly in the standard terminal!
|
||||||
Recommended alternative [iTerm2](https://www.iterm2.com/)
|
Recommended alternative [iTerm2](https://www.iterm2.com/)
|
||||||
|
|
||||||
Will also need to be run as superuser on OSX to display stats for processes not owned by user.
|
Will also need to be run as superuser to display stats for processes not owned by user.
|
||||||
|
|
||||||
The disk io stats on OSX and FreeBSD shows iostats for all disks at the top instead of per disk.
|
#### Linux, Mac Os X and FreeBSD
|
||||||
|
|
||||||
For correct display, a terminal with support for:
|
For correct display, a terminal with support for:
|
||||||
|
|
||||||
* 24-bit truecolor
|
* 24-bit truecolor ([See list of terminals with truecolor support](https://gist.github.com/XVilka/8346728))
|
||||||
* Wide characters
|
* Wide characters (Are sometimes problematic in web-based terminals)
|
||||||
|
|
||||||
Also needs a UTF8 locale and a font that covers:
|
Also needs a UTF8 locale and a font that covers:
|
||||||
|
|
||||||
|
@ -144,7 +141,7 @@ Bash version 5 is highly recommended to make use of $EPOCHREALTIME variable inst
|
||||||
|
|
||||||
**[Python3](https://www.python.org/downloads/)** (v3.6 or later)
|
**[Python3](https://www.python.org/downloads/)** (v3.6 or later)
|
||||||
|
|
||||||
**[psutil python module](https://github.com/giampaolo/psutil)**
|
**[psutil python module](https://github.com/giampaolo/psutil)** (v5.7.0 or later)
|
||||||
|
|
||||||
## Optionals for additional stats
|
## Optionals for additional stats
|
||||||
|
|
||||||
|
@ -177,11 +174,27 @@ Options menu.
|
||||||
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
|
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
|
||||||
```
|
```
|
||||||
|
|
||||||
>Install dependencies
|
|
||||||
|
|
||||||
|
>If you got python 3.6 or later installed outside of brew:
|
||||||
|
|
||||||
``` bash
|
``` bash
|
||||||
brew install bash coreutils gnu-sed python3 git
|
sudo python3 -m ensurepip
|
||||||
pip3 install psutil
|
sudo python3 -m pip install psutil
|
||||||
|
```
|
||||||
|
|
||||||
|
>If you haven't got python3 installed:
|
||||||
|
|
||||||
|
```
|
||||||
|
brew install python3
|
||||||
|
python3 -m pip install psutil
|
||||||
|
```
|
||||||
|
|
||||||
|
>Install dependencies
|
||||||
|
|
||||||
|
|
||||||
|
``` bash
|
||||||
|
brew install bash coreutils gnu-sed git
|
||||||
```
|
```
|
||||||
|
|
||||||
>Install optional dependency osx-cpu-temp
|
>Install optional dependency osx-cpu-temp
|
||||||
|
@ -195,9 +208,7 @@ brew install osx-cpu-temp
|
||||||
>Install with pkg and pip
|
>Install with pkg and pip
|
||||||
|
|
||||||
``` bash
|
``` bash
|
||||||
sudo pkg install coreutils gsed python3 git
|
sudo pkg install coreutils gsed git py37-psutil
|
||||||
sudo python3 -m ensurepip
|
|
||||||
sudo pip3 install psutil
|
|
||||||
```
|
```
|
||||||
|
|
||||||
#### Manual installation Linux, OSX and FreeBSD
|
#### Manual installation Linux, OSX and FreeBSD
|
||||||
|
@ -216,6 +227,16 @@ sudo make install
|
||||||
sudo make uninstall
|
sudo make uninstall
|
||||||
```
|
```
|
||||||
|
|
||||||
|
#### FreeBSD package
|
||||||
|
|
||||||
|
Available in [FreeBSD ports](https://www.freshports.org/sysutils/bashtop/)
|
||||||
|
|
||||||
|
Install pre-built pacakge
|
||||||
|
|
||||||
|
``` bash
|
||||||
|
sudo pkg install bashtop
|
||||||
|
```
|
||||||
|
|
||||||
#### Arch based
|
#### Arch based
|
||||||
|
|
||||||
Available in the AUR as [bashtop-git](https://aur.archlinux.org/packages/bashtop-git/)
|
Available in the AUR as [bashtop-git](https://aur.archlinux.org/packages/bashtop-git/)
|
||||||
|
@ -242,6 +263,16 @@ Or use quick installation:
|
||||||
sudo ./build --remove
|
sudo ./build --remove
|
||||||
```
|
```
|
||||||
|
|
||||||
|
#### Guix based
|
||||||
|
|
||||||
|
Available in [official Guix repository](https://git.savannah.gnu.org/cgit/guix.git/tree/gnu/packages/admin.scm) since 6bbd0fd2
|
||||||
|
|
||||||
|
>Installation
|
||||||
|
|
||||||
|
``` bash
|
||||||
|
guix install bashtop
|
||||||
|
```
|
||||||
|
|
||||||
#### Ubuntu based
|
#### Ubuntu based
|
||||||
|
|
||||||
Available in [official Ubuntu repository](https://launchpad.net/ubuntu/+source/bashtop) since Ubuntu 20.10
|
Available in [official Ubuntu repository](https://launchpad.net/ubuntu/+source/bashtop) since Ubuntu 20.10
|
||||||
|
@ -296,21 +327,25 @@ Config files stored in "$HOME/.config/bashtop" folder
|
||||||
#### bashtop.cfg: (auto generated if not found)
|
#### bashtop.cfg: (auto generated if not found)
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
#? Config file for bashtop v. 0.9.9
|
#? Config file for bashtop v. 0.9.21
|
||||||
|
|
||||||
#* Color theme, looks for a .theme file in "$HOME/.config/bashtop/themes" and "$HOME/.config/bashtop/user_themes", "Default" for builtin default theme
|
#* Color theme, looks for a .theme file in "$HOME/.config/bashtop/themes" and "$HOME/.config/bashtop/user_themes"
|
||||||
|
#* Should be prefixed with either "themes/" or "user_themes/" depending on location, "Default" for builtin default theme
|
||||||
color_theme="Default"
|
color_theme="Default"
|
||||||
|
|
||||||
#* Update time in milliseconds, increases automatically if set below internal loops processing time, recommended 2000 ms or above for better sample times for graphs
|
#* Update time in milliseconds, increases automatically if set below internal loops processing time, recommended 2000 ms or above for better sample times for graphs
|
||||||
update_ms="2500"
|
update_ms="2500"
|
||||||
|
|
||||||
#* Processes sorting, "pid" "program" "arguments" "threads" "user" "memory" "cpu lazy" "cpu responsive" "tree"
|
#* Processes sorting, "pid" "program" "arguments" "threads" "user" "memory" "cpu lazy" "cpu responsive"
|
||||||
#* "cpu lazy" updates sorting over time, "cpu responsive" updates sorting directly at a cpu usage cost
|
#* "cpu lazy" updates sorting over time, "cpu responsive" updates sorting directly
|
||||||
proc_sorting="cpu lazy"
|
proc_sorting="cpu lazy"
|
||||||
|
|
||||||
#* Reverse sorting order, "true" or "false"
|
#* Reverse sorting order, "true" or "false"
|
||||||
proc_reversed="false"
|
proc_reversed="false"
|
||||||
|
|
||||||
|
#* Show processes as a tree
|
||||||
|
proc_tree="false"
|
||||||
|
|
||||||
#* Check cpu temperature, only works if "sensors", "vcgencmd" or "osx-cpu-temp" commands is available
|
#* Check cpu temperature, only works if "sensors", "vcgencmd" or "osx-cpu-temp" commands is available
|
||||||
check_temp="true"
|
check_temp="true"
|
||||||
|
|
||||||
|
@ -365,8 +400,7 @@ Might finish off items out of order since I usually work on multiple at a time.
|
||||||
- [ ] Add gpu temp and usage. (If feasible)
|
- [ ] Add gpu temp and usage. (If feasible)
|
||||||
- [x] Add io stats for disks.
|
- [x] Add io stats for disks.
|
||||||
- [ ] Add cpu and mem stats for docker containers. (If feasible)
|
- [ ] Add cpu and mem stats for docker containers. (If feasible)
|
||||||
- [ ] Change process list to line scroll instead of page change.
|
- [x] Change process list to line scroll instead of page change.
|
||||||
- [ ] Add option for custom color gradient in process list in theme settings.
|
|
||||||
- [ ] Add optional window for tailing log files.
|
- [ ] Add optional window for tailing log files.
|
||||||
- [ ] Add options for resizing all boxes.
|
- [ ] Add options for resizing all boxes.
|
||||||
- [ ] Add command line argument parsing.
|
- [ ] Add command line argument parsing.
|
||||||
|
|
206
bashtop
206
bashtop
|
@ -93,7 +93,7 @@ banner=(
|
||||||
"██╔══██╗██╔══██║╚════██║██╔══██║ ██║ ██║ ██║██╔═══╝ "
|
"██╔══██╗██╔══██║╚════██║██╔══██║ ██║ ██║ ██║██╔═══╝ "
|
||||||
"██████╔╝██║ ██║███████║██║ ██║ ██║ ╚██████╔╝██║ "
|
"██████╔╝██║ ██║███████║██║ ██║ ██║ ╚██████╔╝██║ "
|
||||||
"╚═════╝ ╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝ ╚═╝ ╚═════╝ ╚═╝ ")
|
"╚═════╝ ╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝ ╚═╝ ╚═════╝ ╚═╝ ")
|
||||||
declare version="0.9.17"
|
declare version="0.9.25"
|
||||||
|
|
||||||
#* Get latest version of BashTOP from https://github.com/aristocratos/bashtop
|
#* Get latest version of BashTOP from https://github.com/aristocratos/bashtop
|
||||||
|
|
||||||
|
@ -122,7 +122,8 @@ read tty_height tty_width < <(${stty} size)
|
||||||
#? Any changes made here will be ignored if config file exists
|
#? Any changes made here will be ignored if config file exists
|
||||||
aaa_config() { : ; } #! Do not remove this line!
|
aaa_config() { : ; } #! Do not remove this line!
|
||||||
|
|
||||||
#* Color theme, looks for a .theme file in "$HOME/.config/bashtop/themes" and "$HOME/.config/bashtop/user_themes", "Default" for builtin default theme
|
#* Color theme, looks for a .theme file in "$HOME/.config/bashtop/themes" and "$HOME/.config/bashtop/user_themes"
|
||||||
|
#* Should be prefixed with either "themes/" or "user_themes/" depending on location, "Default" for builtin default theme
|
||||||
color_theme="Default"
|
color_theme="Default"
|
||||||
|
|
||||||
#* Update time in milliseconds, increases automatically if set below internal loops processing time, recommended 2000 ms or above for better sample times for graphs
|
#* Update time in milliseconds, increases automatically if set below internal loops processing time, recommended 2000 ms or above for better sample times for graphs
|
||||||
|
@ -277,47 +278,6 @@ box[double_right_corner_down]="╝"
|
||||||
box[double_title_left]="╟"
|
box[double_title_left]="╟"
|
||||||
box[double_title_right]="╢"
|
box[double_title_right]="╢"
|
||||||
|
|
||||||
#* If using bash version 5, set timestamps with EPOCHREALTIME variable
|
|
||||||
if [[ -n $EPOCHREALTIME ]]; then
|
|
||||||
get_ms() { #? Set given variable to current epoch millisecond with EPOCHREALTIME varialble
|
|
||||||
local -n ms_out=$1
|
|
||||||
ms_out=$((${EPOCHREALTIME/[.,]/}/1000))
|
|
||||||
}
|
|
||||||
|
|
||||||
#* If not, use date command, through fifo if possible
|
|
||||||
else
|
|
||||||
tmpdir=""
|
|
||||||
if [[ -n $XDG_RUNTIME_DIR && -w "$XDG_RUNTIME_DIR" ]]; then
|
|
||||||
tmpdir="$XDG_RUNTIME_DIR"
|
|
||||||
elif [[ -w /dev/shm ]]; then
|
|
||||||
tmpdir="/dev/shm"
|
|
||||||
elif [[ -w /tmp ]]; then
|
|
||||||
tmpdir="/tmp"
|
|
||||||
elif [[ -w "$HOME" ]]; then
|
|
||||||
tmpdir="$HOME"
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [[ -n $tmpdir ]] && command -v ${stdbuf} >/dev/null 2>&1; then
|
|
||||||
${mkfifo} "${tmpdir}/bashtop_datefifo"
|
|
||||||
exec 5> >(exec ${stdbuf} -o0 ${date} -f - +%s%3N > "${tmpdir}/bashtop_datefifo" 2>&1)
|
|
||||||
exec 6< "${tmpdir}/bashtop_datefifo"
|
|
||||||
${rm} -f "${tmpdir}/bashtop_datefifo"
|
|
||||||
|
|
||||||
get_ms() { #? Set given variable to current epoch millisecond with date command through background fifo
|
|
||||||
local -n ms_out=$1
|
|
||||||
echo now >&5 &&
|
|
||||||
read -u 6 ms_out
|
|
||||||
}
|
|
||||||
|
|
||||||
else
|
|
||||||
get_ms() { #? Set given variable to current epoch millisecond with forked date command
|
|
||||||
local -n ms_out=$1
|
|
||||||
ms_out=""
|
|
||||||
read ms_out < <(${date} +%s%3N)
|
|
||||||
}
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
init_() { #? Collect needed information and set options before startig main loop
|
init_() { #? Collect needed information and set options before startig main loop
|
||||||
if [[ -z $1 ]]; then
|
if [[ -z $1 ]]; then
|
||||||
local i stx=0
|
local i stx=0
|
||||||
|
@ -533,7 +493,7 @@ color_init_() { #? Check for theme file and set colors
|
||||||
done
|
done
|
||||||
|
|
||||||
#* Check if theme set in config exists and source it if it does
|
#* Check if theme set in config exists and source it if it does
|
||||||
if [[ -n ${color_theme} && ${color_theme} != "Default" && -e "${config_dir}/${color_theme%.theme}.theme" ]]; then
|
if [[ -n ${color_theme} && ${color_theme} != "Default" && ${color_theme} =~ (themes/)|(user_themes/) && -e "${config_dir}/${color_theme%.theme}.theme" ]]; then
|
||||||
# shellcheck source=/dev/null
|
# shellcheck source=/dev/null
|
||||||
source "${config_dir}/${color_theme%.theme}.theme"
|
source "${config_dir}/${color_theme%.theme}.theme"
|
||||||
sourced=1
|
sourced=1
|
||||||
|
@ -630,7 +590,7 @@ quit_() { #? Clean exit
|
||||||
if [[ $use_psutil == true && $2 != "psutil" ]]; then
|
if [[ $use_psutil == true && $2 != "psutil" ]]; then
|
||||||
py_command quit
|
py_command quit
|
||||||
sleep 0.1
|
sleep 0.1
|
||||||
rm "${pywrapper}"
|
rm -rf "${pytmpdir}"
|
||||||
fi
|
fi
|
||||||
echo -en "${clear_screen}${normal_screen}${show_cursor}"
|
echo -en "${clear_screen}${normal_screen}${show_cursor}"
|
||||||
${stty} "${saved_stty}"
|
${stty} "${saved_stty}"
|
||||||
|
@ -918,7 +878,7 @@ get_cpu_info() {
|
||||||
if [[ $use_psutil == true ]]; then
|
if [[ $use_psutil == true ]]; then
|
||||||
if [[ -z ${cpu[threads]} || -z ${cpu[cores]} ]]; then
|
if [[ -z ${cpu[threads]} || -z ${cpu[cores]} ]]; then
|
||||||
py_command -v pyin "get_cpu_cores()"
|
py_command -v pyin "get_cpu_cores()"
|
||||||
read cpu[threads] cpu[cores] <<<"${pyin}"
|
read cpu[cores] cpu[threads] <<<"${pyin}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
else
|
else
|
||||||
|
@ -2169,8 +2129,10 @@ collect_cpu_temps() { #? Collect cpu temperatures
|
||||||
#* Get CPU package temp for Rapberry Pi cpus and for OSX
|
#* Get CPU package temp for Rapberry Pi cpus and for OSX
|
||||||
elif [[ $sensor_comm != "sensors" && -n ${misc_var} ]]; then
|
elif [[ $sensor_comm != "sensors" && -n ${misc_var} ]]; then
|
||||||
cpu[temp_0]="${misc_var#temp=}"
|
cpu[temp_0]="${misc_var#temp=}"
|
||||||
cpu[temp_unit]="°${cpu[temp_0]:(-1)}"; cpu[temp_0]=${cpu[temp_0]%.*}; if [[ ${cpu[temp_0]::1} == "+" ]]; then cpu[temp_0]=${cpu[temp_0]#+}; fi
|
cpu[temp_unit]="°${cpu[temp_0]:(-1)}"; cpu[temp_0]=${cpu[temp_0]%%.*}; if [[ ${cpu[temp_0]::1} == "+" ]]; then cpu[temp_0]=${cpu[temp_0]#+}; fi
|
||||||
cpu[temp_high]="75"; cpu[temp_crit]=$((cpu[temp_high]+10))
|
if [[ -z ${cpu[temp_high]} ]]; then
|
||||||
|
cpu[temp_high]="75"; cpu[temp_crit]=$((cpu[temp_high]+10))
|
||||||
|
fi
|
||||||
|
|
||||||
#* Copy cpu temp to cores
|
#* Copy cpu temp to cores
|
||||||
for((i=1;i<=threads;i++)); do
|
for((i=1;i<=threads;i++)); do
|
||||||
|
@ -2273,7 +2235,7 @@ collect_mem() { #? Collect memory information from "/proc/meminfo"
|
||||||
if ! py_command -a df_array "get_disks(exclude='squashfs'${filtering})"; then psutil_disk_fail=1; psutil_on="false"; fi
|
if ! py_command -a df_array "get_disks(exclude='squashfs'${filtering})"; then psutil_disk_fail=1; psutil_on="false"; fi
|
||||||
fi
|
fi
|
||||||
if [[ $psutil_on == false ]]; then
|
if [[ $psutil_on == false ]]; then
|
||||||
readarray -t df_array < <(${df} -x squashfs -x tmpfs -x devtmpfs -x overlay 2>/dev/null || true)
|
readarray -t df_array < <(${df} -x squashfs -x tmpfs -x devtmpfs -x overlay -x 9p 2>/dev/null || true)
|
||||||
fi
|
fi
|
||||||
for df_line in "${df_array[@]:1}"; do
|
for df_line in "${df_array[@]:1}"; do
|
||||||
line_array=(${df_line})
|
line_array=(${df_line})
|
||||||
|
@ -2679,7 +2641,7 @@ collect_processes_psutil() {
|
||||||
|
|
||||||
pid_history[${pid}]="1"
|
pid_history[${pid}]="1"
|
||||||
|
|
||||||
#* Create small graphs for all visible processes using more than 1% cpu time
|
#* Create small graphs for all visible processes using more than 1% rounded cpu time
|
||||||
pid_graph="pid_${pid}_graph"
|
pid_graph="pid_${pid}_graph"
|
||||||
if ! local -n pid_count="pid_${pid}_count" 2>/dev/null; then continue; fi
|
if ! local -n pid_count="pid_${pid}_count" 2>/dev/null; then continue; fi
|
||||||
|
|
||||||
|
@ -2691,8 +2653,10 @@ collect_processes_psutil() {
|
||||||
elif [[ ${pid_count} -gt 0 ]]; then
|
elif [[ ${pid_count} -gt 0 ]]; then
|
||||||
if [[ ${cpu_int} -gt 9 ]]; then
|
if [[ ${cpu_int} -gt 9 ]]; then
|
||||||
create_mini_graph -nc -add-value "pid_${pid}_graph" "$((cpu_int+15))"
|
create_mini_graph -nc -add-value "pid_${pid}_graph" "$((cpu_int+15))"
|
||||||
else
|
elif [[ ${cpu_int} -gt 0 ]]; then
|
||||||
create_mini_graph -nc -add-value "pid_${pid}_graph" "$((cpu_int+9))"
|
create_mini_graph -nc -add-value "pid_${pid}_graph" "$((cpu_int+9))"
|
||||||
|
else
|
||||||
|
create_mini_graph -nc -add-value "pid_${pid}_graph" "0"
|
||||||
fi
|
fi
|
||||||
pid_count=$((${pid_count}-1))
|
pid_count=$((${pid_count}-1))
|
||||||
elif [[ ${pid_count} == "0" ]]; then
|
elif [[ ${pid_count} == "0" ]]; then
|
||||||
|
@ -2755,7 +2719,7 @@ collect_processes_psutil() {
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if ((i==height-2)); then
|
if ((i==height-2)); then
|
||||||
if [[ ${proc[selected]} -gt 0 || ${proc[start]} -gt 1 ]] || [[ ${proc[detailed]} -eq 1 && -z ${proc[detailed_cpu]} && -z ${proc[detailed_killed]} ]]; then :
|
if [[ ${proc[selected]} -gt 0 || -n $filter || ${proc[start]} -gt 1 ]] || [[ ${proc[detailed]} -eq 1 && -z ${proc[detailed_cpu]} && -z ${proc[detailed_killed]} ]]; then :
|
||||||
else break; fi
|
else break; fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -2766,16 +2730,14 @@ collect_processes_psutil() {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#* Clear up memory by removing variables and graphs of no longer running processes
|
#* Clear up memory
|
||||||
((++proc[general_counter]))
|
((++proc[general_counter]))
|
||||||
if ((proc[general_counter]>100)); then
|
if ((proc[general_counter]>100)); then
|
||||||
proc[general_counter]=0
|
proc[general_counter]=0
|
||||||
for pids in ${!pid_history[@]}; do
|
for pids in ${!pid_history[@]}; do
|
||||||
if [[ ! -e /proc/${pids} ]]; then
|
unset "pid_${pids}_graph" "pid_${pids}_graph_even" "pid_${pids}_graph_odd" "pid_${pids}_graph_last_type" "pid_${pids}_graph_last_val"
|
||||||
unset "pid_${pids}_graph" "pid_${pids}_graph_even" "pid_${pids}_graph_odd" "pid_${pids}_graph_last_type" "pid_${pids}_graph_last_val"
|
unset "pid_${pids}_count"
|
||||||
unset "pid_${pids}_count"
|
unset "pid_history[${pids}]"
|
||||||
unset "pid_history[${pids}]"
|
|
||||||
fi
|
|
||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -3257,11 +3219,11 @@ draw_mem() { #? Draw mem, swap and disk statistics
|
||||||
draw_processes() { #? Draw processes and values to screen
|
draw_processes() { #? Draw processes and values to screen
|
||||||
local argument="$1"
|
local argument="$1"
|
||||||
if [[ -n $skip_process_draw && $argument != "now" ]]; then return; fi
|
if [[ -n $skip_process_draw && $argument != "now" ]]; then return; fi
|
||||||
local line=${box[processes_line]} col=${box[processes_col]} width=${box[processes_width]} height=${box[processes_height]} out_line y=1 fg_step_r=0 fg_step_g=0 fg_step_b=0 checker=2 page_string
|
local line=${box[processes_line]} col=${box[processes_col]} width=${box[processes_width]} height=${box[processes_height]} out_line y=1 fg_step_r=0 fg_step_g=0 fg_step_b=0 checker=2 page_string sel_string
|
||||||
local reverse_string reverse_pos order_left="───────────┤" filter_string current_num detail_location det_no_add com_fg pg_arrow_up_fg pg_arrow_down_fg p_height=$((height-3))
|
local reverse_string reverse_pos order_left="───────────┤" filter_string current_num detail_location det_no_add com_fg pg_arrow_up_fg pg_arrow_down_fg p_height=$((height-3))
|
||||||
local pid=0 pid_graph pid_step_r pid_step_g pid_step_b pid_add_r pid_add_g pid_add_b bg_add bg_step proc_start up_fg down_fg page_up_fg page_down_fg this_box=processes
|
local pid=0 pid_graph pid_step_r pid_step_g pid_step_b pid_add_r pid_add_g pid_add_b bg_add bg_step proc_start up_fg down_fg page_up_fg page_down_fg this_box=processes
|
||||||
local d_width=${box[details_width]} d_height=${box[details_height]} d_line=${box[details_line]} d_col=${box[details_col]}
|
local d_width=${box[details_width]} d_height=${box[details_height]} d_line=${box[details_line]} d_col=${box[details_col]}
|
||||||
local detail_graph_width=$((d_width/3+2)) detail_graph_height=$((d_height-1)) kill_fg det_mod fg_add_r fg_add_g fg_add_b fg_inv
|
local detail_graph_width=$((d_width/3+2)) detail_graph_height=$((d_height-1)) kill_fg det_mod fg_add_r fg_add_g fg_add_b
|
||||||
local right_width=$((d_width-detail_graph_width-2))
|
local right_width=$((d_width-detail_graph_width-2))
|
||||||
local right_col=$((d_col+detail_graph_width+4))
|
local right_col=$((d_col+detail_graph_width+4))
|
||||||
local -a pid_rgb=(${theme[proc_misc]}) fg_rgb=(${theme[main_fg_dec]})
|
local -a pid_rgb=(${theme[proc_misc]}) fg_rgb=(${theme[main_fg_dec]})
|
||||||
|
@ -3270,14 +3232,23 @@ draw_processes() { #? Draw processes and values to screen
|
||||||
if [[ $argument == "now" ]]; then skip_process_draw=1; fi
|
if [[ $argument == "now" ]]; then skip_process_draw=1; fi
|
||||||
|
|
||||||
if [[ $proc_gradient == true ]]; then
|
if [[ $proc_gradient == true ]]; then
|
||||||
if ((fg_r+fg_g+fg_b<(255*3)/2)); then fg_inv=1; fi
|
if ((fg_r+fg_g+fg_b<(255*3)/2)); then
|
||||||
fg_add_r="${fg_inv:+-}$(( (fg_r-(fg_r/6) )/height))"
|
fg_add_r="$(( (fg_r-255-((fg_r-255)/6) )/height))"
|
||||||
fg_add_g="${fg_inv:+-}$(( (fg_g-(fg_g/6) )/height))"
|
fg_add_g="$(( (fg_g-255-((fg_g-255)/6) )/height))"
|
||||||
fg_add_b="${fg_inv:+-}$(( (fg_b-(fg_b/6) )/height))"
|
fg_add_b="$(( (fg_b-255-((fg_b-255)/6) )/height))"
|
||||||
|
|
||||||
pid_add_r="${fg_inv:+-}$(( (pid_r-(pid_r/6) )/height))"
|
pid_add_r="$(( (pid_r-255-((pid_r-255)/6) )/height))"
|
||||||
pid_add_g="${fg_inv:+-}$(( (pid_g-(pid_g/6) )/height))"
|
pid_add_g="$(( (pid_g-255-((pid_g-255)/6) )/height))"
|
||||||
pid_add_b="${fg_inv:+-}$(( (pid_b-(pid_b/6) )/height))"
|
pid_add_b="$(( (pid_b-255-((pid_b-255)/6) )/height))"
|
||||||
|
else
|
||||||
|
fg_add_r="$(( (fg_r-(fg_r/6) )/height))"
|
||||||
|
fg_add_g="$(( (fg_g-(fg_g/6) )/height))"
|
||||||
|
fg_add_b="$(( (fg_b-(fg_b/6) )/height))"
|
||||||
|
|
||||||
|
pid_add_r="$(( (pid_r-(pid_r/6) )/height))"
|
||||||
|
pid_add_g="$(( (pid_g-(pid_g/6) )/height))"
|
||||||
|
pid_add_b="$(( (pid_b-(pid_b/6) )/height))"
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
unset proc_out
|
unset proc_out
|
||||||
|
@ -3380,10 +3351,14 @@ draw_processes() { #? Draw processes and values to screen
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#* Print processes
|
#* Print processes
|
||||||
if (( proc[start]>(${#proc_array[@]}-1)-p_height )); then
|
if ((${#proc_array[@]}<=p_height)); then
|
||||||
|
proc[start]=1
|
||||||
|
elif (( proc[start]>(${#proc_array[@]}-1)-p_height )); then
|
||||||
proc[start]=$(( (${#proc_array[@]}-1)-p_height ))
|
proc[start]=$(( (${#proc_array[@]}-1)-p_height ))
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if ((proc[selected]>${#proc_array[@]}-1)); then proc[selected]=$((${#proc_array[@]}-1)); fi
|
||||||
|
|
||||||
if [[ $proc_gradient == true ]] && ((proc[selected]>1)); then
|
if [[ $proc_gradient == true ]] && ((proc[selected]>1)); then
|
||||||
fg_r="$(( fg_r-( fg_add_r*(proc[selected]-1) ) ))"
|
fg_r="$(( fg_r-( fg_add_r*(proc[selected]-1) ) ))"
|
||||||
fg_g="$(( fg_g-( fg_add_g*(proc[selected]-1) ) ))"
|
fg_g="$(( fg_g-( fg_add_g*(proc[selected]-1) ) ))"
|
||||||
|
@ -3449,9 +3424,10 @@ draw_processes() { #? Draw processes and values to screen
|
||||||
print -v proc_out -m $((line+y++)) $((col+1)) -rp $((width-2)) -t " "
|
print -v proc_out -m $((line+y++)) $((col+1)) -rp $((width-2)) -t " "
|
||||||
done
|
done
|
||||||
|
|
||||||
page_string="$((proc[start]-1+proc[selected]))/$((${#proc_array[@]}-2))"
|
if ((proc[selected]>0)); then sel_string=$((proc[start]-1+proc[selected])); else sel_string=0; fi
|
||||||
|
page_string="${sel_string}/$((${#proc_array[@]}-2${filter:++1}))"
|
||||||
print -v proc_out -m $((line+height-1)) $((col+width-20)) -fg ${box[processes_color]} -rp 19 -t "─"
|
print -v proc_out -m $((line+height-1)) $((col+width-20)) -fg ${box[processes_color]} -rp 19 -t "─"
|
||||||
print -v proc_out -m $((line+height-1)) $((col+width-${#page_string}-6)) -fg ${box[processes_color]} -t "┤" -b -fg ${theme[title]} -t " $page_string " -rs -fg ${box[processes_color]} -t "├"
|
print -v proc_out -m $((line+height-1)) $((col+width-${#page_string}-4)) -fg ${box[processes_color]} -t "┤" -b -fg ${theme[title]} -t "$page_string" -rs -fg ${box[processes_color]} -t "├"
|
||||||
|
|
||||||
|
|
||||||
if ((proc[order_change]==1 | proc[filter_change]==1 | resized>0)); then
|
if ((proc[order_change]==1 | proc[filter_change]==1 | resized>0)); then
|
||||||
|
@ -3494,8 +3470,9 @@ draw_processes() { #? Draw processes and values to screen
|
||||||
if ((proc[page_change]==1 | resized>0)); then
|
if ((proc[page_change]==1 | resized>0)); then
|
||||||
unset proc_misc2
|
unset proc_misc2
|
||||||
proc[page_change]=0
|
proc[page_change]=0
|
||||||
if ((proc[selected]>0)); then up_fg="${theme[hi_fg]}"; kill_fg="${theme[hi_fg]}"; com_fg="${theme[title]}"; else up_fg="${theme[inactive_fg]}"; kill_fg="${theme[inactive_fg]}"; com_fg="${theme[inactive_fg]}"; fi
|
if ((proc[selected]>0)); then kill_fg="${theme[hi_fg]}"; com_fg="${theme[title]}"; else kill_fg="${theme[inactive_fg]}"; com_fg="${theme[inactive_fg]}"; fi
|
||||||
if ((proc[selected]==(${#proc_array[@]}-1)-proc[start])); then down_fg="${theme[inactive_fg]}"; else down_fg="${theme[hi_fg]}"; fi
|
if ((proc[selected]==(${#proc_array[@]}-1${filter:++1})-proc[start])); then down_fg="${theme[inactive_fg]}"; else down_fg="${theme[hi_fg]}"; fi
|
||||||
|
if ((proc[selected]>0 | proc[start]>1)); then up_fg="${theme[hi_fg]}"; else up_fg="${theme[inactive_fg]}"; fi
|
||||||
|
|
||||||
print -v proc_misc2 -m $((line+height-1)) $((col+2)) -fg ${box[processes_color]} -t "┤" -fg $up_fg -b -t "↑" -fg ${theme[title]} -t " select " -fg $down_fg -t "↓" -rs -fg ${box[processes_color]} -t "├"
|
print -v proc_misc2 -m $((line+height-1)) $((col+2)) -fg ${box[processes_color]} -t "┤" -fg $up_fg -b -t "↑" -fg ${theme[title]} -t " select " -fg $down_fg -t "↓" -rs -fg ${box[processes_color]} -t "├"
|
||||||
print -v proc_misc2 -r 1 -fg ${box[processes_color]} -t "┤" -fg $com_fg -b -t "info " -fg $kill_fg "↲" -rs -fg ${box[processes_color]} -t "├"
|
print -v proc_misc2 -r 1 -fg ${box[processes_color]} -t "┤" -fg $com_fg -b -t "info " -fg $kill_fg "↲" -rs -fg ${box[processes_color]} -t "├"
|
||||||
|
@ -4257,7 +4234,8 @@ killer_() { #? Kill process with selected signal
|
||||||
local kill_op="$1" kill_pid="$2" killer_out killer_box col line program keypress selected selected_int=0 sig confirmed=0 option killer_pause status msg
|
local kill_op="$1" kill_pid="$2" killer_out killer_box col line program keypress selected selected_int=0 sig confirmed=0 option killer_pause status msg
|
||||||
local -a options=("yes" "no")
|
local -a options=("yes" "no")
|
||||||
|
|
||||||
if ! program="$(ps -o comm --no-header -p ${kill_pid})"; then return; fi
|
if ! program="$(ps -o comm -p ${kill_pid})"; then return
|
||||||
|
else program="$(tail -n1 <<<"$program")"; fi
|
||||||
|
|
||||||
case $kill_op in
|
case $kill_op in
|
||||||
t|T) kill_op="terminate"; sig="SIGTERM" ;;
|
t|T) kill_op="terminate"; sig="SIGTERM" ;;
|
||||||
|
@ -4391,10 +4369,10 @@ get_key() { #? Get one key from standard input and translate key code to readabl
|
||||||
if [[ -z $key && $esc -eq 1 ]]; then key="escape"
|
if [[ -z $key && $esc -eq 1 ]]; then key="escape"
|
||||||
elif [[ $esc -eq 1 ]]; then
|
elif [[ $esc -eq 1 ]]; then
|
||||||
case "${key}" in
|
case "${key}" in
|
||||||
'[A'*) key="up" ;;
|
'[A'*|'OA'*) key="up" ;;
|
||||||
'[B'*) key="down" ;;
|
'[B'*|'OB'*) key="down" ;;
|
||||||
'[D'*) key="left" ;;
|
'[D'*|'OD'*) key="left" ;;
|
||||||
'[C'*) key="right" ;;
|
'[C'*|'OC'*) key="right" ;;
|
||||||
'[2~') key="insert" ;;
|
'[2~') key="insert" ;;
|
||||||
'[3~') key="delete" ;;
|
'[3~') key="delete" ;;
|
||||||
'[H'*) key="home" ;;
|
'[H'*) key="home" ;;
|
||||||
|
@ -4441,7 +4419,7 @@ process_input() { #? Process keypresses for main ui
|
||||||
"enter") unset input_to_filter ;;
|
"enter") unset input_to_filter ;;
|
||||||
"backspace") if [[ ${#filter} -gt 0 ]]; then filter="${filter:: (-1)}"; else unset filter_change; fi ;;
|
"backspace") if [[ ${#filter} -gt 0 ]]; then filter="${filter:: (-1)}"; else unset filter_change; fi ;;
|
||||||
"escape") unset input_to_filter filter ;;
|
"escape") unset input_to_filter filter ;;
|
||||||
*) if [[ ${#keypress} -eq 1 ]]; then filter+="${keypress//[\\\$\"\']/}"; else unset filter_change; fi ;;
|
*) if [[ ${#keypress} -eq 1 && $keypress =~ ^[A-Za-z0-9\!\@\#\%\&\/\(\)\[\+\-\_\*\,\;\.\:]$ ]]; then filter+="${keypress//[\\\$\"\']/}"; else unset filter_change; fi ;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
else
|
else
|
||||||
|
@ -4502,10 +4480,10 @@ process_input() { #? Process keypresses for main ui
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
down|tab) #* Move process selector down one
|
down|tab) #* Move process selector down one
|
||||||
if ((proc[selected]<p_height & proc[start]+proc[selected]<(${#proc_array[@]}-1) )); then
|
if ((proc[selected]<p_height & proc[start]+proc[selected]<(${#proc_array[@]}) )); then
|
||||||
((++proc[selected]))
|
((++proc[selected]))
|
||||||
proc[page_change]=1
|
proc[page_change]=1
|
||||||
elif ((proc[start]+proc[selected]<(${#proc_array[@]}-1) )); then
|
elif ((proc[start]+proc[selected]<(${#proc_array[@]}) )); then
|
||||||
((++proc[start]))
|
((++proc[start]))
|
||||||
proc[page_change]=1
|
proc[page_change]=1
|
||||||
fi
|
fi
|
||||||
|
@ -4541,7 +4519,7 @@ process_input() { #? Process keypresses for main ui
|
||||||
if ((proc[start]<(${#proc_array[@]}-1)-p_height)); then
|
if ((proc[start]<(${#proc_array[@]}-1)-p_height)); then
|
||||||
if ((proc[start]==1)) && [[ $use_psutil == false ]]; then collect_processes now; fi
|
if ((proc[start]==1)) && [[ $use_psutil == false ]]; then collect_processes now; fi
|
||||||
proc[start]=$(( proc[start]+p_height ))
|
proc[start]=$(( proc[start]+p_height ))
|
||||||
if (( proc[start]>(${#proc_array[@]}-1)-p_height )); then proc[start]=$(( (${#proc_array[@]}-1)-p_height )); fi
|
if (( proc[start]>(${#proc_array[@]})-p_height )); then proc[start]=$(( (${#proc_array[@]})-p_height )); fi
|
||||||
proc[page_change]=1
|
proc[page_change]=1
|
||||||
elif ((proc[selected]>0)); then
|
elif ((proc[selected]>0)); then
|
||||||
proc[selected]=$((p_height))
|
proc[selected]=$((p_height))
|
||||||
|
@ -4604,6 +4582,8 @@ process_input() { #? Process keypresses for main ui
|
||||||
f|F) #* Start process filtering input
|
f|F) #* Start process filtering input
|
||||||
input_to_filter=1
|
input_to_filter=1
|
||||||
filter_change=1
|
filter_change=1
|
||||||
|
if ((proc[selected]>1)); then proc[selected]=1; fi
|
||||||
|
proc[start]=1
|
||||||
;;
|
;;
|
||||||
c|C) #* Clear process filter
|
c|C) #* Clear process filter
|
||||||
if [[ -n $filter ]]; then
|
if [[ -n $filter ]]; then
|
||||||
|
@ -4783,7 +4763,7 @@ if [[ $use_psutil == true ]]; then
|
||||||
else
|
else
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
elif [[ $use_psutil == true ]] && ! python3 -c "import psutil" >/dev/null 2>&1; then
|
elif [[ $use_psutil == true ]] && ! (cd / && python3 -c "import psutil") >/dev/null 2>&1; then
|
||||||
echo "Error: Missing python3 psutil module!"
|
echo "Error: Missing python3 psutil module!"
|
||||||
if [[ $system == "Linux" ]]; then
|
if [[ $system == "Linux" ]]; then
|
||||||
use_psutil="false"
|
use_psutil="false"
|
||||||
|
@ -4793,8 +4773,28 @@ if [[ $use_psutil == true ]]; then
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#* if we have been sourced by another shell, quit. Allows sourcing only function definition.
|
#* If using bash version 5, set timestamps with EPOCHREALTIME variable
|
||||||
[[ "${#BASH_SOURCE[@]}" -gt 1 ]] && { return 0; }
|
if [[ -n $EPOCHREALTIME ]]; then
|
||||||
|
get_ms() { #? Set given variable to current epoch millisecond with EPOCHREALTIME varialble
|
||||||
|
local -n ms_out=$1
|
||||||
|
ms_out=$((${EPOCHREALTIME/[.,]/}/1000))
|
||||||
|
}
|
||||||
|
|
||||||
|
#* If not, but using psutil, set timestamps with python
|
||||||
|
elif [[ $use_psutil == true ]]; then
|
||||||
|
get_ms() {
|
||||||
|
local -n ms_out=$1
|
||||||
|
py_command -v ms_out "get_ms()"
|
||||||
|
}
|
||||||
|
|
||||||
|
#* Else use date command
|
||||||
|
else
|
||||||
|
get_ms() { #? Set given variable to current epoch millisecond with date command
|
||||||
|
local -n ms_out=$1
|
||||||
|
ms_out=""
|
||||||
|
read ms_out < <(${date} +%s%3N)
|
||||||
|
}
|
||||||
|
fi
|
||||||
|
|
||||||
#* Setup psutil script
|
#* Setup psutil script
|
||||||
if [[ $use_psutil == true ]]; then
|
if [[ $use_psutil == true ]]; then
|
||||||
|
@ -4829,7 +4829,15 @@ if [[ $use_psutil == true ]]; then
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
pywrapper=$(mktemp "${TMPDIR:-/tmp}"/bashtop.psutil.XXXX)
|
if ! pytmpdir=$(mktemp -d "${TMPDIR:-/tmp}"/XXXXXXXXXXXX); then
|
||||||
|
if [[ $system == "Linux" ]]; then
|
||||||
|
use_psutil="false"
|
||||||
|
else
|
||||||
|
echo "ERROR: Failed setting up temp directory for psutil script!"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
pywrapper="${pytmpdir}/bashtop.psutil"
|
||||||
|
|
||||||
cat << 'EOF' > "${pywrapper}"
|
cat << 'EOF' > "${pywrapper}"
|
||||||
import os, sys, subprocess, re, time, psutil
|
import os, sys, subprocess, re, time, psutil
|
||||||
|
@ -4862,7 +4870,8 @@ allowed_commands: Tuple[str] = (
|
||||||
'get_net',
|
'get_net',
|
||||||
'get_cmd_out',
|
'get_cmd_out',
|
||||||
'get_sensors',
|
'get_sensors',
|
||||||
'get_sensors_check'
|
'get_sensors_check',
|
||||||
|
'get_ms'
|
||||||
)
|
)
|
||||||
command: str = ''
|
command: str = ''
|
||||||
cpu_count: int = psutil.cpu_count()
|
cpu_count: int = psutil.cpu_count()
|
||||||
|
@ -4876,6 +4885,11 @@ def get_cmd_out(cmd: str):
|
||||||
'''Save bash the trouble of creating child processes by running through python instead'''
|
'''Save bash the trouble of creating child processes by running through python instead'''
|
||||||
print(subprocess.check_output(cmd, shell=True, universal_newlines=True).rstrip())
|
print(subprocess.check_output(cmd, shell=True, universal_newlines=True).rstrip())
|
||||||
|
|
||||||
|
def get_ms():
|
||||||
|
'''Get current epoch millisecond'''
|
||||||
|
t = str(time.time()).split(".")
|
||||||
|
print(f'{t[0]}{t[1][:3]}')
|
||||||
|
|
||||||
def get_sensors():
|
def get_sensors():
|
||||||
'''A clone of "sensors" but using psutil'''
|
'''A clone of "sensors" but using psutil'''
|
||||||
temps = psutil.sensors_temperatures()
|
temps = psutil.sensors_temperatures()
|
||||||
|
@ -4945,8 +4959,8 @@ def get_cpu_name():
|
||||||
|
|
||||||
def get_cpu_cores():
|
def get_cpu_cores():
|
||||||
'''Get number of CPU cores and threads'''
|
'''Get number of CPU cores and threads'''
|
||||||
cores: int = psutil.cpu_count(logical=True)
|
cores: int = psutil.cpu_count(logical=False)
|
||||||
threads: int = psutil.cpu_count(logical=False)
|
threads: int = psutil.cpu_count(logical=True)
|
||||||
print(f'{cores} {threads if threads else cores}')
|
print(f'{cores} {threads if threads else cores}')
|
||||||
|
|
||||||
def get_cpu_usage():
|
def get_cpu_usage():
|
||||||
|
@ -5050,11 +5064,14 @@ def get_proc(sorting='cpu lazy', tree=False, prog_len=0, arg_len=0, search='', r
|
||||||
print(f"{'Pid:':>7} {'Program:':<{prog_len}}", f"{'Arguments:':<{arg_len-4}}" if arg_len else '', f"{'Threads:' if arg_len else ' Tr:'} {'User:':<9}Mem%{'Cpu%':>11}", sep='')
|
print(f"{'Pid:':>7} {'Program:':<{prog_len}}", f"{'Arguments:':<{arg_len-4}}" if arg_len else '', f"{'Threads:' if arg_len else ' Tr:'} {'User:':<9}Mem%{'Cpu%':>11}", sep='')
|
||||||
|
|
||||||
for p in sorted(psutil.process_iter(['pid', 'name', 'cmdline', 'num_threads', 'username', 'memory_percent', 'cpu_percent', 'cpu_times', 'create_time'], err), key=lambda p: eval(sort_cmd), reverse=reverse):
|
for p in sorted(psutil.process_iter(['pid', 'name', 'cmdline', 'num_threads', 'username', 'memory_percent', 'cpu_percent', 'cpu_times', 'create_time'], err), key=lambda p: eval(sort_cmd), reverse=reverse):
|
||||||
if p.info['name'] == 'idle':
|
if p.info['name'] == 'idle' or p.info['name'] == err or p.info['pid'] == err:
|
||||||
continue
|
continue
|
||||||
if p.info['cpu_times'] == err:
|
if p.info['cmdline'] == err:
|
||||||
|
p.info['cmdline'] = ""
|
||||||
|
if p.info['username'] == err:
|
||||||
|
p.info['username'] = "?"
|
||||||
|
if p.info['num_threads'] == err:
|
||||||
p.info['num_threads'] = 0
|
p.info['num_threads'] = 0
|
||||||
p.info['cmdline'] = ''
|
|
||||||
if search:
|
if search:
|
||||||
found = False
|
found = False
|
||||||
for value in [ p.info['name'], ' '.join(p.info['cmdline']), str(p.info['pid']), p.info['username'] ]:
|
for value in [ p.info['name'], ' '.join(p.info['cmdline']), str(p.info['pid']), p.info['username'] ]:
|
||||||
|
@ -5111,6 +5128,8 @@ def proc_tree(width: int, sorting: str = 'cpu lazy', reverse: bool = True, max_l
|
||||||
if getinfo and cont:
|
if getinfo and cont:
|
||||||
if getinfo['cpu_times'] == err:
|
if getinfo['cpu_times'] == err:
|
||||||
getinfo['num_threads'] = 0
|
getinfo['num_threads'] = 0
|
||||||
|
if p.info['username'] == err:
|
||||||
|
p.info['username'] = "?"
|
||||||
cpu = getinfo['cpu_percent'] if proc_per_cpu else (getinfo['cpu_percent'] / psutil.cpu_count())
|
cpu = getinfo['cpu_percent'] if proc_per_cpu else (getinfo['cpu_percent'] / psutil.cpu_count())
|
||||||
print(f"{getinfo['num_threads']:>4} " if getinfo['num_threads'] < 1000 else '999> ',
|
print(f"{getinfo['num_threads']:>4} " if getinfo['num_threads'] < 1000 else '999> ',
|
||||||
f"{getinfo['username']:<9.9}" if len(getinfo['username']) < 10 else f"{getinfo['username'][:8]:<8}+",
|
f"{getinfo['username']:<9.9}" if len(getinfo['username']) < 10 else f"{getinfo['username'][:8]:<8}+",
|
||||||
|
@ -5226,7 +5245,7 @@ while command != 'quit':
|
||||||
print('/EOL')
|
print('/EOL')
|
||||||
#print(f'{command}', file=sys.stderr)
|
#print(f'{command}', file=sys.stderr)
|
||||||
EOF
|
EOF
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#* Set up traps for ctrl-c, soft kill, window resize, ctrl-z and resume from ctrl-z
|
#* Set up traps for ctrl-c, soft kill, window resize, ctrl-z and resume from ctrl-z
|
||||||
|
@ -5258,6 +5277,9 @@ else
|
||||||
exec 2>/dev/null
|
exec 2>/dev/null
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
#* If we have been sourced by another shell, quit. Allows sourcing only function definition.
|
||||||
|
[[ "${#BASH_SOURCE[@]}" -gt 1 ]] && { return 0; }
|
||||||
|
|
||||||
#* Call init function
|
#* Call init function
|
||||||
init_
|
init_
|
||||||
|
|
||||||
|
|
|
@ -32,7 +32,8 @@ allowed_commands: Tuple[str] = (
|
||||||
'get_net',
|
'get_net',
|
||||||
'get_cmd_out',
|
'get_cmd_out',
|
||||||
'get_sensors',
|
'get_sensors',
|
||||||
'get_sensors_check'
|
'get_sensors_check',
|
||||||
|
'get_ms'
|
||||||
)
|
)
|
||||||
command: str = ''
|
command: str = ''
|
||||||
cpu_count: int = psutil.cpu_count()
|
cpu_count: int = psutil.cpu_count()
|
||||||
|
@ -46,6 +47,11 @@ def get_cmd_out(cmd: str):
|
||||||
'''Save bash the trouble of creating child processes by running through python instead'''
|
'''Save bash the trouble of creating child processes by running through python instead'''
|
||||||
print(subprocess.check_output(cmd, shell=True, universal_newlines=True).rstrip())
|
print(subprocess.check_output(cmd, shell=True, universal_newlines=True).rstrip())
|
||||||
|
|
||||||
|
def get_ms():
|
||||||
|
'''Get current epoch millisecond'''
|
||||||
|
t = str(time.time()).split(".")
|
||||||
|
print(f'{t[0]}{t[1][:3]}')
|
||||||
|
|
||||||
def get_sensors():
|
def get_sensors():
|
||||||
'''A clone of "sensors" but using psutil'''
|
'''A clone of "sensors" but using psutil'''
|
||||||
temps = psutil.sensors_temperatures()
|
temps = psutil.sensors_temperatures()
|
||||||
|
@ -115,8 +121,8 @@ def get_cpu_name():
|
||||||
|
|
||||||
def get_cpu_cores():
|
def get_cpu_cores():
|
||||||
'''Get number of CPU cores and threads'''
|
'''Get number of CPU cores and threads'''
|
||||||
cores: int = psutil.cpu_count(logical=True)
|
cores: int = psutil.cpu_count(logical=False)
|
||||||
threads: int = psutil.cpu_count(logical=False)
|
threads: int = psutil.cpu_count(logical=True)
|
||||||
print(f'{cores} {threads if threads else cores}')
|
print(f'{cores} {threads if threads else cores}')
|
||||||
|
|
||||||
def get_cpu_usage():
|
def get_cpu_usage():
|
||||||
|
@ -220,11 +226,14 @@ def get_proc(sorting='cpu lazy', tree=False, prog_len=0, arg_len=0, search='', r
|
||||||
print(f"{'Pid:':>7} {'Program:':<{prog_len}}", f"{'Arguments:':<{arg_len-4}}" if arg_len else '', f"{'Threads:' if arg_len else ' Tr:'} {'User:':<9}Mem%{'Cpu%':>11}", sep='')
|
print(f"{'Pid:':>7} {'Program:':<{prog_len}}", f"{'Arguments:':<{arg_len-4}}" if arg_len else '', f"{'Threads:' if arg_len else ' Tr:'} {'User:':<9}Mem%{'Cpu%':>11}", sep='')
|
||||||
|
|
||||||
for p in sorted(psutil.process_iter(['pid', 'name', 'cmdline', 'num_threads', 'username', 'memory_percent', 'cpu_percent', 'cpu_times', 'create_time'], err), key=lambda p: eval(sort_cmd), reverse=reverse):
|
for p in sorted(psutil.process_iter(['pid', 'name', 'cmdline', 'num_threads', 'username', 'memory_percent', 'cpu_percent', 'cpu_times', 'create_time'], err), key=lambda p: eval(sort_cmd), reverse=reverse):
|
||||||
if p.info['name'] == 'idle':
|
if p.info['name'] == 'idle' or p.info['name'] == err or p.info['pid'] == err:
|
||||||
continue
|
continue
|
||||||
if p.info['cpu_times'] == err:
|
if p.info['cmdline'] == err:
|
||||||
|
p.info['cmdline'] = ""
|
||||||
|
if p.info['username'] == err:
|
||||||
|
p.info['username'] = "?"
|
||||||
|
if p.info['num_threads'] == err:
|
||||||
p.info['num_threads'] = 0
|
p.info['num_threads'] = 0
|
||||||
p.info['cmdline'] = ''
|
|
||||||
if search:
|
if search:
|
||||||
found = False
|
found = False
|
||||||
for value in [ p.info['name'], ' '.join(p.info['cmdline']), str(p.info['pid']), p.info['username'] ]:
|
for value in [ p.info['name'], ' '.join(p.info['cmdline']), str(p.info['pid']), p.info['username'] ]:
|
||||||
|
@ -281,6 +290,8 @@ def proc_tree(width: int, sorting: str = 'cpu lazy', reverse: bool = True, max_l
|
||||||
if getinfo and cont:
|
if getinfo and cont:
|
||||||
if getinfo['cpu_times'] == err:
|
if getinfo['cpu_times'] == err:
|
||||||
getinfo['num_threads'] = 0
|
getinfo['num_threads'] = 0
|
||||||
|
if p.info['username'] == err:
|
||||||
|
p.info['username'] = "?"
|
||||||
cpu = getinfo['cpu_percent'] if proc_per_cpu else (getinfo['cpu_percent'] / psutil.cpu_count())
|
cpu = getinfo['cpu_percent'] if proc_per_cpu else (getinfo['cpu_percent'] / psutil.cpu_count())
|
||||||
print(f"{getinfo['num_threads']:>4} " if getinfo['num_threads'] < 1000 else '999> ',
|
print(f"{getinfo['num_threads']:>4} " if getinfo['num_threads'] < 1000 else '999> ',
|
||||||
f"{getinfo['username']:<9.9}" if len(getinfo['username']) < 10 else f"{getinfo['username'][:8]:<8}+",
|
f"{getinfo['username']:<9.9}" if len(getinfo['username']) < 10 else f"{getinfo['username'][:8]:<8}+",
|
||||||
|
|
|
@ -60,7 +60,7 @@ theme[cpu_end]="#F92672"
|
||||||
|
|
||||||
# Mem/Disk free meter
|
# Mem/Disk free meter
|
||||||
theme[free_start]="#75715E"
|
theme[free_start]="#75715E"
|
||||||
theme[free_mid]="a9c474"
|
theme[free_mid]="#a9c474"
|
||||||
theme[free_end]="#e2f5bc"
|
theme[free_end]="#e2f5bc"
|
||||||
|
|
||||||
# Mem/Disk cached meter
|
# Mem/Disk cached meter
|
||||||
|
|
Loading…
Reference in New Issue