1
0
Fork 0
mirror of https://github.com/polybar/polybar.git synced 2024-11-25 13:55:47 -05:00

fix: Handle unsupported modules

This commit is contained in:
Michael Carlberg 2016-10-11 10:05:03 +02:00
parent 990f2a3074
commit c79d8dfea4
2 changed files with 48 additions and 3 deletions

View file

@ -23,14 +23,23 @@
#include "modules/counter.hpp"
#include "modules/cpu.hpp"
#include "modules/date.hpp"
#include "modules/i3.hpp"
#include "modules/memory.hpp"
#include "modules/menu.hpp"
#include "modules/mpd.hpp"
#include "modules/network.hpp"
#include "modules/script.hpp"
#include "modules/text.hpp"
#include "modules/unsupported.hpp"
#if ENABLE_I3
#include "modules/i3.hpp"
#endif
#if ENABLE_MPD
#include "modules/mpd.hpp"
#endif
#if ENABLE_NETWORK
#include "modules/network.hpp"
#endif
#if ENABLE_ALSA
#include "modules/volume.hpp"
#endif
LEMONBUDDY_NS

View file

@ -0,0 +1,36 @@
#pragma once
#include "modules/meta.hpp"
#define DEFINE_UNSUPPORTED_MODULE(MODULE_NAME, MODULE_TYPE) \
class MODULE_NAME : public module<MODULE_NAME> { \
public: \
using module<MODULE_NAME>::module; \
MODULE_NAME(const bar_settings b, const logger& l, const config& c, string n) \
: module<MODULE_NAME>::module(b, l, c, n) { \
throw application_error("No built-in support for '" + string{MODULE_TYPE} + "'"); \
} \
void start() {} \
bool build(builder*, string) { \
return true; \
} \
}
LEMONBUDDY_NS
namespace modules {
#if not ENABLE_I3
DEFINE_UNSUPPORTED_MODULE(i3_module, "internal/i3");
#endif
#if not ENABLE_MPD
DEFINE_UNSUPPORTED_MODULE(mpd_module, "internal/mpd");
#endif
#if not ENABLE_NETWORK
DEFINE_UNSUPPORTED_MODULE(network_module, "internal/network");
#endif
#if not ENABLE_ALSA
DEFINE_UNSUPPORTED_MODULE(volume_module, "internal/volume");
#endif
}
LEMONBUDDY_NS_END