From 73119d33b93ace942038ef7668e32f0d9e6ef413 Mon Sep 17 00:00:00 2001 From: zack kourouma Date: Mon, 27 Sep 2021 12:27:17 -0700 Subject: [PATCH 1/3] Add night-owl theme Inspired by sdras' VS Code theme: https://github.com/sdras/night-owl-vscode-theme --- themes/night-owl.theme | 92 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 92 insertions(+) create mode 100644 themes/night-owl.theme diff --git a/themes/night-owl.theme b/themes/night-owl.theme new file mode 100644 index 0000000..de1b361 --- /dev/null +++ b/themes/night-owl.theme @@ -0,0 +1,92 @@ +#Bashtop theme with night-owl colors +#by zkourouma + +# Colors should be in 6 or 2 character hexadecimal or single spaced rgb decimal: "#RRGGBB", "#BW" or "0-255 0-255 0-255" +# example for white: "#ffffff", "#ff" or "255 255 255". + +# All graphs and meters can be gradients +# For single color graphs leave "mid" and "end" variable empty. +# Use "start" and "end" variables for two color gradient +# Use "start", "mid" and "end" for three color gradient + +# Main background, empty for terminal default, need to be empty if you want transparent background +theme[main_bg]="#011627" + +# Main text color +theme[main_fg]="#d6deeb" + +# Title color for boxes +theme[title]="#ffffff" + +# Higlight color for keyboard shortcuts +theme[hi_fg]="#addb67" + +# Background color of selected items +theme[selected_bg]="#000000" + +# Foreground color of selected items +theme[selected_fg]="#ffeb95" + +# Color of inactive/disabled text +theme[inactive_fg]="#000000" + +# Color of text appearing on top of graphs, i.e uptime and current network graph scaling +theme[graph_text]="#585858" + +# Misc colors for processes box including mini cpu graphs, details memory graph and details status text +theme[proc_misc]="#22da6e" + +# Cpu box outline color +theme[cpu_box]="#ffffff" + +# Memory/disks box outline color +theme[mem_box]="#ffffff" + +# Net up/down box outline color +theme[net_box]="#ffffff" + +# Processes box outline color +theme[proc_box]="#ffffff" + +# Box divider line and small boxes line color +theme[div_line]="#ffffff" + +# Temperature graph colors +theme[temp_start]="#82aaff" +theme[temp_mid]="#c792ea" +theme[temp_end]="#fb4394" + +# CPU graph colors +theme[cpu_start]="#22da6e" +theme[cpu_mid]="#addb67" +theme[cpu_end]="#ef5350" + +# Mem/Disk free meter +theme[free_start]="#4e5900" +theme[free_mid]="" +theme[free_end]="#22da6e" + +# Mem/Disk cached meter +theme[cached_start]="#82aaff" +theme[cached_mid]="" +theme[cached_end]="#82aaff" + +# Mem/Disk available meter +theme[available_start]="#addb67" +theme[available_mid]="" +theme[available_end]="#ffeb95" + +# Mem/Disk used meter +theme[used_start]="#ef5350" +theme[used_mid]="" +theme[used_end]="#ef5350" + +# Download graph colors +theme[download_start]="#3d4070" +theme[download_mid]="#6c71c4" +theme[download_end]="#a3a8f7" + +# Upload graph colors +theme[upload_start]="#701c45" +theme[upload_mid]="#c792ea" +theme[upload_end]="#c792ea" From a1fa532914a35364bf6790ead74da186a9b52c22 Mon Sep 17 00:00:00 2001 From: zack kourouma Date: Mon, 27 Sep 2021 18:40:26 -0700 Subject: [PATCH 2/3] More readable inactive/disabled text --- themes/night-owl.theme | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/themes/night-owl.theme b/themes/night-owl.theme index de1b361..7537fea 100644 --- a/themes/night-owl.theme +++ b/themes/night-owl.theme @@ -28,7 +28,7 @@ theme[selected_bg]="#000000" theme[selected_fg]="#ffeb95" # Color of inactive/disabled text -theme[inactive_fg]="#000000" +theme[inactive_fg]="#575656" # Color of text appearing on top of graphs, i.e uptime and current network graph scaling theme[graph_text]="#585858" From a246c098cd6ca794b8c6a6680f6c50b22e1b0797 Mon Sep 17 00:00:00 2001 From: aristocratos Date: Wed, 29 Sep 2021 21:24:33 +0200 Subject: [PATCH 3/3] v1.0.11 Bug fixes --- CHANGELOG.md | 10 ++++++++++ src/btop.cpp | 29 +++++++++++++++-------------- src/btop_tools.cpp | 1 - src/btop_tools.hpp | 8 +------- 4 files changed, 26 insertions(+), 22 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 10532f5..9ec21b0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,13 @@ +## v1.0.11 + +* Changed: atomic_wait to use while loop instead of wait() because of rare stall when a signal handler is triggered while waiting + +* Fixed: Get real / mountpoint when running inside snap + +* Fixed: UTF8 set LANG and LC_ALL to empty before UTF8 search and fixed empty error msg on exit before signal handler init + +* Changed: Init will continue with a warning if UTF-8 locale are detected and it fails to set the locale + ## v1.0.10 * Added: Wait for terminal size properties to be available at start diff --git a/src/btop.cpp b/src/btop.cpp index 50a2bba..02ca177 100644 --- a/src/btop.cpp +++ b/src/btop.cpp @@ -55,7 +55,7 @@ namespace Global { {"#801414", "██████╔╝ ██║ ╚██████╔╝██║ ╚═╝ ╚═╝"}, {"#000000", "╚═════╝ ╚═╝ ╚═════╝ ╚═╝"}, }; - const string Version = "1.0.10"; + const string Version = "1.0.11"; int coreCount; string overlay; @@ -712,20 +712,21 @@ int main(int argc, char **argv) { } //? Try to find and set a UTF-8 locale - if (std::setlocale(LC_ALL, "") != NULL and str_to_upper(s_replace((string)std::setlocale(LC_ALL, ""), "-", "")).ends_with("UTF8")) { + if (std::setlocale(LC_ALL, "") != NULL and not s_contains((string)std::setlocale(LC_ALL, ""), ";") + and str_to_upper(s_replace((string)std::setlocale(LC_ALL, ""), "-", "")).ends_with("UTF8")) { Logger::debug("Using locale " + (string)std::setlocale(LC_ALL, "")); } else { string found; - if (std::getenv("LANG") != NULL and str_to_upper(s_replace((string)std::getenv("LANG"), "-", "")).ends_with("UTF8")) { - found = std::getenv("LANG"); - if (std::setlocale(LC_ALL, std::getenv("LANG")) == NULL) - Logger::warning("Failed to set locale " + (string)std::getenv("LANG") + " continuing anyway."); - } - if (found.empty() and std::getenv("LC_ALL") != NULL and str_to_upper(s_replace((string)std::getenv("LC_ALL"), "-", "")).ends_with("UTF8")) { - found = std::getenv("LC_ALL"); - if (std::setlocale(LC_ALL, std::getenv("LC_ALL")) == NULL) - Logger::warning("Failed to set locale " + (string)std::getenv("LC_ALL") + " continuing anyway."); + bool set_failure = false; + for (const auto loc_env : array{"LANG", "LC_ALL"}) { + if (std::getenv(loc_env) != NULL and str_to_upper(s_replace((string)std::getenv(loc_env), "-", "")).ends_with("UTF8")) { + found = std::getenv(loc_env); + if (std::setlocale(LC_ALL, found.c_str()) == NULL) { + set_failure = true; + Logger::warning("Failed to set locale " + found + " continuing anyway."); + } + } } if (found.empty()) { if (setenv("LC_ALL", "", 1) == 0 and setenv("LANG", "", 1) == 0) { @@ -733,8 +734,8 @@ int main(int argc, char **argv) { if (const auto loc = std::locale("").name(); not loc.empty() and loc != "*") { for (auto& l : ssplit(loc, ';')) { if (str_to_upper(s_replace(l, "-", "")).ends_with("UTF8")) { - if (std::setlocale(LC_ALL, l.substr(l.find('=') + 1).c_str()) != NULL) { - found = l; + found = l.substr(l.find('=') + 1); + if (std::setlocale(LC_ALL, found.c_str()) != NULL) { break; } } @@ -751,7 +752,7 @@ int main(int argc, char **argv) { Global::exit_error_msg = "No UTF-8 locale detected!\nUse --utf-force argument to force start if you're sure your terminal can handle it."; clean_quit(1); } - else + else if (not set_failure) Logger::debug("Setting LC_ALL=" + found); } diff --git a/src/btop_tools.cpp b/src/btop_tools.cpp index dc3a0bd..c897b1b 100644 --- a/src/btop_tools.cpp +++ b/src/btop_tools.cpp @@ -329,7 +329,6 @@ namespace Tools { atomic_lock::~atomic_lock() { active_locks--; this->atom.store(false); - atomic_notify(this->atom); } string readfile(const std::filesystem::path& path, const string& fallback) { diff --git a/src/btop_tools.hpp b/src/btop_tools.hpp index 7bb0445..97e010a 100644 --- a/src/btop_tools.hpp +++ b/src/btop_tools.hpp @@ -269,15 +269,9 @@ namespace Tools { string hostname(); string username(); -// #if __GNUC__ < 11 inline void atomic_wait(const atomic& atom, const bool old=true) noexcept { while (atom.load() == old) sleep_ms(1); } - inline void atomic_notify(const atomic& atom) noexcept { (void)atom; } -// #else -// inline void atomic_wait(const atomic& atom, const bool old=true) noexcept { if (atom == old) atom.wait(old); } -// inline void atomic_notify(const atomic& atom) noexcept { atom.notify_all(); } -// #endif - //* Waits for atomic to be false and sets it to true on construct, sets to false and notifies on destruct + //* Waits for atomic to be false and sets it to true on construct, sets to false on destruct class atomic_lock { atomic& atom; bool not_true = false;