diff --git a/.builds/archlinux.yml b/.builds/archlinux.yml index dfe1900ee4..ad47a9c9bd 100644 --- a/.builds/archlinux.yml +++ b/.builds/archlinux.yml @@ -24,7 +24,7 @@ tasks: sudo ninja -C build install - setup: | cd sway - meson build -Dauto_features=enabled + meson build -Dauto_features=enabled -Dsd-bus-provider=libsystemd - build: | cd sway ninja -C build diff --git a/include/swaybar/tray/tray.h b/include/swaybar/tray/tray.h index 8958b69aad..a64cd9c8b3 100644 --- a/include/swaybar/tray/tray.h +++ b/include/swaybar/tray/tray.h @@ -2,10 +2,12 @@ #define _SWAYBAR_TRAY_TRAY_H #include "config.h" -#ifdef HAVE_SYSTEMD +#ifdef HAVE_LIBSYSTEMD #include -#elif HAVE_ELOGIND +#elif HAVE_LIBELOGIND #include +#elif HAVE_BASU +#include #endif #include #include diff --git a/meson.build b/meson.build index 4c58c45269..38a5567825 100644 --- a/meson.build +++ b/meson.build @@ -51,8 +51,6 @@ pixman = dependency('pixman-1') glesv2 = dependency('glesv2') libevdev = dependency('libevdev') libinput = dependency('libinput', version: '>=1.6.0') -systemd = dependency('libsystemd', version: '>=239', required: false) -elogind = dependency('libelogind', version: '>=239', required: false) xcb = dependency('xcb', required: get_option('xwayland')) bash_comp = dependency('bash-completion', required: false) fish_comp = dependency('fish', required: false) @@ -67,23 +65,58 @@ wlroots_proj = subproject( required: false, version: wlroots_version, ) +wlroots_features = { + 'xwayland': false, + 'systemd': false, + 'elogind': false, + 'libseat': false, +} if wlroots_proj.found() wlroots = wlroots_proj.get_variable('wlroots') wlroots_conf = wlroots_proj.get_variable('conf_data') - wlroots_has_xwayland = wlroots_conf.get('WLR_HAS_XWAYLAND') == 1 + foreach name, _ : wlroots_features + has = wlroots_conf.get('WLR_HAS_' + name.to_upper()) == 1 + wlroots_features += { name: has } + endforeach else wlroots = dependency('wlroots', version: wlroots_version) - wlroots_has_xwayland = cc.get_define('WLR_HAS_XWAYLAND', prefix: '#include ', dependencies: wlroots) == '1' + foreach name, _ : wlroots_features + has = cc.get_define('WLR_HAS_' + name.to_upper(), prefix: '#include ', dependencies: wlroots) == '1' + wlroots_features += { name: has } + endforeach endif -if get_option('xwayland').enabled() and not wlroots_has_xwayland +if get_option('xwayland').enabled() and not wlroots_features['xwayland'] error('Cannot enable Xwayland in sway: wlroots has been built without Xwayland support') endif -have_xwayland = xcb.found() and wlroots_has_xwayland +have_xwayland = xcb.found() and wlroots_features['xwayland'] + +if get_option('sd-bus-provider') == 'auto' + if not get_option('tray').disabled() + assert(get_option('auto_features').auto(), 'sd-bus-provider must not be set to auto since auto_features != auto') + endif + sdbus = dependency('libsystemd', + required: false, + version: '>=239', + not_found_message: 'libsystemd not found, trying libelogind', + ) + if not sdbus.found() + sdbus = dependency('libelogind', + required: false, + version: '>=239', + not_found_message: 'libelogind not found, trying basu', + ) + endif + if not sdbus.found() + sdbus = dependency('basu', required: false) + endif +else + sdbus = dependency(get_option('sd-bus-provider'), required: get_option('tray')) +endif -tray_deps_found = systemd.found() or elogind.found() +tray_deps_found = sdbus.found() if get_option('tray').enabled() and not tray_deps_found - error('Building with -Dtray=enabled, but libsystemd and libelogind have not been not found') + error('Building with -Dtray=enabled, but sd-bus has not been not found') endif have_tray = (not get_option('tray').disabled()) and tray_deps_found @@ -91,8 +124,9 @@ conf_data = configuration_data() conf_data.set10('HAVE_XWAYLAND', have_xwayland) conf_data.set10('HAVE_GDK_PIXBUF', gdk_pixbuf.found()) -conf_data.set10('HAVE_SYSTEMD', systemd.found()) -conf_data.set10('HAVE_ELOGIND', elogind.found()) +conf_data.set10('HAVE_LIBSYSTEMD', sdbus.found() and sdbus.name() == 'libsystemd') +conf_data.set10('HAVE_LIBELOGIND', sdbus.found() and sdbus.name() == 'libelogind') +conf_data.set10('HAVE_BASU', sdbus.found() and sdbus.name() == 'basu') conf_data.set10('HAVE_TRAY', have_tray) scdoc = dependency('scdoc', version: '>=1.9.2', native: true, required: get_option('man-pages')) @@ -279,13 +313,12 @@ endif summary({ 'xwayland': have_xwayland, 'gdk-pixbuf': gdk_pixbuf.found(), - 'systemd': systemd.found(), - 'elogind': elogind.found(), + 'sd-bus': sdbus.found(), 'tray': have_tray, 'man-pages': scdoc.found(), }, bool_yn: true) -if not systemd.found() and not elogind.found() - warning('The sway binary must be setuid when compiled without (e)logind') +if not wlroots_features['systemd'] and not wlroots_features['elogind'] and not wlroots_features['libseat'] + warning('The sway binary must be setuid when compiled without (e)logind or libseat') warning('You must do this manually post-install: chmod a+s /path/to/sway') endif diff --git a/meson_options.txt b/meson_options.txt index d3667acfd9..e36900b673 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -6,3 +6,4 @@ option('xwayland', type: 'feature', value: 'auto', description: 'Enable support option('tray', type: 'feature', value: 'auto', description: 'Enable support for swaybar tray') option('gdk-pixbuf', type: 'feature', value: 'auto', description: 'Enable support for more image formats in swaybg') option('man-pages', type: 'feature', value: 'auto', description: 'Generate and install man pages') +option('sd-bus-provider', type: 'combo', choices: ['auto', 'libsystemd', 'libelogind', 'basu'], value: 'auto', description: 'Provider of the sd-bus library') diff --git a/swaybar/meson.build b/swaybar/meson.build index 469145ae63..9feb3cd2d0 100644 --- a/swaybar/meson.build +++ b/swaybar/meson.build @@ -19,11 +19,7 @@ swaybar_deps = [ wayland_cursor ] if have_tray - if systemd.found() - swaybar_deps += systemd - elif elogind.found() - swaybar_deps += elogind - endif + swaybar_deps += sdbus endif executable(