Compare commits

...

9 Commits

Author SHA1 Message Date
Steffen dd0e8a3f8b
Add regex filtering
Filters starting with '!' will try to match processes pid, name, cmd and
user with extended regex as defined by the C++ standard. A single '!'
will not filter.
2024-04-07 14:03:26 +02:00
Jakob P. Liljenberg d1680735d9
Merge pull request #796 from davc0n/main 2024-03-23 01:42:17 +01:00
Jakob P. Liljenberg a535a6eb92
Merge pull request #797 from kz6fittycent/main 2024-03-23 01:37:59 +01:00
Jakob P. Liljenberg b1b8249d55
Merge pull request #807 from kk9uk/main 2024-03-23 01:35:52 +01:00
kk9uk 4a82105547 [FEATURE] Add gruvbox_light theme 2024-03-20 12:17:24 +08:00
kz6fittycent 8af8389bd0
Merge branch 'aristocratos:main' into main 2024-03-13 11:02:55 -05:00
kz6fittycent adaea59a2a
Update test-snap-can-build.yml 2024-03-13 10:50:29 -05:00
kz6fittycent 2aa2c90f41
Update snapcraft.yaml
core22 attempt
2024-03-13 10:49:38 -05:00
Davide Conti a60c969533 Fix rsmi device name buffer size
ref. issue #794
2024-03-13 10:12:28 +01:00
9 changed files with 134 additions and 43 deletions

View File

@ -1,5 +1,4 @@
name: 🧪 Test snap can be built on x86_64
on:
workflow_dispatch:
push:
@ -28,7 +27,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [16.x]
node-version: [20.x]
steps:
- uses: actions/checkout@v2

View File

@ -6,7 +6,7 @@ description: |
C++ version and continuation of bashtop and bpytop.
license: Apache-2.0
base: core20
base: core22
grade: stable
confinement: strict
compression: lzo

View File

