Skip to content

Commit

Permalink
Merge branch 'aristocratos:main' into battery-power-2
Browse files Browse the repository at this point in the history
  • Loading branch information
vsey authored Jan 22, 2024
2 parents b28c5ff + b2df503 commit 40cdb92
Show file tree
Hide file tree
Showing 14 changed files with 169 additions and 113 deletions.
14 changes: 13 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
## v1.3.0

* Added Gpu Support | @romner-set | PR #529
* Added Gpu Support Linux | @romner-set | PR #529

* Added platform support for OpenBSD | @joske | PR #607

* Enable macos clang | @muneebmahmed | PR #666

Expand Down Expand Up @@ -42,6 +44,16 @@

* Create adwaita.theme | @flipflop133 | #485

* Try get terminal size of "/dev/tty" if stdout fails | @imwints | PR #627

* Refresh rate program argument | @imwints | PR #640

* Improved error handling when determining the config directory | @imwints | #652

* Use native POSIX polling syscalls to read input | @lvxnull | #624

* Conditional compile on Big Sur and up | @joske | PR #690

+ Various fixes by @imwints, @simplepad, @joske, @gwena, @cpalv, @iambeingtracked, @mattico, @NexAdn

## v1.2.13
Expand Down
7 changes: 4 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ if("${CMAKE_CURRENT_SOURCE_DIR}" STREQUAL "${CMAKE_CURRENT_BINARY_DIR}")
endif()

