Support HSL, HSV, CMYK, short options, minor I/O fix, and add a manual page (#12)
* use getopt_long(3) and support short options
Now instead of `--format`, `--no-fancy`, and `--help` you can also use
`-f`, `-n`, and `-h`. Additionally instead of just being able to do
`--format <fmt>` you can now do the standard `--format=<fmt>`.
* remove initial space when m_bFancyOutput is true
* add the HSL format
* add the HSV format
* add a manual page
* silence compiler warning
* make all the default target, and add install rule
* add the CMYK format
* add new formats to the README
2022-11-19 18:02:11 +01:00
|
|
|
#include <strings.h>
|
2023-03-31 18:41:40 +02:00
|
|
|
|
2022-09-02 18:06:00 +02:00
|
|
|
#include <iostream>
|
2023-03-31 18:41:40 +02:00
|
|
|
|
2022-09-02 18:06:00 +02:00
|
|
|
#include "hyprpicker.hpp"
|
|
|
|
|
Support HSL, HSV, CMYK, short options, minor I/O fix, and add a manual page (#12)
* use getopt_long(3) and support short options
Now instead of `--format`, `--no-fancy`, and `--help` you can also use
`-f`, `-n`, and `-h`. Additionally instead of just being able to do
`--format <fmt>` you can now do the standard `--format=<fmt>`.
* remove initial space when m_bFancyOutput is true
* add the HSL format
* add the HSV format
* add a manual page
* silence compiler warning
* make all the default target, and add install rule
* add the CMYK format
* add new formats to the README
2022-11-19 18:02:11 +01:00
|
|
|
static void help(void) {
|
2023-03-31 18:41:40 +02:00
|
|
|
std::cout << "Hyprpicker usage: hyprpicker [arg [...]].\n\nArguments:\n"
|
|
|
|
<< " -a | --autocopy | Automatically copies the output to the clipboard (requires wl-clipboard)\n"
|
|
|
|
<< " -f | --format=fmt | Specifies the output format (cmyk, hex, rgb, hsl, hsv)\n"
|
|
|
|
<< " -n | --no-fancy | Disables the \"fancy\" (aka. colored) outputting\n"
|
|
|
|
<< " -h | --help | Show this help message\n"
|
|
|
|
<< " -r | --render-inactive | Render (freeze) inactive displays\n"
|
2024-09-29 19:12:50 +02:00
|
|
|
<< " -z | --no-zoom | Disable the zoom lens\n"
|
|
|
|
<< " -q | --quiet | Disable most logs (leaves errors)\n"
|
|
|
|
<< " -v | --verbose | Enable more logs\n"
|
2024-09-29 19:24:57 +02:00
|
|
|
<< " -t | --no-fractional | Disable fractional scaling support\n"
|
|
|
|
<< " -V | --version | Print version info\n";
|
Support HSL, HSV, CMYK, short options, minor I/O fix, and add a manual page (#12)
* use getopt_long(3) and support short options
Now instead of `--format`, `--no-fancy`, and `--help` you can also use
`-f`, `-n`, and `-h`. Additionally instead of just being able to do
`--format <fmt>` you can now do the standard `--format=<fmt>`.
* remove initial space when m_bFancyOutput is true
* add the HSL format
* add the HSV format
* add a manual page
* silence compiler warning
* make all the default target, and add install rule
* add the CMYK format
* add new formats to the README
2022-11-19 18:02:11 +01:00
|
|
|
}
|
2022-09-02 18:06:00 +02:00
|
|
|
|
|
|
|
int main(int argc, char** argv, char** envp) {
|
|
|
|
g_pHyprpicker = std::make_unique<CHyprpicker>();
|
2022-09-02 20:44:42 +02:00
|
|
|
|
Support HSL, HSV, CMYK, short options, minor I/O fix, and add a manual page (#12)
* use getopt_long(3) and support short options
Now instead of `--format`, `--no-fancy`, and `--help` you can also use
`-f`, `-n`, and `-h`. Additionally instead of just being able to do
`--format <fmt>` you can now do the standard `--format=<fmt>`.
* remove initial space when m_bFancyOutput is true
* add the HSL format
* add the HSV format
* add a manual page
* silence compiler warning
* make all the default target, and add install rule
* add the CMYK format
* add new formats to the README
2022-11-19 18:02:11 +01:00
|
|
|
while (true) {
|
2023-03-31 18:41:40 +02:00
|
|
|
int option_index = 0;
|
|
|
|
static struct option long_options[] = {{"autocopy", no_argument, NULL, 'a'},
|
|
|
|
{"format", required_argument, NULL, 'f'},
|
|
|
|
{"help", no_argument, NULL, 'h'},
|
|
|
|
{"no-fancy", no_argument, NULL, 'n'},
|
|
|
|
{"render-inactive", no_argument, NULL, 'r'},
|
|
|
|
{"no-zoom", no_argument, NULL, 'z'},
|
2024-09-29 19:12:50 +02:00
|
|
|
{"no-fractional", no_argument, NULL, 't'},
|
|
|
|
{"quiet", no_argument, NULL, 'q'},
|
|
|
|
{"verbose", no_argument, NULL, 'v'},
|
2024-09-29 19:24:57 +02:00
|
|
|
{"version", no_argument, NULL, 'V'},
|
2023-03-31 18:41:40 +02:00
|
|
|
{NULL, 0, NULL, 0}};
|
Support HSL, HSV, CMYK, short options, minor I/O fix, and add a manual page (#12)
* use getopt_long(3) and support short options
Now instead of `--format`, `--no-fancy`, and `--help` you can also use
`-f`, `-n`, and `-h`. Additionally instead of just being able to do
`--format <fmt>` you can now do the standard `--format=<fmt>`.
* remove initial space when m_bFancyOutput is true
* add the HSL format
* add the HSV format
* add a manual page
* silence compiler warning
* make all the default target, and add install rule
* add the CMYK format
* add new formats to the README
2022-11-19 18:02:11 +01:00
|
|
|
|
2024-09-29 19:24:57 +02:00
|
|
|
int c = getopt_long(argc, argv, ":f:hnarzqvtV", long_options, &option_index);
|
Support HSL, HSV, CMYK, short options, minor I/O fix, and add a manual page (#12)
* use getopt_long(3) and support short options
Now instead of `--format`, `--no-fancy`, and `--help` you can also use
`-f`, `-n`, and `-h`. Additionally instead of just being able to do
`--format <fmt>` you can now do the standard `--format=<fmt>`.
* remove initial space when m_bFancyOutput is true
* add the HSL format
* add the HSV format
* add a manual page
* silence compiler warning
* make all the default target, and add install rule
* add the CMYK format
* add new formats to the README
2022-11-19 18:02:11 +01:00
|
|
|
if (c == -1)
|
|
|
|
break;
|
|
|
|
|
|
|
|
switch (c) {
|
|
|
|
case 'f':
|
|
|
|
if (strcasecmp(optarg, "cmyk") == 0)
|
|
|
|
g_pHyprpicker->m_bSelectedOutputMode = OUTPUT_CMYK;
|
|
|
|
else if (strcasecmp(optarg, "hex") == 0)
|
|
|
|
g_pHyprpicker->m_bSelectedOutputMode = OUTPUT_HEX;
|
|
|
|
else if (strcasecmp(optarg, "rgb") == 0)
|
|
|
|
g_pHyprpicker->m_bSelectedOutputMode = OUTPUT_RGB;
|
|
|
|
else if (strcasecmp(optarg, "hsl") == 0)
|
|
|
|
g_pHyprpicker->m_bSelectedOutputMode = OUTPUT_HSL;
|
|
|
|
else if (strcasecmp(optarg, "hsv") == 0)
|
|
|
|
g_pHyprpicker->m_bSelectedOutputMode = OUTPUT_HSV;
|
|
|
|
else {
|
|
|
|
Debug::log(NONE, "Unrecognized format %s", optarg);
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
break;
|
2023-03-31 18:41:40 +02:00
|
|
|
case 'h': help(); exit(0);
|
|
|
|
case 'n': g_pHyprpicker->m_bFancyOutput = false; break;
|
|
|
|
case 'a': g_pHyprpicker->m_bAutoCopy = true; break;
|
|
|
|
case 'r': g_pHyprpicker->m_bRenderInactive = true; break;
|
|
|
|
case 'z': g_pHyprpicker->m_bNoZoom = true; break;
|
2024-09-29 19:12:50 +02:00
|
|
|
case 't': g_pHyprpicker->m_bNoFractional = true; break;
|
|
|
|
case 'q': Debug::quiet = true; break;
|
|
|
|
case 'v': Debug::verbose = true; break;
|
2024-09-29 19:24:57 +02:00
|
|
|
case 'V': {
|
|
|
|
std::cout << "hyprpicker v" << HYPRPICKER_VERSION << "\n";
|
|
|
|
exit(0);
|
|
|
|
}
|
2023-03-31 18:41:40 +02:00
|
|
|
|
|
|
|
default: help(); exit(1);
|
|
|
|
}
|
2022-09-02 20:44:42 +02:00
|
|
|
}
|
|
|
|
|
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
|
|
|
}
|