@ -17,6 +17,8 @@ tab-size = 4
*/
#include <ranges>
#include <regex>
#include <string>
#include "btop_config.hpp"
#include "btop_shared.hpp"
@ -111,6 +113,22 @@ namespace Proc {
}
}
bool matches_filter(const proc_info& proc, const std::string& filter) {
if (filter.starts_with("!")) {
if (filter.size() == 1) {
return true;
}
std::regex regex{filter.substr(1), std::regex::extended};
return std::regex_search(std::to_string(proc.pid), regex) ||
std::regex_search(proc.name, regex) || std::regex_match(proc.cmd, regex) ||
std::regex_search(proc.user, regex);
} else {
return s_contains(std::to_string(proc.pid), filter) ||
s_contains_ic(proc.name, filter) || s_contains_ic(proc.cmd, filter) ||
s_contains_ic(proc.user, filter);
}
}
void _tree_gen(proc_info& cur_proc, vector<proc_info>& in_procs, vector<tree_proc>& out_procs,
int cur_depth, bool collapsed, const string& filter, bool found, bool no_update, bool should_filter) {
auto cur_pos = out_procs.size();
@ -118,10 +136,7 @@ namespace Proc {
//? If filtering, include children of matching processes
if (not found and (should_filter or not filter.empty())) {
if (not s_contains(std::to_string(cur_proc.pid), filter)
and not s_contains_ic(cur_proc.name, filter)
and not s_contains_ic(cur_proc.cmd, filter)
and not s_contains_ic(cur_proc.user, filter)) {
if (!matches_filter(cur_proc, filter)) {
filtering = true;
cur_proc.filtered = true;
filter_found++;

View File

@ -424,6 +424,8 @@ namespace Proc {
void tree_sort(vector<tree_proc>& proc_vec, const string& sorting,
bool reverse, int& c_index, const int index_max, bool collapsed = false);
bool matches_filter(const proc_info& proc, const std::string& filter);
//* Generate process tree list
void _tree_gen(proc_info& cur_proc, vector<proc_info>& in_procs, vector<tree_proc>& out_procs,
int cur_depth, bool collapsed, const string& filter,

View File

@ -1239,18 +1239,13 @@ namespace Proc {
filter_found = 0;
for (auto& p : current_procs) {
if (not tree and not filter.empty()) {
if (not s_contains_ic(to_string(p.pid), filter)
and not s_contains_ic(p.name, filter)
and not s_contains_ic(p.cmd, filter)
and not s_contains_ic(p.user, filter)) {
p.filtered = true;
filter_found++;
}
else {
p.filtered = false;
}
if (!matches_filter(p, filter)) {
p.filtered = true;
filter_found++;
} else {
p.filtered = false;
}
else {
} else {
p.filtered = false;
}
}

View File

@ -160,6 +160,7 @@ namespace Gpu {
namespace Rsmi {
#if !defined(RSMI_STATIC)
//? RSMI defines, structs & typedefs
#define RSMI_DEVICE_NAME_BUFFER_SIZE 128
#define RSMI_MAX_NUM_FREQUENCIES_V5 32
#define RSMI_MAX_NUM_FREQUENCIES_V6 33
#define RSMI_STATUS_SUCCESS 0
@ -1396,8 +1397,8 @@ namespace Gpu {
for (uint32_t i = 0; i < device_count; ++i) {
if constexpr(is_init) {
//? Device name
char name[NVML_DEVICE_NAME_BUFFER_SIZE]; // ROCm SMI does not provide a constant for this as far as I can tell, this should be good enough
result = rsmi_dev_name_get(i, name, NVML_DEVICE_NAME_BUFFER_SIZE);
char name[RSMI_DEVICE_NAME_BUFFER_SIZE];
result = rsmi_dev_name_get(i, name, RSMI_DEVICE_NAME_BUFFER_SIZE);
if (result != RSMI_STATUS_SUCCESS)
Logger::warning("ROCm SMI: Failed to get device name");
else gpu_names[Nvml::device_count + i] = string(name);
@ -2793,18 +2794,13 @@ namespace Proc {
filter_found = 0;
for (auto& p : current_procs) {
if (not tree and not filter.empty()) {
if (not s_contains_ic(to_string(p.pid), filter)
and not s_contains_ic(p.name, filter)
and not s_contains_ic(p.cmd, filter)
and not s_contains_ic(p.user, filter)) {
p.filtered = true;
filter_found++;
}
else {
p.filtered = false;
}
if (!matches_filter(p, filter)) {
p.filtered = true;
filter_found++;
} else {
p.filtered = false;
}
else {
} else {
p.filtered = false;
}
}

View File

@ -1171,18 +1171,13 @@ namespace Proc {
filter_found = 0;
for (auto& p : current_procs) {
if (not tree and not filter.empty()) {
if (not s_contains_ic(to_string(p.pid), filter)
and not s_contains_ic(p.name, filter)
and not s_contains_ic(p.cmd, filter)
and not s_contains_ic(p.user, filter)) {
p.filtered = true;
filter_found++;
}
else {
p.filtered = false;
}
if (!matches_filter(p, filter)) {
p.filtered = true;
filter_found++;
} else {
p.filtered = false;
}
else {
} else {
p.filtered = false;
}
}

View File

@ -1301,7 +1301,7 @@ namespace Proc {
filter_found = 0;
for (auto &p : current_procs) {
if (not tree and not filter.empty()) {
if (not s_contains_ic(to_string(p.pid), filter) and not s_contains_ic(p.name, filter) and not s_contains_ic(p.cmd, filter) and not s_contains_ic(p.user, filter)) {
if (!matches_filter(p, filter)) {
p.filtered = true;
filter_found++;
} else {

View File

@ -0,0 +1,89 @@
# Btop gruvbox_light theme
# by kk9uk
# Main background, empty for terminal default, need to be empty if you want transparent background
theme[main_bg]="#fbf1c7"
# Main text color
theme[main_fg]="#3c3836"
# Title color for boxes
theme[title]="#3c3836"
# Highlight color for keyboard shortcuts
theme[hi_fg]="#cc241d"
# Background color of selected items
theme[selected_bg]="#f2e5bc"
# Foreground color of selected items
theme[selected_fg]="#8f3f71"
# Color of inactive/disabled text
theme[inactive_fg]="#ebdbb2"
# Color of text appearing on top of graphs, i.e uptime and current network graph scaling
theme[graph_text]="#a89984"
# Misc colors for processes box including mini cpu graphs, details memory graph and details status text
theme[proc_misc]="#98971a"
# Cpu box outline color
theme[cpu_box]="#a89984"
# Memory/disks box outline color
theme[mem_box]="#a89984"
# Net up/down box outline color
theme[net_box]="#a89984"
# Processes box outline color
theme[proc_box]="#a89984"
# Box divider line and small boxes line color
theme[div_line]="#a89984"
# Temperature graph colors
theme[temp_start]="#98971a"
theme[temp_mid]=""
theme[temp_end]="#cc241d"
# CPU graph colors
theme[cpu_start]="#427b58"
theme[cpu_mid]="#d79921"
theme[cpu_end]="#cc241d"
# Mem/Disk free meter
theme[free_start]="#cc241d"
theme[free_mid]="#d79921"
theme[free_end]="#427b58"
# Mem/Disk cached meter
theme[cached_start]="#458588"
theme[cached_mid]="#076678"
theme[cached_end]="#427b58"
# Mem/Disk available meter
theme[available_start]="#cc241d"
theme[available_mid]="#d65d0e"
theme[available_end]="#b57614"
# Mem/Disk used meter
theme[used_start]="#427b58"
theme[used_mid]="#d65d0e"
theme[used_end]="#cc241d"
# Download graph colors
theme[download_start]="#98971a"
theme[download_mid]="#689d6a"
theme[download_end]="#79740e"
# Upload graph colors
theme[upload_start]="#cc241d"
theme[upload_mid]="#d65d0e"
theme[upload_end]="#b57614"
# Process box color gradient for threads, mem and cpu usage
theme[process_start]="#427b58"
theme[process_mid]="#af3a03"
theme[process_end]="#cc241d"