project("btop"
VERSION 1.2.13
VERSION 1.3.0
DESCRIPTION "A monitor of resources"
HOMEPAGE_URL "https://github.com/aristocratos/btop"
LANGUAGES CXX
Expand Down Expand Up @@ -41,6 +41,7 @@ option(BTOP_LTO "Enable LTO" ON)
option(BTOP_USE_MOLD "Use mold to link btop" OFF)
option(BTOP_PEDANTIC "Enable a bunch of additional warnings" OFF)
option(BTOP_WERROR "Compile with warnings as errors" OFF)
option(BTOP_FORTIFY "Detect buffer overflows with _FORTIFY_SOURCE=3" ON)
option(BTOP_GPU "Enable GPU support" ON)
cmake_dependent_option(BTOP_RSMI_STATIC "Link statically to ROCm SMI" OFF "BTOP_GPU" OFF)

Expand Down Expand Up @@ -97,7 +98,7 @@ if(BTOP_WERROR)
endif()

if(NOT APPLE)
target_compile_options(btop PRIVATE -fstack-clash-protection)
target_compile_options(btop PRIVATE -fstack-clash-protection)
endif()
check_cxx_compiler_flag(-fstack-protector HAS_FSTACK_PROTECTOR)
if(HAS_FSTACK_PROTECTOR)
Expand All @@ -112,7 +113,7 @@ target_compile_definitions(btop PRIVATE
_FILE_OFFSET_BITS=64
$<$<CONFIG:Debug>:_GLIBCXX_ASSERTIONS _LIBCPP_ENABLE_ASSERTIONS=1>
# Only has an effect with optimizations enabled
$<$<NOT:$<CONFIG:Debug>>:_FORTIFY_SOURCE=2>
$<$<AND:$<NOT:$<CONFIG:Debug>>,$<BOOL:${BTOP_FORTIFY}>>:_FORTIFY_SOURCE=3>
)

target_include_directories(btop SYSTEM PRIVATE include)
Expand Down
7 changes: 6 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,11 @@ ifeq ($(GPU_SUPPORT),true)
override ADDFLAGS += -DGPU_SUPPORT
endif

FORTIFY_SOURCE ?= true
ifeq ($(FORTIFY_SOURCE),true)
override ADDFLAGS += -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=3
endif

#? Compiler and Linker
ifeq ($(shell $(CXX) --version | grep clang >/dev/null 2>&1; echo $$?),0)
override CXX_IS_CLANG := true
Expand Down Expand Up @@ -174,7 +179,7 @@ override GOODFLAGS := $(foreach flag,$(TESTFLAGS),$(strip $(shell echo "int main
override REQFLAGS := -std=c++20
WARNFLAGS := -Wall -Wextra -pedantic
OPTFLAGS := -O2 -ftree-vectorize -flto=$(LTO)
LDCXXFLAGS := -pthread -D_FORTIFY_SOURCE=2 -D_GLIBCXX_ASSERTIONS -D_FILE_OFFSET_BITS=64 $(GOODFLAGS) $(ADDFLAGS)
LDCXXFLAGS := -pthread -D_GLIBCXX_ASSERTIONS -D_FILE_OFFSET_BITS=64 $(GOODFLAGS) $(ADDFLAGS)
override CXXFLAGS += $(REQFLAGS) $(LDCXXFLAGS) $(OPTFLAGS) $(WARNFLAGS)
override LDFLAGS += $(LDCXXFLAGS) $(OPTFLAGS) $(WARNFLAGS)
INC := $(foreach incdir,$(INCDIRS),-isystem $(incdir)) -I$(SRCDIR)
Expand Down
38 changes: 35 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,15 @@

## News

##### 7 January 2024

Btop release v1.3.0

Big release with GPU support added for Linux and platform support for OpenBSD. Big thanks to [@romner-set](https://github.com/romner-set) (GPU support) and [@joske](https://github.com/joske) (OpenBSD support) for contributions.
And a multitude of bugfixes and small changes, see [CHANGELOG.md](CHANGELOG.md) and latest [release](https://github.com/aristocratos/btop/releases/latest) for detailed list and attributions.

See news entry below for more information regarding GPU support.

##### 25 November 2023

GPU monitoring added for Linux!
Expand All @@ -69,6 +78,9 @@ Big update with version bump to 1.3 coming soon.

First release of btop4win available at https://github.com/aristocratos/btop4win

<details>
<summary>More...</summary>

##### 16 January 2022

Release v1.2.0 with FreeBSD support. No release binaries for FreeBSD provided as of yet.
Expand All @@ -84,9 +96,6 @@ macOS binaries + installer are included for both x86 and ARM64 (Apple Silicon) i

Big thank you to [@joske](https://github.com/joske) who wrote the vast majority of the implementation!

<details>
<summary>More...</summary>

##### 30 October 2021

Work on the OSX [macOS] and FreeBSD branches, both initiated and mostly worked on by [@joske](https://github.com/joske), will likely be completed in the coming weeks.
Expand Down Expand Up @@ -213,6 +222,22 @@ Also needs a UTF8 locale and a font that covers:
* Unicode Block “Geometric Shapes” U+25A0 - U+25FF
* Unicode Block "Box Drawing" and "Block Elements" U+2500 - U+259F

### **Optional Dependencies (Needed for GPU monitoring)**

GPU monitoring also requires a btop binary built with GPU support (`GPU_SUPPORT=true` flag).

See [GPU compatibility](#gpu-compatibility) section for more about compiling with GPU support.

* **NVIDIA**

If you have an NVIDIA GPU you must use an official NVIDIA driver, both the closed-source and open-source ones have been verified to work.

In addition to that you must also have the nvidia-ml dynamic library installed, which should be included with the driver package of your distribution.

* **AMD**

If you have an AMD GPU `rocm_smi_lib` is required, which may or may not be packaged for your distribution.

### **Notice (Text rendering issues)**

* If you are having problems with the characters in the graphs not looking like they do in the screenshots, it's likely a problem with your systems configured fallback font not having support for braille characters.
Expand Down Expand Up @@ -396,6 +421,7 @@ Also needs a UTF8 locale and a font that covers:
| `STRIP=true` | To force stripping of debug symbols (adds `-s` linker flag) |
| `DEBUG=true` | Sets OPTFLAGS to `-O0 -g` and enables more verbose debug logging |
| `ARCH=<architecture>` | To manually set the target architecture |
| `FORTIFY_SOURCE=false` | Disable fortification with `_FORTIFY_SOURCE=3` |
| `GPU_SUPPORT=<true\|false>` | Enable/disable GPU support (Enabled by default on X86_64 Linux) |
| `RSMI_STATIC=true` | To statically link the ROCm SMI library used for querying AMDGPU |
| `ADDFLAGS=<flags>` | For appending flags to both compiler and linker |
Expand Down Expand Up @@ -494,6 +520,7 @@ Also needs a UTF8 locale and a font that covers:
| `-DBTOP_USE_MOLD=<ON\|OFF>` | Use mold to link btop (OFF by default) |
| `-DBTOP_PEDANTIC=<ON\|OFF>` | Compile with additional warnings (OFF by default) |
| `-DBTOP_WERROR=<ON\|OFF>` | Compile with warnings as errors (OFF by default) |
| `-DBTOP_FORTIFY=<ON\|OFF>` | Detect buffer overflows with `_FORTIFY_SOURCE=3` (ON by default) |
| `-DBTOP_GPU=<ON\|OFF>` | Enable GPU support (ON by default) |
| `-DBTOP_RSMI_STATIC=<ON\|OFF>` | Build and link the ROCm SMI library statically (OFF by default) |
| `-DCMAKE_INSTALL_PREFIX=<path>` | The installation prefix ('/usr/local' by default) |
Expand Down Expand Up @@ -567,6 +594,7 @@ Also needs a UTF8 locale and a font that covers:
| `STRIP=true` | To force stripping of debug symbols (adds `-s` linker flag) |
| `DEBUG=true` | Sets OPTFLAGS to `-O0 -g` and enables more verbose debug logging |
| `ARCH=<architecture>` | To manually set the target architecture |
| `FORTIFY_SOURCE=false` | Disable fortification with `_FORTIFY_SOURCE=3` |
| `ADDFLAGS=<flags>` | For appending flags to both compiler and linker |
| `CXX=<compiler>` | Manualy set which compiler to use |
Expand Down Expand Up @@ -665,6 +693,7 @@ Also needs a UTF8 locale and a font that covers:
| `-DBTOP_USE_MOLD=<ON\|OFF>` | Use mold to link btop (OFF by default) |
| `-DBTOP_PEDANTIC=<ON\|OFF>` | Compile with additional warnings (OFF by default) |
| `-DBTOP_WERROR=<ON\|OFF>` | Compile with warnings as errors (OFF by default) |
| `-DBTOP_FORTIFY=<ON\|OFF>` | Detect buffer overflows with `_FORTIFY_SOURCE=3` (ON by default) |
| `-DCMAKE_INSTALL_PREFIX=<path>` | The installation prefix ('/usr/local' by default) |
To force any specific compiler, run `CXX=<compiler> cmake -B build -G Ninja`
Expand Down Expand Up @@ -733,6 +762,7 @@ Also needs a UTF8 locale and a font that covers:
| `STRIP=true` | To force stripping of debug symbols (adds `-s` linker flag) |
| `DEBUG=true` | Sets OPTFLAGS to `-O0 -g` and enables more verbose debug logging |
| `ARCH=<architecture>` | To manually set the target architecture |
| `FORTIFY_SOURCE=false` | Disable fortification with `_FORTIFY_SOURCE=3` |
| `ADDFLAGS=<flags>` | For appending flags to both compiler and linker |
| `CXX=<compiler>` | Manualy set which compiler to use |
Expand Down Expand Up @@ -842,6 +872,7 @@ Also needs a UTF8 locale and a font that covers:
| `-DBTOP_USE_MOLD=<ON\|OFF>` | Use mold to link btop (OFF by default) |
| `-DBTOP_PEDANTIC=<ON\|OFF>` | Compile with additional warnings (OFF by default) |
| `-DBTOP_WERROR=<ON\|OFF>` | Compile with warnings as errors (OFF by default) |
| `-DBTOP_FORTIFY=<ON\|OFF>` | Detect buffer overflows with `_FORTIFY_SOURCE=3` (ON by default) |
| `-DCMAKE_INSTALL_PREFIX=<path>` | The installation prefix ('/usr/local' by default) |
_**Note:** Static linking does not work with GCC._
Expand Down Expand Up @@ -912,6 +943,7 @@ Also needs a UTF8 locale and a font that covers:
| `STRIP=true` | To force stripping of debug symbols (adds `-s` linker flag) |
| `DEBUG=true` | Sets OPTFLAGS to `-O0 -g` and enables more verbose debug logging |
| `ARCH=<architecture>` | To manually set the target architecture |
| `FORTIFY_SOURCE=false` | Disable fortification with `_FORTIFY_SOURCE=3` |
| `ADDFLAGS=<flags>` | For appending flags to both compiler and linker |
| `CXX=<compiler>` | Manualy set which compiler to use |
Expand Down
26 changes: 16 additions & 10 deletions src/btop.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,9 @@ namespace Global {
string exit_error_msg;
atomic<bool> thread_exception (false);

bool debuginit{}; // defaults to false
bool debug{}; // defaults to false
bool utf_force{}; // defaults to false
bool debuginit{};
bool debug{};
bool utf_force{};

uint64_t start_time;

Expand All @@ -107,9 +107,10 @@ namespace Global {
atomic<bool> should_quit (false);
atomic<bool> should_sleep (false);
atomic<bool> _runner_started (false);
atomic<bool> init_conf (false);

bool arg_tty{}; // defaults to false
bool arg_low_color{}; // defaults to false
bool arg_tty{};
bool arg_low_color{};
int arg_preset = -1;
int arg_update = 0;
}
Expand Down Expand Up @@ -418,7 +419,7 @@ namespace Runner {

string output;
string empty_bg;
bool pause_output{}; // defaults to false
bool pause_output{};
sigset_t mask;
pthread_t runner_id;
pthread_mutex_t mtx;
Expand Down Expand Up @@ -894,10 +895,10 @@ int main(int argc, char **argv) {
}

//? Config init
{ vector<string> load_warnings;
{
atomic_lock lck(Global::init_conf);
vector<string> load_warnings;
Config::load(Config::conf_file, load_warnings);

if (Config::current_boxes.empty()) Config::check_boxes(Config::getS("shown_boxes"));
Config::set("lowcolor", (Global::arg_low_color ? true : not Config::getB("truecolor")));

if (Global::debug) {
Expand All @@ -918,7 +919,7 @@ int main(int argc, char **argv) {
}
else {
string found;
bool set_failure{}; // defaults to false
bool set_failure{};
for (const auto loc_env : array{"LANG", "LC_ALL"}) {
if (std::getenv(loc_env) != nullptr and str_to_upper(s_replace((string)std::getenv(loc_env), "-", "")).ends_with("UTF8")) {
found = std::getenv(loc_env);
Expand Down Expand Up @@ -1018,6 +1019,11 @@ int main(int argc, char **argv) {
clean_quit(1);
}

if (not Config::check_boxes(Config::getS("shown_boxes"))) {
Config::check_boxes("cpu mem net proc");
Config::set("shown_boxes", "cpu mem net proc"s);
}

//? Update list of available themes and generate the selected theme
Theme::updateThemes();
Theme::setTheme();
Expand Down
5 changes: 2 additions & 3 deletions src/btop_config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -510,7 +510,7 @@ namespace Config {
else if (name.starts_with("graph_symbol_") and (value != "default" and not v_contains(valid_graph_symbols, value)))
validError = fmt::format("Invalid graph symbol identifier for {}: {}", name, value);

else if (name == "shown_boxes" and not value.empty() and not check_boxes(value))
else if (name == "shown_boxes" and not Global::init_conf and not value.empty() and not check_boxes(value))
validError = "Invalid box name(s) in shown_boxes!";

#ifdef GPU_SUPPORT
Expand Down Expand Up @@ -622,8 +622,7 @@ namespace Config {
if (not v_contains(valid_boxes, box)) return false;
#ifdef GPU_SUPPORT
if (box.starts_with("gpu")) {
size_t gpu_num = stoi(box.substr(3));
if (gpu_num == 0) gpu_num = 5;
size_t gpu_num = stoi(box.substr(3)) + 1;
if (std::cmp_greater(gpu_num, Gpu::gpu_names.size())) return false;
}
#endif
Expand Down
6 changes: 3 additions & 3 deletions src/btop_draw.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -307,8 +307,8 @@ namespace Draw {
{"/uptime", ""}
};

static time_t c_time{}; // defaults to 0
static size_t clock_len{}; // defaults to 0
static time_t c_time{};
static size_t clock_len{};
static string clock_str;

if (auto n_time = time(nullptr); not force and n_time == c_time)
Expand Down Expand Up @@ -2013,7 +2013,7 @@ namespace Draw {
#ifdef GPU_SUPPORT
const bool show_gpu_on = Config::getS("show_gpu_info") == "On";
const bool gpus_shown_in_cpu_panel = Gpu::gpu_names.size() > 0 and (
show_gpu_on or (Config::getS("cpu_graph_lower") == "Auto" and Gpu::shown == 0)
show_gpu_on or (Config::getS("show_gpu_info") == "Auto" and Gpu::shown == 0)
);
const int gpus_height_offset = (Gpu::gpu_names.size() - Gpu::shown)*gpus_shown_in_cpu_panel;
int gpus_extra_height = gpus_shown_in_cpu_panel ? Gpu::gpu_names.size() - (show_gpu_on ? 0 : Gpu::shown) : 0;
Expand Down
4 changes: 2 additions & 2 deletions src/btop_draw.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@ namespace Draw {

//* An editable text field
class TextEdit {
size_t pos{}; // defaults to 0
size_t upos{}; // defaults to 0
size_t pos{};
size_t upos{};
bool numeric;
public:
string text;
Expand Down
Loading

0 comments on commit 40cdb92

Please sign in to comment.