mirror of
https://github.com/aristocratos/btop.git
synced 2024-06-27 02:20:25 +12:00
commitc296ac13cd
Merge:9a1e760
091c30a
Author: Jakob P. Liljenberg <admin@qvantnet.com> Date: Sat Aug 26 19:29:57 2023 +0200 Merge pull request #590 from nobounce/dangling-reference-config Convert parameters and config keys to std::string_view commit9a1e760a66
Merge:9c8af4d
22e64ca
Author: Jakob P. Liljenberg <admin@qvantnet.com> Date: Sat Aug 26 19:20:18 2023 +0200 Merge pull request #602 from jfouquart/main Fix getting zfs pool name with '.' char in freebsd commit9c8af4df43
Merge:8a49d8c
2217cbe
Author: Jakob P. Liljenberg <admin@qvantnet.com> Date: Sat Aug 26 19:18:55 2023 +0200 Merge pull request #601 from joske/cleanup [macos] don't check /sys on macos commit8a49d8cf45
Merge:1556388
008fcd8
Author: Jakob P. Liljenberg <admin@qvantnet.com> Date: Sat Aug 26 19:18:07 2023 +0200 Merge pull request #600 from joske/makefile [macos/freebsd] support gcc13 commit1556388c83
Merge:1b126f5
d17e1a2
Author: Jakob P. Liljenberg <admin@qvantnet.com> Date: Sat Aug 26 19:14:00 2023 +0200 Merge pull request #599 from joske/main [macos] fix temp sensor on system with many cores commitd17e1a2dac
Author: Jos Dehaes <jos.dehaes@gmail.com> Date: Fri Aug 25 16:18:39 2023 +0200 fix some warnings commit4d8aa6b118
Author: Jos Dehaes <jos.dehaes@gmail.com> Date: Fri Aug 25 15:52:58 2023 +0200 fix core check commit22e64caaff
Author: Jonathan Fouquart <jfouquart@hotmail.fr> Date: Fri Aug 25 09:37:49 2023 +0200 Fix getting zfs pool name with '.' char in freebsd commit2217cbe143
Author: Jos Dehaes <jos.dehaes@gmail.com> Date: Wed Aug 23 16:01:04 2023 +0200 [macos] don't check /sys on macos commit008fcd889e
Author: Jos Dehaes <jos.dehaes@gmail.com> Date: Wed Aug 23 16:05:00 2023 +0200 also add g++13 commit0fdca5eb03
Author: Jos Dehaes <jos.dehaes@gmail.com> Date: Wed Aug 23 15:54:07 2023 +0200 support gcc13 commitdcbdb7360d
Author: Jos Dehaes <jos.dehaes@gmail.com> Date: Wed Aug 23 15:46:47 2023 +0200 [macos] fix temp sensor on system with many cores commit1b126f55e3
Author: aristocratos <gnmjpl@gmail.com> Date: Fri Aug 4 01:08:27 2023 +0200 Update Makefile for partial static compilation on freebsd commitc8ec6bbb00
Author: aristocratos <gnmjpl@gmail.com> Date: Thu Aug 3 23:08:33 2023 +0200 Fix freebsd nullptr changes and makefile for gcc12 and newer commit8a33aab588
Merge:94e5c02
e4abcef
Author: Jakob P. Liljenberg <admin@qvantnet.com> Date: Sun Jul 30 13:21:48 2023 +0200 Merge pull request #539 from nobounce/replace-NULL-nullptr Modernize using nullptr. commit94e5c02d11
Author: aristocratos <gnmjpl@gmail.com> Date: Thu Jul 27 20:51:21 2023 +0200 Better text editing commit091c30ab2b
Author: nobounce <steffen.winter@proton.me> Date: Thu Jul 27 14:17:54 2023 +0200 Convert parameters and config keys to std::string_view Using std::string_view instead of std::string& silences a new warning from GCC 13, -Wdangling-reference Also switch return type of `getI` from int& to int, trivial types are cheaper to copy by value commite4abcefbf9
Author: nobounce <steffen.winter@proton.me> Date: Wed Jul 26 16:19:17 2023 +0200 Use nullptr instead of NULL. See https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2431.pdf TLDR: NULL is of type int and relies on proper implicit pointer conversion which may lead to issues when using overloaded functions It is also considered a 'best practise' for modern C++ and conveys the programmers intention more precisly. commitd53307f14c
Author: nobounce <steffen.winter@proton.me> Date: Sun Jul 23 19:53:36 2023 +0200 Fix path to Linux CI file in itself The CI file has a list of dependent files including itself. The path was not updated when the CI was split into different files commit594f42b9eb
Merge:aca2e4b
53d6eba
Author: Jakob P. Liljenberg <admin@qvantnet.com> Date: Wed Jul 26 15:38:01 2023 +0200 Merge pull request #584 from nobounce/nb/fix-ci-path Fix path to Linux CI file in itself commitaca2e4be75
Author: aristocratos <gnmjpl@gmail.com> Date: Wed Jul 26 14:38:48 2023 +0200 Fix whitespace indent -> tab indent commit33faa01910
Author: aristocratos <gnmjpl@gmail.com> Date: Wed Jul 26 14:34:15 2023 +0200 Revert fmt submodule to static fmt folder in include commit53d6ebabc0
Author: nobounce <steffen.winter@proton.me> Date: Sun Jul 23 19:53:36 2023 +0200 Fix path to Linux CI file in itself The CI file has a list of dependent files including itself. The path was not updated when the CI was split into different files
117 lines
3.8 KiB
C++
117 lines
3.8 KiB
C++
/* Copyright 2021 Aristocratos (jakob@qvantnet.com)
|
|
|
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
you may not use this file except in compliance with the License.
|
|
You may obtain a copy of the License at
|
|
|
|
http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
Unless required by applicable law or agreed to in writing, software
|
|
distributed under the License is distributed on an "AS IS" BASIS,
|
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
See the License for the specific language governing permissions and
|
|
limitations under the License.
|
|
|
|
indent = tab
|
|
tab-size = 4
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include <string>
|
|
#include <vector>
|
|
#include <filesystem>
|
|
|
|
#include <robin_hood.h>
|
|
|
|
using std::string;
|
|
using std::vector;
|
|
using robin_hood::unordered_flat_map;
|
|
|
|
//* Functions and variables for reading and writing the btop config file
|
|
namespace Config {
|
|
|
|
extern std::filesystem::path conf_dir;
|
|
extern std::filesystem::path conf_file;
|
|
|
|
extern unordered_flat_map<std::string_view, string> strings;
|
|
extern unordered_flat_map<std::string_view, string> stringsTmp;
|
|
extern unordered_flat_map<std::string_view, bool> bools;
|
|
extern unordered_flat_map<std::string_view, bool> boolsTmp;
|
|
extern unordered_flat_map<std::string_view, int> ints;
|
|
extern unordered_flat_map<std::string_view, int> intsTmp;
|
|
|
|
const vector<string> valid_graph_symbols = { "braille", "block", "tty" };
|
|
const vector<string> valid_graph_symbols_def = { "default", "braille", "block", "tty" };
|
|
const vector<string> valid_boxes = { "cpu", "mem", "net", "proc", "gpu0", "gpu1", "gpu2", "gpu3", "gpu4", "gpu5" };
|
|
const vector<string> temp_scales = { "celsius", "fahrenheit", "kelvin", "rankine" };
|
|
|
|
extern vector<string> current_boxes;
|
|
extern vector<string> preset_list;
|
|
extern vector<string> available_batteries;
|
|
extern int current_preset;
|
|
|
|
//* Check if string only contains space separated valid names for boxes
|
|
bool check_boxes(const string& boxes);
|
|
|
|
//* Toggle box and update config string shown_boxes
|
|
void toggle_box(const string& box);
|
|
|
|
//* Parse and setup config value presets
|
|
bool presetsValid(const string& presets);
|
|
|
|
//* Apply selected preset
|
|
void apply_preset(const string& preset);
|
|
|
|
bool _locked(const std::string_view name);
|
|
|
|
//* Return bool for config key <name>
|
|
inline bool getB(const std::string_view name) { return bools.at(name); }
|
|
|
|
//* Return integer for config key <name>
|
|
inline const int& getI(const std::string_view name) { return ints.at(name); }
|
|
|
|
//* Return string for config key <name>
|
|
inline const string& getS(const std::string_view name) { return strings.at(name); }
|
|
|
|
string getAsString(const std::string_view name);
|
|
|
|
extern string validError;
|
|
|
|
bool intValid(const std::string_view name, const string& value);
|
|
bool stringValid(const std::string_view name, const string& value);
|
|
|
|
//* Set config key <name> to bool <value>
|
|
inline void set(const std::string_view name, bool value) {
|
|
if (_locked(name)) boolsTmp.insert_or_assign(name, value);
|
|
else bools.at(name) = value;
|
|
}
|
|
|
|
//* Set config key <name> to int <value>
|
|
inline void set(const std::string_view name, const int& value) {
|
|
if (_locked(name)) intsTmp.insert_or_assign(name, value);
|
|
else ints.at(name) = value;
|
|
}
|
|
|
|
//* Set config key <name> to string <value>
|
|
inline void set(const std::string_view name, const string& value) {
|
|
if (_locked(name)) stringsTmp.insert_or_assign(name, value);
|
|
else strings.at(name) = value;
|
|
}
|
|
|
|
//* Flip config key bool <name>
|
|
void flip(const std::string_view name);
|
|
|
|
//* Lock config and cache changes until unlocked
|
|
void lock();
|
|
|
|
//* Unlock config and write any cached values to config
|
|
void unlock();
|
|
|
|
//* Load the config file from disk
|
|
void load(const std::filesystem::path& conf_file, vector<string>& load_warnings);
|
|
|
|
//* Write the config file to disk
|
|
void write();
|
|
}
|