chore: optional deps

pull/45/head
Alexis 2018-08-20 17:20:02 +02:00
parent 49232eed8d
commit 8be67d5008
3 changed files with 47 additions and 5 deletions

View File

@ -2,13 +2,19 @@
#include <json/json.h>
#include "modules/clock.hpp"
#ifdef HAVE_SWAY
#include "modules/sway/workspaces.hpp"
#include "modules/sway/window.hpp"
#endif
#include "modules/battery.hpp"
#include "modules/memory.hpp"
#include "modules/cpu.hpp"
#ifdef HAVE_LIBNL
#include "modules/network.hpp"
#endif
#ifdef HAVE_LIBPULSE
#include "modules/pulseaudio.hpp"
#endif
#include "modules/custom.hpp"
namespace waybar {

View File

@ -31,14 +31,44 @@ wlroots = dependency('wlroots', fallback: ['wlroots', 'wlroots'])
gtkmm = dependency('gtkmm-3.0')
jsoncpp = dependency('jsoncpp')
sigcpp = dependency('sigc++-2.0')
libnl = dependency('libnl-3.0')
libnlgen = dependency('libnl-genl-3.0')
libpulse = dependency('libpulse')
libnl = dependency('libnl-3.0', required: false)
libnlgen = dependency('libnl-genl-3.0', required: false)
libpulse = dependency('libpulse', required: false)
src_files = files(
'src/factory.cpp',
'src/ALabel.cpp',
'src/modules/memory.cpp',
'src/modules/battery.cpp',
'src/modules/clock.cpp',
'src/modules/custom.cpp',
'src/modules/cpu.cpp',
'src/main.cpp',
'src/bar.cpp',
'src/client.cpp'
)
if find_program('sway').found()
add_project_arguments('-DHAVE_SWAY', language: 'cpp')
src_files += [
'src/modules/sway/ipc/client.cpp',
'src/modules/sway/window.cpp',
'src/modules/sway/workspaces.cpp'
]
endif
if libnl.found() and libnlgen.found()
add_project_arguments('-DHAVE_LIBNL', language: 'cpp')
src_files += 'src/modules/network.cpp'
endif
if libpulse.found()
add_project_arguments('-DHAVE_LIBPULSE', language: 'cpp')
src_files += 'src/modules/pulseaudio.cpp'
endif
subdir('protocol')
src_files = run_command('find', './src', '-name', '*.cpp').stdout().strip().split('\n')
executable(
'waybar',
src_files,

View File

@ -10,9 +10,11 @@ waybar::IModule* waybar::Factory::makeModule(const std::string &name) const
if (name == "battery") {
return new waybar::modules::Battery(config_[name]);
}
#ifdef HAVE_SWAY
if (name == "sway/workspaces") {
return new waybar::modules::sway::Workspaces(bar_, config_[name]);
}
#endif
if (name == "sway/window") {
return new waybar::modules::sway::Window(bar_, config_[name]);
}
@ -25,12 +27,16 @@ waybar::IModule* waybar::Factory::makeModule(const std::string &name) const
if (name == "clock") {
return new waybar::modules::Clock(config_[name]);
}
#ifdef HAVE_LIBNL
if (name == "network") {
return new waybar::modules::Network(config_[name]);
}
#endif
#ifdef HAVE_LIBPULSE
if (name == "pulseaudio") {
return new waybar::modules::Pulseaudio(config_[name]);
}
#endif
if (name.compare(0, 7, "custom/") == 0 && name.size() > 7) {
return new waybar::modules::Custom(name.substr(7), config_[name]);
}