Skip to content

Commit fdcc9a1

Browse files
committed
core: add -v and --verbose
fixes #28
1 parent 7b7339f commit fdcc9a1

File tree

3 files changed

+15
-3
lines changed

3 files changed

+15
-3
lines changed

src/Hyprsunset.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ int CHyprsunset::init() {
8787
const std::string IFACE = interface;
8888

8989
if (IFACE == hyprland_ctm_control_manager_v1_interface.name) {
90-
auto targetVersion = std::min(version, 2u);
90+
auto targetVersion = std::min(version, 2u);
9191

9292
Debug::log(NONE, "┣ Found hyprland-ctm-control-v1 supported with version {}, binding to v{}", version, targetVersion);
9393
state.pCTMMgr = makeShared<CCHyprlandCtmControlManagerV1>(

src/helpers/Log.hpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,13 @@ enum LogLevel {
1616
};
1717

1818
namespace Debug {
19+
inline bool trace = false;
20+
1921
template <typename... Args>
2022
void log(LogLevel level, std::format_string<Args...> fmt, Args&&... args) {
23+
if (!trace && (level == LOG || level == INFO))
24+
return;
25+
2126
switch (level) {
2227
case NONE: break;
2328
case LOG: std::cout << "[LOG] "; break;

src/main.cpp

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@ static void printHelp() {
66
Debug::log(NONE, "┣ --gamma_max → Set the maximum display gamma (default 100%, maximum 200%)");
77
Debug::log(NONE, "┣ --temperature -t → Set the temperature in K (default 6000)");
88
Debug::log(NONE, "┣ --identity -i → Use the identity matrix (no color change)");
9+
Debug::log(NONE, "┣ --verbose → Print more logging");
10+
Debug::log(NONE, "┣ --version -v → Print the version");
911
Debug::log(NONE, "┣ --help -h → Print this info");
1012
Debug::log(NONE, "");
1113
}
1214

1315
int main(int argc, char** argv, char** envp) {
14-
Debug::log(NONE, "┏ hyprsunset v{} ━━╸\n", HYPRSUNSET_VERSION);
15-
1616
g_pHyprsunset = std::make_unique<CHyprsunset>();
1717

1818
for (int i = 1; i < argc; ++i) {
@@ -64,13 +64,20 @@ int main(int argc, char** argv, char** envp) {
6464
} else if (argv[i] == std::string{"-h"} || argv[i] == std::string{"--help"}) {
6565
printHelp();
6666
return 0;
67+
} else if (argv[i] == std::string{"-v"} || argv[i] == std::string{"--version"}) {
68+
Debug::log(NONE, "hyprsunset v{}", HYPRSUNSET_VERSION);
69+
return 0;
70+
} else if (argv[i] == std::string{"--verbose"}) {
71+
Debug::trace = true;
6772
} else {
6873
Debug::log(NONE, "✖ Argument not recognized: {}", argv[i]);
6974
printHelp();
7075
return 1;
7176
}
7277
}
7378

79+
Debug::log(NONE, "┏ hyprsunset v{} ━━╸\n", HYPRSUNSET_VERSION);
80+
7481
if (!g_pHyprsunset->calculateMatrix())
7582
return 1;
7683
if (!g_pHyprsunset->init())

0 commit comments

Comments
 (0)