2022-09-02 18:06:00 +02:00
|
|
|
#include <iostream>
|
|
|
|
#include "hyprpicker.hpp"
|
|
|
|
|
|
|
|
|
|
|
|
int main(int argc, char** argv, char** envp) {
|
|
|
|
g_pHyprpicker = std::make_unique<CHyprpicker>();
|
2022-09-02 20:44:42 +02:00
|
|
|
|
|
|
|
// parse args
|
|
|
|
// 1 - format
|
|
|
|
int currentlyParsing = 0;
|
|
|
|
for (int i = 1; i < argc; i++) {
|
|
|
|
std::string arg = argv[i];
|
|
|
|
|
|
|
|
if (currentlyParsing == 0) {
|
|
|
|
if (arg == "--format") {
|
|
|
|
currentlyParsing = 1;
|
|
|
|
continue;
|
2022-09-02 21:14:44 +02:00
|
|
|
} else if (arg == "--no-fancy") {
|
|
|
|
g_pHyprpicker->m_bFancyOutput = false;
|
2022-11-19 15:53:05 +01:00
|
|
|
} else if (arg == "--autocopy") {
|
|
|
|
g_pHyprpicker->m_bAutoCopy = true;
|
2022-09-02 20:44:42 +02:00
|
|
|
} else {
|
2022-09-05 04:48:37 +02:00
|
|
|
std::cout << "Hyprpicker usage: hyprpicker [arg [...]].\n\nArguments:\n" <<
|
|
|
|
" --format [fmt] | Specifies the output format (hex, rgb)\n" <<
|
|
|
|
" --no-fancy | Disables the \"fancy\" (aka. colored) outputting\n" <<
|
2022-11-19 15:53:05 +01:00
|
|
|
" --autocopy | Automatically copies the output to the clipboard (requires wl-clipboard)\n" <<
|
2022-09-05 04:48:37 +02:00
|
|
|
" --help | Show this help message\n";
|
2022-09-02 20:44:42 +02:00
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
} else if (currentlyParsing == 1) {
|
|
|
|
if (arg == "hex") g_pHyprpicker->m_bSelectedOutputMode = OUTPUT_HEX;
|
|
|
|
else if (arg == "rgb") g_pHyprpicker->m_bSelectedOutputMode = OUTPUT_RGB;
|
|
|
|
else {
|
|
|
|
Debug::log(NONE, "Unrecognized format %s", arg.c_str());
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
currentlyParsing = 0;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-09-02 21:14:44 +02:00
|
|
|
if (!isatty(fileno(stdout)) || getenv("NO_COLOR"))
|
|
|
|
g_pHyprpicker->m_bFancyOutput = false;
|
|
|
|
|
2022-09-02 18:06:00 +02:00
|
|
|
g_pHyprpicker->init();
|
|
|
|
|
|
|
|
return 0;
|
2022-09-05 04:48:37 +02:00
|
|
|
}
|