refactor: Cleanup
This commit is contained in:
parent
c1aa3319a1
commit
8cc885c316
@ -3,6 +3,7 @@
|
|||||||
#include <mutex>
|
#include <mutex>
|
||||||
|
|
||||||
#include "common.hpp"
|
#include "common.hpp"
|
||||||
|
#include "settings.hpp"
|
||||||
|
|
||||||
// fwd
|
// fwd
|
||||||
struct _snd_ctl;
|
struct _snd_ctl;
|
||||||
|
@ -39,6 +39,7 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "common.hpp"
|
#include "common.hpp"
|
||||||
|
#include "settings.hpp"
|
||||||
#include "errors.hpp"
|
#include "errors.hpp"
|
||||||
|
|
||||||
POLYBAR_NS
|
POLYBAR_NS
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
#include <mutex>
|
#include <mutex>
|
||||||
|
|
||||||
#include "common.hpp"
|
#include "common.hpp"
|
||||||
|
#include "settings.hpp"
|
||||||
|
|
||||||
// fwd
|
// fwd
|
||||||
struct _snd_mixer;
|
struct _snd_mixer;
|
||||||
|
@ -11,14 +11,12 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "common.hpp"
|
#include "common.hpp"
|
||||||
#include "config.hpp"
|
#include "settings.hpp"
|
||||||
#include "errors.hpp"
|
#include "errors.hpp"
|
||||||
#include "utils/math.hpp"
|
#include "utils/math.hpp"
|
||||||
|
|
||||||
POLYBAR_NS
|
POLYBAR_NS
|
||||||
|
|
||||||
namespace chrono = std::chrono;
|
|
||||||
|
|
||||||
class file_descriptor;
|
class file_descriptor;
|
||||||
|
|
||||||
namespace net {
|
namespace net {
|
||||||
@ -45,7 +43,7 @@ namespace net {
|
|||||||
struct link_activity {
|
struct link_activity {
|
||||||
bytes_t transmitted{0};
|
bytes_t transmitted{0};
|
||||||
bytes_t received{0};
|
bytes_t received{0};
|
||||||
chrono::system_clock::time_point time;
|
std::chrono::system_clock::time_point time;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct link_status {
|
struct link_status {
|
||||||
|
@ -2,8 +2,7 @@
|
|||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include <vector>
|
||||||
#include "config.hpp"
|
|
||||||
|
|
||||||
#define POLYBAR_NS \
|
#define POLYBAR_NS \
|
||||||
namespace polybar { \
|
namespace polybar { \
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
#include <mutex>
|
#include <mutex>
|
||||||
|
|
||||||
#include "common.hpp"
|
#include "common.hpp"
|
||||||
|
#include "settings.hpp"
|
||||||
#include "components/types.hpp"
|
#include "components/types.hpp"
|
||||||
#include "errors.hpp"
|
#include "errors.hpp"
|
||||||
#include "events/signal_fwd.hpp"
|
#include "events/signal_fwd.hpp"
|
||||||
|
@ -4,7 +4,6 @@
|
|||||||
|
|
||||||
#include "common.hpp"
|
#include "common.hpp"
|
||||||
#include "errors.hpp"
|
#include "errors.hpp"
|
||||||
#include "utils/factory.hpp"
|
|
||||||
|
|
||||||
POLYBAR_NS
|
POLYBAR_NS
|
||||||
|
|
||||||
@ -27,8 +26,12 @@ namespace command_line {
|
|||||||
string token;
|
string token;
|
||||||
const choices values;
|
const choices values;
|
||||||
|
|
||||||
explicit option(string flag, string flag_long, string desc, string token = "", const choices c = {})
|
explicit option(string&& flag, string&& flag_long, string&& desc, string&& token = "", const choices&& c = {})
|
||||||
: flag(flag), flag_long(flag_long), desc(desc), token(token), values(c) {}
|
: flag(forward<string>(flag))
|
||||||
|
, flag_long(forward<string>(flag_long))
|
||||||
|
, desc(forward<string>(desc))
|
||||||
|
, token(forward<string>(token))
|
||||||
|
, values(forward<const choices>(c)) {}
|
||||||
};
|
};
|
||||||
|
|
||||||
// }}}
|
// }}}
|
||||||
@ -67,8 +70,4 @@ namespace command_line {
|
|||||||
// }}}
|
// }}}
|
||||||
}
|
}
|
||||||
|
|
||||||
using cliparser = command_line::parser;
|
|
||||||
using clioption = command_line::option;
|
|
||||||
using clioptions = command_line::options;
|
|
||||||
|
|
||||||
POLYBAR_NS_END
|
POLYBAR_NS_END
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
|
|
||||||
#include "common.hpp"
|
#include "common.hpp"
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
#include <thread>
|
#include <thread>
|
||||||
|
|
||||||
#include "common.hpp"
|
#include "common.hpp"
|
||||||
|
#include "settings.hpp"
|
||||||
#include "events/signal_fwd.hpp"
|
#include "events/signal_fwd.hpp"
|
||||||
#include "events/signal_receiver.hpp"
|
#include "events/signal_receiver.hpp"
|
||||||
#include "events/types.hpp"
|
#include "events/types.hpp"
|
||||||
|
@ -1,14 +1,15 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "common.hpp"
|
#include "common.hpp"
|
||||||
#include "components/logger.hpp"
|
#include "settings.hpp"
|
||||||
#include "events/signal_emitter.hpp"
|
|
||||||
#include "utils/concurrency.hpp"
|
#include "utils/concurrency.hpp"
|
||||||
#include "utils/functional.hpp"
|
|
||||||
#include "utils/file.hpp"
|
|
||||||
|
|
||||||
POLYBAR_NS
|
POLYBAR_NS
|
||||||
|
|
||||||
|
class file_descriptor;
|
||||||
|
class logger;
|
||||||
|
class signal_emitter;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Message types
|
* Message types
|
||||||
*/
|
*/
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <chrono>
|
#include <chrono>
|
||||||
#include <iostream>
|
#include <cstdio>
|
||||||
|
|
||||||
#include "common.hpp"
|
#include "common.hpp"
|
||||||
|
|
||||||
@ -23,7 +23,7 @@ namespace debug_util {
|
|||||||
|
|
||||||
explicit scope_timer() : m_start(clock_t::now()) {}
|
explicit scope_timer() : m_start(clock_t::now()) {}
|
||||||
~scope_timer() {
|
~scope_timer() {
|
||||||
std::cout << std::chrono::duration_cast<duration_t>(clock_t::now() - m_start).count() << "ms" << std::endl;
|
printf("%lums\n", std::chrono::duration_cast<duration_t>(clock_t::now() - m_start).count());
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@ -39,13 +39,12 @@ namespace debug_util {
|
|||||||
auto start = std::chrono::high_resolution_clock::now();
|
auto start = std::chrono::high_resolution_clock::now();
|
||||||
expr();
|
expr();
|
||||||
auto finish = std::chrono::high_resolution_clock::now();
|
auto finish = std::chrono::high_resolution_clock::now();
|
||||||
std::cout << "execution speed: " << std::chrono::duration_cast<std::chrono::milliseconds>(finish - start).count()
|
printf("execution speed: %lums\n", std::chrono::duration_cast<std::chrono::milliseconds>(finish - start).count());
|
||||||
<< "ms" << std::endl;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class T>
|
template <class T>
|
||||||
void memory_usage(const T& object) noexcept {
|
void memory_usage(const T& object) noexcept {
|
||||||
std::cout << "memory usage: " << sizeof(object) << "b" << std::endl;
|
printf("memory usage: %lub\n", sizeof(object));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "components/config.hpp"
|
#include "components/config.hpp"
|
||||||
#include "config.hpp"
|
#include "settings.hpp"
|
||||||
#include "modules/meta/inotify_module.hpp"
|
#include "modules/meta/inotify_module.hpp"
|
||||||
|
|
||||||
POLYBAR_NS
|
POLYBAR_NS
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "config.hpp"
|
#include "settings.hpp"
|
||||||
#include "modules/meta/timer_module.hpp"
|
#include "modules/meta/timer_module.hpp"
|
||||||
|
|
||||||
POLYBAR_NS
|
POLYBAR_NS
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "components/config.hpp"
|
#include "components/config.hpp"
|
||||||
#include "config.hpp"
|
#include "settings.hpp"
|
||||||
#include "modules/meta/timer_module.hpp"
|
#include "modules/meta/timer_module.hpp"
|
||||||
|
|
||||||
POLYBAR_NS
|
POLYBAR_NS
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "config.hpp"
|
#include "settings.hpp"
|
||||||
#include "modules/meta/timer_module.hpp"
|
#include "modules/meta/timer_module.hpp"
|
||||||
#include "utils/http.hpp"
|
#include "utils/http.hpp"
|
||||||
|
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
#include <i3ipc++/ipc.hpp>
|
#include <i3ipc++/ipc.hpp>
|
||||||
|
|
||||||
#include "components/config.hpp"
|
#include "components/config.hpp"
|
||||||
#include "config.hpp"
|
#include "settings.hpp"
|
||||||
#include "modules/meta/event_module.hpp"
|
#include "modules/meta/event_module.hpp"
|
||||||
#include "modules/meta/input_handler.hpp"
|
#include "modules/meta/input_handler.hpp"
|
||||||
#include "utils/i3.hpp"
|
#include "utils/i3.hpp"
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "config.hpp"
|
#include "settings.hpp"
|
||||||
#include "modules/meta/timer_module.hpp"
|
#include "modules/meta/timer_module.hpp"
|
||||||
|
|
||||||
POLYBAR_NS
|
POLYBAR_NS
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
#include <istream>
|
#include <istream>
|
||||||
|
|
||||||
#include "config.hpp"
|
#include "settings.hpp"
|
||||||
#include "modules/meta/timer_module.hpp"
|
#include "modules/meta/timer_module.hpp"
|
||||||
|
|
||||||
POLYBAR_NS
|
POLYBAR_NS
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "config.hpp"
|
#include "settings.hpp"
|
||||||
#include "modules/meta/event_module.hpp"
|
#include "modules/meta/event_module.hpp"
|
||||||
#include "modules/meta/input_handler.hpp"
|
#include "modules/meta/input_handler.hpp"
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "components/config.hpp"
|
#include "components/config.hpp"
|
||||||
#include "config.hpp"
|
#include "settings.hpp"
|
||||||
#include "modules/meta/event_handler.hpp"
|
#include "modules/meta/event_handler.hpp"
|
||||||
#include "modules/meta/input_handler.hpp"
|
#include "modules/meta/input_handler.hpp"
|
||||||
#include "modules/meta/static_module.hpp"
|
#include "modules/meta/static_module.hpp"
|
||||||
|
107
include/settings.hpp
Normal file
107
include/settings.hpp
Normal file
@ -0,0 +1,107 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <cstdio>
|
||||||
|
#include <string>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
#include "version.hpp"
|
||||||
|
|
||||||
|
#define APP_NAME "polybar"
|
||||||
|
#define APP_VERSION "2.4.8-9-gc1aa331-git"
|
||||||
|
#ifndef APP_VERSION
|
||||||
|
#define APP_VERSION GIT_TAG
|
||||||
|
#endif
|
||||||
|
#define BASE_PATH "/home/jaagr/.local/var/github/jaagr/polybar"
|
||||||
|
|
||||||
|
#define ENABLE_ALSA 1
|
||||||
|
#define ENABLE_MPD 1
|
||||||
|
#define ENABLE_NETWORK 1
|
||||||
|
#define ENABLE_I3 1
|
||||||
|
#define ENABLE_CURL 1
|
||||||
|
|
||||||
|
#define WITH_XRANDR 1
|
||||||
|
#define WITH_XRENDER 0
|
||||||
|
#define WITH_XDAMAGE 0
|
||||||
|
#define WITH_XSYNC 0
|
||||||
|
#define WITH_XCOMPOSITE 0
|
||||||
|
#define WITH_XKB 1
|
||||||
|
#define XPP_EXTENSION_LIST xpp::randr::extension, xpp::xkb::extension
|
||||||
|
|
||||||
|
/* #undef DEBUG_LOGGER */
|
||||||
|
/* #undef VERBOSE_TRACELOG */
|
||||||
|
/* #undef DEBUG_HINTS */
|
||||||
|
|
||||||
|
static const size_t EVENT_SIZE{64UL};
|
||||||
|
|
||||||
|
static const int SIGN_PRIORITY_CONTROLLER{1};
|
||||||
|
static const int SIGN_PRIORITY_SCREEN{2};
|
||||||
|
static const int SIGN_PRIORITY_BAR{3};
|
||||||
|
static const int SIGN_PRIORITY_RENDERER{4};
|
||||||
|
static const int SIGN_PRIORITY_TRAY{5};
|
||||||
|
|
||||||
|
static const int SINK_PRIORITY_BAR{1};
|
||||||
|
static const int SINK_PRIORITY_SCREEN{2};
|
||||||
|
static const int SINK_PRIORITY_TRAY{3};
|
||||||
|
static const int SINK_PRIORITY_MODULE{4};
|
||||||
|
|
||||||
|
#ifdef DEBUG_HINTS
|
||||||
|
static const int DEBUG_HINTS_OFFSET_X{0};
|
||||||
|
static const int DEBUG_HINTS_OFFSET_Y{0};
|
||||||
|
#endif
|
||||||
|
|
||||||
|
static constexpr const char* ALSA_SOUNDCARD{"default"};
|
||||||
|
static constexpr const char* BSPWM_SOCKET_PATH{"/tmp/bspwm_0_0-socket"};
|
||||||
|
static constexpr const char* BSPWM_STATUS_PREFIX{"W"};
|
||||||
|
static constexpr const char* CONNECTION_TEST_IP{"8.8.8.8"};
|
||||||
|
static constexpr const char* PATH_ADAPTER{"/sys/class/power_supply/%adapter%"};
|
||||||
|
static constexpr const char* PATH_BACKLIGHT_MAX{"/sys/class/backlight/%card%/max_brightness"};
|
||||||
|
static constexpr const char* PATH_BACKLIGHT_VAL{"/sys/class/backlight/%card%/brightness"};
|
||||||
|
static constexpr const char* PATH_BATTERY{"/sys/class/power_supply/%battery%"};
|
||||||
|
static constexpr const char* PATH_CPU_INFO{"/proc/stat"};
|
||||||
|
static constexpr const char* PATH_MEMORY_INFO{"/proc/meminfo"};
|
||||||
|
static constexpr const char* PATH_MESSAGING_FIFO{"/tmp/polybar_mqueue.%pid%"};
|
||||||
|
static constexpr const char* PATH_TEMPERATURE_INFO{"/sys/class/thermal/thermal_zone%zone%/temp"};
|
||||||
|
|
||||||
|
static constexpr const char* BUILDER_SPACE_TOKEN{"%__"};
|
||||||
|
|
||||||
|
const auto version_details = [](const std::vector<std::string>& args) {
|
||||||
|
for (auto&& arg : args) {
|
||||||
|
if (arg.compare(0, 3, "-vv") == 0)
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
};
|
||||||
|
|
||||||
|
// clang-format off
|
||||||
|
const auto print_build_info = [](bool extended = false) {
|
||||||
|
printf("%s %s\n\n", APP_NAME, APP_VERSION);
|
||||||
|
printf("Features: %calsa %ccurl %ci3 %cmpd %cnetwork\n",
|
||||||
|
(ENABLE_ALSA ? '+' : '-'),
|
||||||
|
(ENABLE_CURL ? '+' : '-'),
|
||||||
|
(ENABLE_I3 ? '+' : '-'),
|
||||||
|
(ENABLE_MPD ? '+' : '-'),
|
||||||
|
(ENABLE_NETWORK ? '+' : '-'));
|
||||||
|
if (extended) {
|
||||||
|
printf("\n");
|
||||||
|
printf("Build type: RelWithDebInfo\n");
|
||||||
|
printf("Compiler: /usr/bin/c++\n");
|
||||||
|
printf("Compiler flags: -Wall -Wextra -Werror -O2 -pedantic -pedantic-errors\n");
|
||||||
|
printf("Linker flags: \n");
|
||||||
|
printf("\n");
|
||||||
|
printf("ALSA_SOUNDCARD %s\n", ALSA_SOUNDCARD);
|
||||||
|
printf("BSPWM_SOCKET_PATH %s\n", BSPWM_SOCKET_PATH);
|
||||||
|
printf("BSPWM_STATUS_PREFIX %s\n", BSPWM_STATUS_PREFIX);
|
||||||
|
printf("BUILDER_SPACE_TOKEN %s\n", BUILDER_SPACE_TOKEN);
|
||||||
|
printf("CONNECTION_TEST_IP %s\n", CONNECTION_TEST_IP);
|
||||||
|
printf("PATH_ADAPTER %s\n", PATH_ADAPTER);
|
||||||
|
printf("PATH_BACKLIGHT_MAX %s\n", PATH_BACKLIGHT_MAX);
|
||||||
|
printf("PATH_BACKLIGHT_VAL %s\n", PATH_BACKLIGHT_VAL);
|
||||||
|
printf("PATH_BATTERY %s\n", PATH_BATTERY);
|
||||||
|
printf("PATH_CPU_INFO %s\n", PATH_CPU_INFO);
|
||||||
|
printf("PATH_MEMORY_INFO %s\n", PATH_MEMORY_INFO);
|
||||||
|
printf("PATH_TEMPERATURE_INFO %s\n", PATH_TEMPERATURE_INFO);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
// clang-format on
|
||||||
|
|
||||||
|
// vim:ft=cpp
|
@ -1,6 +1,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <iostream>
|
#include <cstdio>
|
||||||
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "version.hpp"
|
#include "version.hpp"
|
||||||
@ -30,7 +31,7 @@
|
|||||||
#cmakedefine VERBOSE_TRACELOG
|
#cmakedefine VERBOSE_TRACELOG
|
||||||
#cmakedefine DEBUG_HINTS
|
#cmakedefine DEBUG_HINTS
|
||||||
|
|
||||||
static const size_t EVENT_SIZE{64U};
|
static const size_t EVENT_SIZE{64UL};
|
||||||
|
|
||||||
static const int SIGN_PRIORITY_CONTROLLER{1};
|
static const int SIGN_PRIORITY_CONTROLLER{1};
|
||||||
static const int SIGN_PRIORITY_SCREEN{2};
|
static const int SIGN_PRIORITY_SCREEN{2};
|
||||||
@ -44,12 +45,8 @@ static const int SINK_PRIORITY_TRAY{3};
|
|||||||
static const int SINK_PRIORITY_MODULE{4};
|
static const int SINK_PRIORITY_MODULE{4};
|
||||||
|
|
||||||
#ifdef DEBUG_HINTS
|
#ifdef DEBUG_HINTS
|
||||||
static const int DEBUG_HINTS_OFFSET_X {
|
static const int DEBUG_HINTS_OFFSET_X{@DEBUG_HINTS_OFFSET_X@};
|
||||||
@DEBUG_HINTS_OFFSET_X@
|
static const int DEBUG_HINTS_OFFSET_Y{@DEBUG_HINTS_OFFSET_Y@};
|
||||||
};
|
|
||||||
static const int DEBUG_HINTS_OFFSET_Y {
|
|
||||||
@DEBUG_HINTS_OFFSET_Y@
|
|
||||||
};
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static constexpr const char* ALSA_SOUNDCARD{"@SETTING_ALSA_SOUNDCARD@"};
|
static constexpr const char* ALSA_SOUNDCARD{"@SETTING_ALSA_SOUNDCARD@"};
|
||||||
@ -67,7 +64,7 @@ static constexpr const char* PATH_TEMPERATURE_INFO{"@SETTING_PATH_TEMPERATURE_IN
|
|||||||
|
|
||||||
static constexpr const char* BUILDER_SPACE_TOKEN{"%__"};
|
static constexpr const char* BUILDER_SPACE_TOKEN{"%__"};
|
||||||
|
|
||||||
auto version_details = [](const std::vector<std::string>& args) {
|
const auto version_details = [](const std::vector<std::string>& args) {
|
||||||
for (auto&& arg : args) {
|
for (auto&& arg : args) {
|
||||||
if (arg.compare(0, 3, "-vv") == 0)
|
if (arg.compare(0, 3, "-vv") == 0)
|
||||||
return true;
|
return true;
|
||||||
@ -76,36 +73,34 @@ auto version_details = [](const std::vector<std::string>& args) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// clang-format off
|
// clang-format off
|
||||||
auto print_build_info = [](bool extended = false) {
|
const auto print_build_info = [](bool extended = false) {
|
||||||
std::cout << APP_NAME << " " << APP_VERSION << " " << "\n"
|
printf("%s %s\n\n", APP_NAME, APP_VERSION);
|
||||||
<< "\n"
|
printf("Features: %calsa %ccurl %ci3 %cmpd %cnetwork\n",
|
||||||
<< "Features: "
|
(ENABLE_ALSA ? '+' : '-'),
|
||||||
<< (ENABLE_ALSA ? "+" : "-") << "alsa "
|
(ENABLE_CURL ? '+' : '-'),
|
||||||
<< (ENABLE_CURL ? "+" : "-") << "curl "
|
(ENABLE_I3 ? '+' : '-'),
|
||||||
<< (ENABLE_I3 ? "+" : "-") << "i3 "
|
(ENABLE_MPD ? '+' : '-'),
|
||||||
<< (ENABLE_MPD ? "+" : "-") << "mpd "
|
(ENABLE_NETWORK ? '+' : '-'));
|
||||||
<< (ENABLE_NETWORK ? "+" : "-") << "network "
|
if (extended) {
|
||||||
<< "\n";
|
printf("\n");
|
||||||
if (!extended)
|
printf("Build type: @CMAKE_BUILD_TYPE@\n");
|
||||||
return;
|
printf("Compiler: @CMAKE_CXX_COMPILER@\n");
|
||||||
std::cout << "\n"
|
printf("Compiler flags: @CMAKE_CXX_FLAGS@\n");
|
||||||
<< "Build type: @CMAKE_BUILD_TYPE@" << "\n"
|
printf("Linker flags: @CMAKE_EXE_LINKER_FLAGS@\n");
|
||||||
<< "Compiler: @CMAKE_CXX_COMPILER@" << "\n"
|
printf("\n");
|
||||||
<< "Compiler flags: @CMAKE_CXX_FLAGS@" << "\n"
|
printf("ALSA_SOUNDCARD %s\n", ALSA_SOUNDCARD);
|
||||||
<< "Linker flags: @CMAKE_EXE_LINKER_FLAGS@" << "\n"
|
printf("BSPWM_SOCKET_PATH %s\n", BSPWM_SOCKET_PATH);
|
||||||
<< "\n"
|
printf("BSPWM_STATUS_PREFIX %s\n", BSPWM_STATUS_PREFIX);
|
||||||
<< "ALSA_SOUNDCARD " << ALSA_SOUNDCARD << "\n"
|
printf("BUILDER_SPACE_TOKEN %s\n", BUILDER_SPACE_TOKEN);
|
||||||
<< "BSPWM_SOCKET_PATH " << BSPWM_SOCKET_PATH << "\n"
|
printf("CONNECTION_TEST_IP %s\n", CONNECTION_TEST_IP);
|
||||||
<< "BSPWM_STATUS_PREFIX " << BSPWM_STATUS_PREFIX << "\n"
|
printf("PATH_ADAPTER %s\n", PATH_ADAPTER);
|
||||||
<< "BUILDER_SPACE_TOKEN " << BUILDER_SPACE_TOKEN << "\n"
|
printf("PATH_BACKLIGHT_MAX %s\n", PATH_BACKLIGHT_MAX);
|
||||||
<< "CONNECTION_TEST_IP " << CONNECTION_TEST_IP << "\n"
|
printf("PATH_BACKLIGHT_VAL %s\n", PATH_BACKLIGHT_VAL);
|
||||||
<< "PATH_ADAPTER " << PATH_ADAPTER << "\n"
|
printf("PATH_BATTERY %s\n", PATH_BATTERY);
|
||||||
<< "PATH_BACKLIGHT_MAX " << PATH_BACKLIGHT_MAX << "\n"
|
printf("PATH_CPU_INFO %s\n", PATH_CPU_INFO);
|
||||||
<< "PATH_BACKLIGHT_VAL " << PATH_BACKLIGHT_VAL << "\n"
|
printf("PATH_MEMORY_INFO %s\n", PATH_MEMORY_INFO);
|
||||||
<< "PATH_BATTERY " << PATH_BATTERY << "\n"
|
printf("PATH_TEMPERATURE_INFO %s\n", PATH_TEMPERATURE_INFO);
|
||||||
<< "PATH_CPU_INFO " << PATH_CPU_INFO << "\n"
|
}
|
||||||
<< "PATH_MEMORY_INFO " << PATH_MEMORY_INFO << "\n"
|
|
||||||
<< "PATH_TEMPERATURE_INFO " << PATH_TEMPERATURE_INFO << "\n";
|
|
||||||
};
|
};
|
||||||
// clang-format on
|
// clang-format on
|
||||||
|
|
@ -4,7 +4,7 @@
|
|||||||
#include <xcb/xcb_icccm.h>
|
#include <xcb/xcb_icccm.h>
|
||||||
|
|
||||||
#include "common.hpp"
|
#include "common.hpp"
|
||||||
#include "config.hpp"
|
#include "settings.hpp"
|
||||||
#include "utils/socket.hpp"
|
#include "utils/socket.hpp"
|
||||||
#include "utils/string.hpp"
|
#include "utils/string.hpp"
|
||||||
#include "x11/extensions/randr.hpp"
|
#include "x11/extensions/randr.hpp"
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <streambuf>
|
||||||
|
|
||||||
#include "common.hpp"
|
#include "common.hpp"
|
||||||
#include "utils/factory.hpp"
|
#include "utils/factory.hpp"
|
||||||
|
|
||||||
@ -75,7 +77,7 @@ class fd_streambuf : public std::streambuf {
|
|||||||
char m_in[BUFSIZ - 1]{};
|
char m_in[BUFSIZ - 1]{};
|
||||||
};
|
};
|
||||||
|
|
||||||
template <typename StreamType = std::ostream>
|
template <typename StreamType>
|
||||||
class fd_stream : public StreamType {
|
class fd_stream : public StreamType {
|
||||||
public:
|
public:
|
||||||
using type = fd_stream<StreamType>;
|
using type = fd_stream<StreamType>;
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "config.hpp"
|
#include "settings.hpp"
|
||||||
|
|
||||||
#if WITH_XDAMAGE
|
#if WITH_XDAMAGE
|
||||||
#include "x11/extensions/damage.hpp"
|
#include "x11/extensions/damage.hpp"
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "config.hpp"
|
#include "settings.hpp"
|
||||||
|
|
||||||
#if not WITH_XCOMPOSITE
|
#if not WITH_XCOMPOSITE
|
||||||
#error "X Composite extension is disabled..."
|
#error "X Composite extension is disabled..."
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "config.hpp"
|
#include "settings.hpp"
|
||||||
|
|
||||||
#if not WITH_XDAMAGE
|
#if not WITH_XDAMAGE
|
||||||
#error "X Damage extension is disabled..."
|
#error "X Damage extension is disabled..."
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "config.hpp"
|
#include "settings.hpp"
|
||||||
|
|
||||||
namespace xpp {
|
namespace xpp {
|
||||||
#if WITH_XDAMAGE
|
#if WITH_XDAMAGE
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "config.hpp"
|
#include "settings.hpp"
|
||||||
|
|
||||||
#if not WITH_XRANDR
|
#if not WITH_XRANDR
|
||||||
#error "X RandR extension is disabled..."
|
#error "X RandR extension is disabled..."
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "config.hpp"
|
#include "settings.hpp"
|
||||||
|
|
||||||
#if not WITH_XRENDER
|
#if not WITH_XRENDER
|
||||||
#error "X Render extension is disabled..."
|
#error "X Render extension is disabled..."
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "config.hpp"
|
#include "settings.hpp"
|
||||||
|
|
||||||
#if not WITH_XSYNC
|
#if not WITH_XSYNC
|
||||||
#error "X Sync extension is disabled..."
|
#error "X Sync extension is disabled..."
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
#include <map>
|
#include <map>
|
||||||
|
|
||||||
#include "config.hpp"
|
#include "settings.hpp"
|
||||||
|
|
||||||
#if not WITH_XKB
|
#if not WITH_XKB
|
||||||
#error "X xkb extension is disabled..."
|
#error "X xkb extension is disabled..."
|
||||||
|
@ -161,6 +161,6 @@ execute_process(COMMAND git describe --tags --dirty=-git
|
|||||||
OUTPUT_STRIP_TRAILING_WHITESPACE ERROR_QUIET)
|
OUTPUT_STRIP_TRAILING_WHITESPACE ERROR_QUIET)
|
||||||
|
|
||||||
configure_file(
|
configure_file(
|
||||||
${PROJECT_SOURCE_DIR}/include/config.hpp.cmake
|
${PROJECT_SOURCE_DIR}/include/settings.hpp.cmake
|
||||||
${CMAKE_SOURCE_DIR}/include/config.hpp
|
${CMAKE_SOURCE_DIR}/include/settings.hpp
|
||||||
ESCAPE_QUOTES @ONLY)
|
ESCAPE_QUOTES @ONLY)
|
||||||
|
@ -22,7 +22,7 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "common.hpp"
|
#include "common.hpp"
|
||||||
#include "config.hpp"
|
#include "settings.hpp"
|
||||||
#include "utils/command.hpp"
|
#include "utils/command.hpp"
|
||||||
#include "utils/file.hpp"
|
#include "utils/file.hpp"
|
||||||
#include "utils/string.hpp"
|
#include "utils/string.hpp"
|
||||||
@ -67,7 +67,7 @@ namespace net {
|
|||||||
m_status.previous = m_status.current;
|
m_status.previous = m_status.current;
|
||||||
m_status.current.transmitted = 0;
|
m_status.current.transmitted = 0;
|
||||||
m_status.current.received = 0;
|
m_status.current.received = 0;
|
||||||
m_status.current.time = chrono::system_clock::now();
|
m_status.current.time = std::chrono::system_clock::now();
|
||||||
|
|
||||||
for (auto ifa = ifaddr; ifa != nullptr; ifa = ifa->ifa_next) {
|
for (auto ifa = ifaddr; ifa != nullptr; ifa = ifa->ifa_next) {
|
||||||
if (ifa->ifa_addr == nullptr) {
|
if (ifa->ifa_addr == nullptr) {
|
||||||
@ -183,7 +183,7 @@ namespace net {
|
|||||||
*/
|
*/
|
||||||
string network::format_speedrate(float bytes_diff, int minwidth) const {
|
string network::format_speedrate(float bytes_diff, int minwidth) const {
|
||||||
const auto duration = m_status.current.time - m_status.previous.time;
|
const auto duration = m_status.current.time - m_status.previous.time;
|
||||||
float time_diff = chrono::duration_cast<chrono::seconds>(duration).count();
|
float time_diff = std::chrono::duration_cast<std::chrono::seconds>(duration).count();
|
||||||
float speedrate = bytes_diff / (time_diff ? time_diff : 1);
|
float speedrate = bytes_diff / (time_diff ? time_diff : 1);
|
||||||
|
|
||||||
vector<string> suffixes{"GB", "MB"};
|
vector<string> suffixes{"GB", "MB"};
|
||||||
|
@ -1,179 +1,179 @@
|
|||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <iomanip>
|
|
||||||
#include <iostream>
|
|
||||||
#include <utility>
|
|
||||||
|
|
||||||
#include "components/command_line.hpp"
|
#include "components/command_line.hpp"
|
||||||
|
#include "utils/factory.hpp"
|
||||||
|
|
||||||
POLYBAR_NS
|
POLYBAR_NS
|
||||||
|
|
||||||
/**
|
namespace command_line {
|
||||||
* Create instance
|
/**
|
||||||
*/
|
* Create instance
|
||||||
cliparser::make_type cliparser::make(string&& scriptname, const clioptions&& opts) {
|
*/
|
||||||
return factory_util::unique<cliparser>(
|
parser::make_type parser::make(string&& scriptname, const options&& opts) {
|
||||||
"Usage: " + scriptname + " bar_name [OPTION...]", forward<decltype(opts)>(opts));
|
return factory_util::unique<parser>(
|
||||||
}
|
"Usage: " + scriptname + " bar_name [OPTION...]", forward<decltype(opts)>(opts));
|
||||||
|
|
||||||
/**
|
|
||||||
* Construct parser
|
|
||||||
*/
|
|
||||||
cliparser::parser(string&& synopsis, const options&& opts)
|
|
||||||
: m_synopsis(forward<decltype(synopsis)>(synopsis)), m_opts(forward<decltype(opts)>(opts)) {}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Print application usage message
|
|
||||||
*/
|
|
||||||
void cliparser::usage() const {
|
|
||||||
std::cout << m_synopsis << "\n\n";
|
|
||||||
|
|
||||||
// get the length of the longest string in the flag column
|
|
||||||
// which is used to align the description fields
|
|
||||||
size_t maxlen{0};
|
|
||||||
|
|
||||||
for (const auto& m_opt : m_opts) {
|
|
||||||
size_t len{m_opt.flag_long.length() + m_opt.flag.length() + 4};
|
|
||||||
maxlen = len > maxlen ? len : maxlen;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for (auto& opt : m_opts) {
|
/**
|
||||||
size_t pad = maxlen - opt.flag_long.length() - opt.token.length();
|
* Construct parser
|
||||||
|
*/
|
||||||
|
parser::parser(string&& synopsis, const options&& opts)
|
||||||
|
: m_synopsis(forward<decltype(synopsis)>(synopsis)), m_opts(forward<decltype(opts)>(opts)) {}
|
||||||
|
|
||||||
std::cout << " " << opt.flag << ", " << opt.flag_long;
|
/**
|
||||||
|
* Print application usage message
|
||||||
|
*/
|
||||||
|
void parser::usage() const {
|
||||||
|
printf("%s\n\n", m_synopsis.c_str());
|
||||||
|
|
||||||
if (!opt.token.empty()) {
|
// get the length of the longest string in the flag column
|
||||||
std::cout << "=" << opt.token;
|
// which is used to align the description fields
|
||||||
pad--;
|
size_t maxlen{0};
|
||||||
|
|
||||||
|
for (const auto& m_opt : m_opts) {
|
||||||
|
size_t len{m_opt.flag_long.length() + m_opt.flag.length() + 4};
|
||||||
|
maxlen = len > maxlen ? len : maxlen;
|
||||||
}
|
}
|
||||||
|
|
||||||
// output the list with accepted values
|
for (auto& opt : m_opts) {
|
||||||
if (!opt.values.empty()) {
|
size_t pad = maxlen - opt.flag_long.length() - opt.token.length();
|
||||||
std::cout << std::setw(pad + opt.desc.length()) << std::setfill(' ') << opt.desc << '\n';
|
|
||||||
|
|
||||||
pad = pad + opt.flag_long.length() + opt.token.length() + 7;
|
printf(" %s, %s", opt.flag.c_str(), opt.flag_long.c_str());
|
||||||
|
|
||||||
std::cout << string(pad, ' ') << opt.token << " is one of: ";
|
if (!opt.token.empty()) {
|
||||||
|
printf("=%s", opt.token.c_str());
|
||||||
for (auto& v : opt.values) {
|
pad--;
|
||||||
std::cout << v << (v != opt.values.back() ? ", " : "");
|
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
std::cout << std::setw(pad + opt.desc.length()) << std::setfill(' ') << opt.desc;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::cout << '\n';
|
// output the list with accepted values
|
||||||
}
|
if (!opt.values.empty()) {
|
||||||
|
printf("%*s\n", static_cast<int>(pad + opt.desc.length()), opt.desc.c_str());
|
||||||
|
|
||||||
std::cout << std::endl;
|
pad = pad + opt.flag_long.length() + opt.token.length() + 7;
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
printf("%*c%s is one of: ", static_cast<int>(pad), ' ', opt.token.c_str());
|
||||||
* Process input values
|
|
||||||
*/
|
|
||||||
void cliparser::process_input(const vector<string>& values) {
|
|
||||||
for (size_t i = 0; i < values.size(); i++) {
|
|
||||||
parse(values[i], values.size() > i + 1 ? values[i + 1] : "");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
for (auto& v : opt.values) {
|
||||||
* Test if the passed option was provided
|
printf("%s%s", v.c_str(), v != opt.values.back() ? ", " : "");
|
||||||
*/
|
}
|
||||||
bool cliparser::has(const string& option) const {
|
|
||||||
return m_optvalues.find(option) != m_optvalues.end();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the value defined for given option
|
|
||||||
*/
|
|
||||||
string cliparser::get(string opt) const {
|
|
||||||
if (has(forward<string>(opt))) {
|
|
||||||
return m_optvalues.find(opt)->second;
|
|
||||||
}
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Compare option value with given string
|
|
||||||
*/
|
|
||||||
bool cliparser::compare(string opt, const string& val) const {
|
|
||||||
return get(move(opt)) == val;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Compare option with its short version
|
|
||||||
*/
|
|
||||||
auto cliparser::is_short(const string& option, const string& opt_short) const {
|
|
||||||
return option.compare(0, opt_short.length(), opt_short) == 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Compare option with its long version
|
|
||||||
*/
|
|
||||||
auto cliparser::is_long(const string& option, const string& opt_long) const {
|
|
||||||
return option.compare(0, opt_long.length(), opt_long) == 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Compare option with both versions
|
|
||||||
*/
|
|
||||||
auto cliparser::is(const string& option, string opt_short, string opt_long) const {
|
|
||||||
return is_short(option, move(opt_short)) || is_long(option, move(opt_long));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Parse option value
|
|
||||||
*/
|
|
||||||
auto cliparser::parse_value(string input, const string& input_next, choices values) const {
|
|
||||||
string opt = move(input);
|
|
||||||
size_t pos;
|
|
||||||
string value;
|
|
||||||
|
|
||||||
if (input_next.empty() && opt.compare(0, 2, "--") != 0) {
|
|
||||||
throw value_error("Missing value for " + opt);
|
|
||||||
} else if ((pos = opt.find('=')) == string::npos && opt.compare(0, 2, "--") == 0) {
|
|
||||||
throw value_error("Missing value for " + opt);
|
|
||||||
} else if (pos == string::npos && !input_next.empty()) {
|
|
||||||
value = input_next;
|
|
||||||
} else {
|
|
||||||
value = opt.substr(pos + 1);
|
|
||||||
opt = opt.substr(0, pos);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!values.empty() && std::find(values.begin(), values.end(), value) == values.end()) {
|
|
||||||
throw value_error("Invalid value '" + value + "' for argument " + string{opt});
|
|
||||||
}
|
|
||||||
|
|
||||||
return value;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Parse and validate passed arguments and flags
|
|
||||||
*/
|
|
||||||
void cliparser::parse(const string& input, const string& input_next) {
|
|
||||||
if (m_skipnext) {
|
|
||||||
m_skipnext = false;
|
|
||||||
if (!input_next.empty()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for (auto&& opt : m_opts) {
|
|
||||||
if (is(input, opt.flag, opt.flag_long)) {
|
|
||||||
if (opt.token.empty()) {
|
|
||||||
m_optvalues.insert(make_pair(opt.flag_long.substr(2), ""));
|
|
||||||
} else {
|
} else {
|
||||||
auto value = parse_value(input, input_next, opt.values);
|
printf("%*s", static_cast<int>(pad + opt.desc.length()), opt.desc.c_str());
|
||||||
m_skipnext = (value == input_next);
|
|
||||||
m_optvalues.insert(make_pair(opt.flag_long.substr(2), value));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
printf("\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
printf("\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Process input values
|
||||||
|
*/
|
||||||
|
void parser::process_input(const vector<string>& values) {
|
||||||
|
for (size_t i = 0; i < values.size(); i++) {
|
||||||
|
parse(values[i], values.size() > i + 1 ? values[i + 1] : "");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (input.compare(0, 1, "-") == 0) {
|
/**
|
||||||
throw argument_error("Unrecognized option " + input);
|
* Test if the passed option was provided
|
||||||
|
*/
|
||||||
|
bool parser::has(const string& option) const {
|
||||||
|
return m_optvalues.find(option) != m_optvalues.end();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the value defined for given option
|
||||||
|
*/
|
||||||
|
string parser::get(string opt) const {
|
||||||
|
if (has(forward<string>(opt))) {
|
||||||
|
return m_optvalues.find(opt)->second;
|
||||||
|
}
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Compare option value with given string
|
||||||
|
*/
|
||||||
|
bool parser::compare(string opt, const string& val) const {
|
||||||
|
return get(move(opt)) == val;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Compare option with its short version
|
||||||
|
*/
|
||||||
|
auto parser::is_short(const string& option, const string& opt_short) const {
|
||||||
|
return option.compare(0, opt_short.length(), opt_short) == 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Compare option with its long version
|
||||||
|
*/
|
||||||
|
auto parser::is_long(const string& option, const string& opt_long) const {
|
||||||
|
return option.compare(0, opt_long.length(), opt_long) == 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Compare option with both versions
|
||||||
|
*/
|
||||||
|
auto parser::is(const string& option, string opt_short, string opt_long) const {
|
||||||
|
return is_short(option, move(opt_short)) || is_long(option, move(opt_long));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Parse option value
|
||||||
|
*/
|
||||||
|
auto parser::parse_value(string input, const string& input_next, choices values) const {
|
||||||
|
string opt = move(input);
|
||||||
|
size_t pos;
|
||||||
|
string value;
|
||||||
|
|
||||||
|
if (input_next.empty() && opt.compare(0, 2, "--") != 0) {
|
||||||
|
throw value_error("Undefined argument for option " + opt);
|
||||||
|
} else if ((pos = opt.find('=')) == string::npos && opt.compare(0, 2, "--") == 0) {
|
||||||
|
throw value_error("Undefined argument for option " + opt);
|
||||||
|
} else if (pos == string::npos && !input_next.empty()) {
|
||||||
|
value = input_next;
|
||||||
|
} else {
|
||||||
|
value = opt.substr(pos + 1);
|
||||||
|
opt = opt.substr(0, pos);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!values.empty() && std::find(values.begin(), values.end(), value) == values.end()) {
|
||||||
|
throw value_error("Invalid argument for option " + opt);
|
||||||
|
}
|
||||||
|
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Parse and validate passed arguments and flags
|
||||||
|
*/
|
||||||
|
void parser::parse(const string& input, const string& input_next) {
|
||||||
|
if (m_skipnext) {
|
||||||
|
m_skipnext = false;
|
||||||
|
if (!input_next.empty()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (auto&& opt : m_opts) {
|
||||||
|
if (is(input, opt.flag, opt.flag_long)) {
|
||||||
|
if (opt.token.empty()) {
|
||||||
|
m_optvalues.insert(make_pair(opt.flag_long.substr(2), ""));
|
||||||
|
} else {
|
||||||
|
auto value = parse_value(input, input_next, opt.values);
|
||||||
|
m_skipnext = (value == input_next);
|
||||||
|
m_optvalues.insert(make_pair(opt.flag_long.substr(2), value));
|
||||||
|
}
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (input.compare(0, 1, "-") == 0) {
|
||||||
|
throw argument_error("Unrecognized option " + input);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,14 +1,12 @@
|
|||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <unistd.h>
|
|
||||||
|
|
||||||
#include "components/ipc.hpp"
|
#include "components/ipc.hpp"
|
||||||
#include "config.hpp"
|
#include "components/logger.hpp"
|
||||||
#include "events/signal.hpp"
|
#include "events/signal.hpp"
|
||||||
#include "events/signal_emitter.hpp"
|
#include "events/signal_emitter.hpp"
|
||||||
#include "utils/factory.hpp"
|
#include "utils/factory.hpp"
|
||||||
#include "utils/file.hpp"
|
#include "utils/file.hpp"
|
||||||
#include "utils/io.hpp"
|
|
||||||
#include "utils/string.hpp"
|
#include "utils/string.hpp"
|
||||||
|
|
||||||
POLYBAR_NS
|
POLYBAR_NS
|
||||||
|
@ -5,6 +5,8 @@
|
|||||||
#include "events/signal.hpp"
|
#include "events/signal.hpp"
|
||||||
#include "events/signal_emitter.hpp"
|
#include "events/signal_emitter.hpp"
|
||||||
#include "utils/color.hpp"
|
#include "utils/color.hpp"
|
||||||
|
#include "utils/factory.hpp"
|
||||||
|
#include "utils/file.hpp"
|
||||||
#include "utils/math.hpp"
|
#include "utils/math.hpp"
|
||||||
#include "utils/memory.hpp"
|
#include "utils/memory.hpp"
|
||||||
#include "utils/string.hpp"
|
#include "utils/string.hpp"
|
||||||
|
@ -4,6 +4,8 @@
|
|||||||
#include "events/signal.hpp"
|
#include "events/signal.hpp"
|
||||||
#include "events/signal_emitter.hpp"
|
#include "events/signal_emitter.hpp"
|
||||||
#include "events/signal_receiver.hpp"
|
#include "events/signal_receiver.hpp"
|
||||||
|
#include "utils/factory.hpp"
|
||||||
|
#include "utils/file.hpp"
|
||||||
#include "x11/connection.hpp"
|
#include "x11/connection.hpp"
|
||||||
#include "x11/draw.hpp"
|
#include "x11/draw.hpp"
|
||||||
#include "x11/extensions/all.hpp"
|
#include "x11/extensions/all.hpp"
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
#include "components/logger.hpp"
|
#include "components/logger.hpp"
|
||||||
#include "components/parser.hpp"
|
#include "components/parser.hpp"
|
||||||
#include "components/renderer.hpp"
|
#include "components/renderer.hpp"
|
||||||
#include "config.hpp"
|
#include "settings.hpp"
|
||||||
#include "utils/env.hpp"
|
#include "utils/env.hpp"
|
||||||
#include "utils/file.hpp"
|
#include "utils/file.hpp"
|
||||||
#include "utils/inotify.hpp"
|
#include "utils/inotify.hpp"
|
||||||
@ -47,7 +47,7 @@ int main(int argc, char** argv) {
|
|||||||
string scriptname{argv[0]};
|
string scriptname{argv[0]};
|
||||||
vector<string> args{argv + 1, argv + argc};
|
vector<string> args{argv + 1, argv + argc};
|
||||||
|
|
||||||
cliparser::make_type cli{cliparser::make(move(scriptname), move(opts))};
|
command_line::parser::make_type cli{command_line::parser::make(move(scriptname), move(opts))};
|
||||||
cli->process_input(args);
|
cli->process_input(args);
|
||||||
|
|
||||||
if (cli->has("quiet")) {
|
if (cli->has("quiet")) {
|
||||||
|
@ -36,7 +36,8 @@ namespace modules {
|
|||||||
if (file_util::exists((m_fstate = path_adapter + "online"))) {
|
if (file_util::exists((m_fstate = path_adapter + "online"))) {
|
||||||
m_state_reader = make_unique<state_reader>([=] { return file_util::contents(m_fstate).compare(0, 1, "1") == 0; });
|
m_state_reader = make_unique<state_reader>([=] { return file_util::contents(m_fstate).compare(0, 1, "1") == 0; });
|
||||||
} else if (file_util::exists((m_fstate = path_battery + "status"))) {
|
} else if (file_util::exists((m_fstate = path_battery + "status"))) {
|
||||||
m_state_reader = make_unique<state_reader>([=] { return file_util::contents(m_fstate).compare(0, 8, "Charging") == 0; });
|
m_state_reader =
|
||||||
|
make_unique<state_reader>([=] { return file_util::contents(m_fstate).compare(0, 8, "Charging") == 0; });
|
||||||
} else {
|
} else {
|
||||||
throw module_error("No suitable way to get current charge state");
|
throw module_error("No suitable way to get current charge state");
|
||||||
}
|
}
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
#include <curl/curl.h>
|
#include <curl/curl.h>
|
||||||
#include <curl/curlbuild.h>
|
#include <curl/curlbuild.h>
|
||||||
#include <curl/easy.h>
|
#include <curl/easy.h>
|
||||||
#include <iostream>
|
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
|
||||||
#include "errors.hpp"
|
#include "errors.hpp"
|
||||||
|
#include "settings.hpp"
|
||||||
#include "utils/http.hpp"
|
#include "utils/http.hpp"
|
||||||
|
|
||||||
POLYBAR_NS
|
POLYBAR_NS
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
#include <i3ipc++/ipc.hpp>
|
#include <i3ipc++/ipc.hpp>
|
||||||
|
|
||||||
#include "common.hpp"
|
#include "common.hpp"
|
||||||
#include "config.hpp"
|
#include "settings.hpp"
|
||||||
#include "utils/i3.hpp"
|
#include "utils/i3.hpp"
|
||||||
#include "utils/socket.hpp"
|
#include "utils/socket.hpp"
|
||||||
#include "utils/string.hpp"
|
#include "utils/string.hpp"
|
||||||
|
Loading…
Reference in New Issue
Block a user