Gate backlight module behind libudev availability

This commit is contained in:
Ian Hattendorf 2019-02-18 21:11:18 -07:00
parent 875306804c
commit e67347f6ad
No known key found for this signature in database
GPG Key ID: BE8B1B445E06437D
4 changed files with 15 additions and 6 deletions

View File

@ -16,10 +16,12 @@
#ifdef HAVE_LIBNL #ifdef HAVE_LIBNL
#include "modules/network.hpp" #include "modules/network.hpp"
#endif #endif
#ifdef HAVE_LIBUDEV
#include "modules/backlight.hpp"
#endif
#ifdef HAVE_LIBPULSE #ifdef HAVE_LIBPULSE
#include "modules/pulseaudio.hpp" #include "modules/pulseaudio.hpp"
#endif #endif
#include "modules/backlight.hpp"
#include "modules/custom.hpp" #include "modules/custom.hpp"
namespace waybar { namespace waybar {

View File

@ -55,7 +55,7 @@ sigcpp = dependency('sigc++-2.0')
libnl = dependency('libnl-3.0', required: get_option('libnl')) libnl = dependency('libnl-3.0', required: get_option('libnl'))
libnlgen = dependency('libnl-genl-3.0', required: get_option('libnl')) libnlgen = dependency('libnl-genl-3.0', required: get_option('libnl'))
libpulse = dependency('libpulse', required: get_option('pulseaudio')) libpulse = dependency('libpulse', required: get_option('pulseaudio'))
libudev = dependency('libudev') libudev = dependency('libudev', required: get_option('libudev'))
src_files = files( src_files = files(
'src/factory.cpp', 'src/factory.cpp',
@ -65,7 +65,6 @@ src_files = files(
'src/modules/clock.cpp', 'src/modules/clock.cpp',
'src/modules/custom.cpp', 'src/modules/custom.cpp',
'src/modules/cpu.cpp', 'src/modules/cpu.cpp',
'src/modules/backlight.cpp',
'src/main.cpp', 'src/main.cpp',
'src/bar.cpp', 'src/bar.cpp',
'src/client.cpp' 'src/client.cpp'
@ -101,6 +100,11 @@ if dbusmenu_gtk.found()
) )
endif endif
if libudev.found()
add_project_arguments('-DHAVE_LIBUDEV', language: 'cpp')
src_files += 'src/modules/backlight.cpp'
endif
subdir('protocol') subdir('protocol')
executable( executable(

View File

@ -1,4 +1,5 @@
option('libnl', type: 'feature', value: 'auto', description: 'Enable libnl support for network related features') option('libnl', type: 'feature', value: 'auto', description: 'Enable libnl support for network related features')
option('libudev', type: 'feature', value: 'auto', description: 'Enable libudev support for udev related features')
option('pulseaudio', type: 'feature', value: 'auto', description: 'Enable support for pulseaudio') option('pulseaudio', type: 'feature', value: 'auto', description: 'Enable support for pulseaudio')
option('dbusmenu-gtk', type: 'feature', value: 'auto', description: 'Enable support for tray') option('dbusmenu-gtk', type: 'feature', value: 'auto', description: 'Enable support for tray')
option('out', type: 'string', value : '/', description: 'output prefix directory') option('out', type: 'string', value : '/', description: 'output prefix directory')

View File

@ -43,14 +43,16 @@ waybar::IModule* waybar::Factory::makeModule(const std::string &name) const
return new waybar::modules::Network(id, config_[name]); return new waybar::modules::Network(id, config_[name]);
} }
#endif #endif
#ifdef HAVE_LIBUDEV
if (ref == "backlight") {
return new waybar::modules::Backlight(id, config_[name]);
}
#endif
#ifdef HAVE_LIBPULSE #ifdef HAVE_LIBPULSE
if (ref == "pulseaudio") { if (ref == "pulseaudio") {
return new waybar::modules::Pulseaudio(id, config_[name]); return new waybar::modules::Pulseaudio(id, config_[name]);
} }
#endif #endif
if (ref == "backlight") {
return new waybar::modules::Backlight(id, config_[name]);
}
if (ref.compare(0, 7, "custom/") == 0 && ref.size() > 7) { if (ref.compare(0, 7, "custom/") == 0 && ref.size() > 7) {
return new waybar::modules::Custom(ref.substr(7), config_[name]); return new waybar::modules::Custom(ref.substr(7), config_[name]);
} }