diff --git a/.woodpecker.yml b/.woodpecker.yml index 02fd5f6..058b08a 100644 --- a/.woodpecker.yml +++ b/.woodpecker.yml @@ -95,7 +95,7 @@ pipeline: - apk add pixman-dev freetype-dev fontconfig-dev - apk add libxcb-dev xcb-util-wm-dev xcb-util-cursor-dev yaml-dev - apk add wayland-dev wayland-protocols wlroots-dev - - apk add json-c-dev libmpdclient-dev alsa-lib-dev pulseaudio-dev + - apk add json-c-dev libmpdclient-dev alsa-lib-dev pulseaudio-dev pipewire-dev - apk add ttf-dejavu - apk add git - apk add flex bison diff --git a/CHANGELOG.md b/CHANGELOG.md index ddde62d..8360e27 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -50,6 +50,7 @@ ### Changed +* All modules are now compile-time optional. * Minimum required meson version is now 0.59. * Float tags are now treated as floats instead of integers when formatted with the `kb`/`kib`/`mb`/`mib`/`gb`/`gib` string particle diff --git a/PKGBUILD b/PKGBUILD index b675823..8f20543 100644 --- a/PKGBUILD +++ b/PKGBUILD @@ -16,6 +16,7 @@ depends=( 'json-c' 'libmpdclient' 'libpulse' + 'pipewire' 'fcft>=3.0.0' 'fcft<4.0.0') optdepends=('xcb-util-errors: better X error messages') source=() diff --git a/PKGBUILD.wayland-only b/PKGBUILD.wayland-only index e836093..cc956e9 100644 --- a/PKGBUILD.wayland-only +++ b/PKGBUILD.wayland-only @@ -1,5 +1,5 @@ pkgname=yambar-wayland -pkgver=1.8.0 +pkgver=1.8.0.r111.g690bd63 pkgrel=1 pkgdesc="Simplistic and highly configurable status panel for Wayland" arch=('x86_64' 'aarch64') @@ -17,6 +17,7 @@ depends=( 'json-c' 'libmpdclient' 'libpulse' + 'pipewire' 'fcft>=3.0.0' 'fcft<4.0.0') source=() diff --git a/doc/meson.build b/doc/meson.build index e561ef3..fa9673d 100644 --- a/doc/meson.build +++ b/doc/meson.build @@ -3,22 +3,73 @@ sh = find_program('sh', native: true) scdoc = dependency('scdoc', native: true) scdoc_prog = find_program(scdoc.get_variable('scdoc'), native: true) -foreach man_src : ['yambar.1.scd', 'yambar.5.scd', 'yambar-decorations.5.scd', - 'yambar-modules-alsa.5.scd', 'yambar-modules-backlight.5.scd', - 'yambar-modules-battery.5.scd', 'yambar-modules-clock.5.scd', - 'yambar-modules-disk-io.5.scd', 'yambar-modules-dwl.5.scd', - 'yambar-modules-foreign-toplevel.5.scd', - 'yambar-modules-i3.5.scd', 'yambar-modules-label.5.scd', - 'yambar-modules-mpd.5.scd', 'yambar-modules-network.5.scd', - 'yambar-modules-pulse.5.scd', - 'yambar-modules-pipewire.5.scd', - 'yambar-modules-removables.5.scd', 'yambar-modules-river.5.scd', - 'yambar-modules-script.5.scd', 'yambar-modules-sway-xkb.5.scd', - 'yambar-modules-sway.5.scd', 'yambar-modules-xkb.5.scd', - 'yambar-modules-xwindow.5.scd', 'yambar-modules.5.scd', - 'yambar-modules-cpu.5.scd', - 'yambar-modules-mem.5.scd', - 'yambar-particles.5.scd', 'yambar-tags.5.scd'] +plugin_pages = [] +if plugin_alsa_enabled + plugin_pages += ['yambar-modules-alsa.5.scd'] +endif +if plugin_backlight_enabled + plugin_pages += ['yambar-modules-backlight.5.scd'] +endif +if plugin_battery_enabled + plugin_pages += ['yambar-modules-battery.5.scd'] +endif +if plugin_clock_enabled + plugin_pages += ['yambar-modules-clock.5.scd'] +endif +if plugin_cpu_enabled + plugin_pages += ['yambar-modules-cpu.5.scd'] +endif +if plugin_disk_io_enabled + plugin_pages += ['yambar-modules-disk-io.5.scd'] +endif +if plugin_dwl_enabled + plugin_pages += ['yambar-modules-dwl.5.scd'] +endif +if plugin_foreign_toplevel_enabled + plugin_pages += ['yambar-modules-foreign-toplevel.5.scd'] +endif +if plugin_mem_enabled + plugin_pages += ['yambar-modules-mem.5.scd'] +endif +if plugin_mpd_enabled + plugin_pages += ['yambar-modules-mpd.5.scd'] +endif +if plugin_i3_enabled + plugin_pages += ['yambar-modules-i3.5.scd'] +endif +if plugin_label_enabled + plugin_pages += ['yambar-modules-label.5.scd'] +endif +if plugin_network_enabled + plugin_pages += ['yambar-modules-network.5.scd'] +endif +if plugin_pipewire_enabled + plugin_pages += ['yambar-modules-pipewire.5.scd'] +endif +if plugin_pulse_enabled + plugin_pages += ['yambar-modules-pulse.5.scd'] +endif +if plugin_removables_enabled + plugin_pages += ['yambar-modules-removables.5.scd'] +endif +if plugin_river_enabled + plugin_pages += ['yambar-modules-river.5.scd'] +endif +if plugin_script_enabled + plugin_pages += ['yambar-modules-script.5.scd'] +endif +if plugin_sway_xkb_enabled + plugin_pages += ['yambar-modules-sway-xkb.5.scd'] +endif +if plugin_xkb_enabled + plugin_pages += ['yambar-modules-xkb.5.scd'] +endif + +foreach man_src : ['yambar.1.scd', + 'yambar.5.scd', + 'yambar-decorations.5.scd', + 'yambar-particles.5.scd', + 'yambar-tags.5.scd'] + plugin_pages parts = man_src.split('.') name = parts[-3] section = parts[-2] diff --git a/meson.build b/meson.build index a26f682..3f02985 100644 --- a/meson.build +++ b/meson.build @@ -99,11 +99,11 @@ if backend_x11 endif subdir('completions') -subdir('doc') subdir('bar') subdir('decorations') subdir('particles') subdir('modules') +subdir('doc') env = find_program('env', native: true) generate_version_sh = files('generate-version.sh') @@ -131,12 +131,6 @@ yambar = executable( version, dependencies: [bar, libepoll, libinotify, pixman, yaml, threads, dl, tllist, fcft] + decorations + particles + modules, - c_args: [ - plugin_mpd_enabled? '-DPLUGIN_ENABLED_MPD':[], - plugin_pulse_enabled? '-DPLUGIN_ENABLED_PULSE':[], - plugin_pipewire_enabled? '-DPLUGIN_ENABLED_PIPEWIRE':[], - plugin_dwl_enabled? '-DPLUGIN_ENABLED_DWL':[], - ], build_rpath: '$ORIGIN/modules:$ORIGIN/decorations:$ORIGIN/particles', export_dynamic: true, install: true, @@ -174,10 +168,27 @@ summary( summary( { + 'ALSA': plugin_alsa_enabled, + 'Backlight': plugin_backlight_enabled, + 'Battery': plugin_battery_enabled, + 'Clock': plugin_clock_enabled, + 'CPU monitoring': plugin_cpu_enabled, + 'Disk I/O monitoring': plugin_disk_io_enabled, 'DWL (dwm for Wayland)': plugin_dwl_enabled, + 'Foreign toplevel (window tracking for Wayland)': plugin_foreign_toplevel_enabled, + 'Memory monitoring': plugin_mem_enabled, 'Music Player Daemon (MPD)': plugin_mpd_enabled, + 'i3+Sway': plugin_i3_enabled, + 'Label': plugin_label_enabled, + 'Network monitoring': plugin_network_enabled, 'Pipewire': plugin_pipewire_enabled, 'PulseAudio': plugin_pulse_enabled, + 'Removables monitoring': plugin_removables_enabled, + 'River': plugin_river_enabled, + 'Script': plugin_script_enabled, + 'Sway XKB keyboard': plugin_sway_xkb_enabled, + 'XKB keyboard (for X11)': plugin_xkb_enabled, + 'XWindow (window tracking for X11)': plugin_xwindow_enabled, }, section: 'Optional modules', bool_yn: true diff --git a/meson_options.txt b/meson_options.txt index bd77f77..03c0ead 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -5,15 +5,46 @@ option( option( 'core-plugins-as-shared-libraries', type: 'boolean', value: false, description: 'Compiles modules, particles and decorations as shared libraries, which are loaded on-demand') -option( - 'plugin-mpd', type: 'feature', value: 'auto', - description: 'Music Player Daemon (MPD) support') -option( - 'plugin-pulse', type: 'feature', value: 'auto', - description: 'PulseAudio support') -option( - 'plugin-pipewire', type: 'feature', value: 'auto', - description: 'Pipewire support') -option( - 'plugin-dwl', type: 'feature', value: 'auto', - description: 'DWL (dwm for wayland) support') + +option('plugin-alsa', type: 'feature', value: 'auto', + description: 'ALSA support') +option('plugin-backlight', type: 'feature', value: 'auto', + description: 'Backlight support') +option('plugin-battery', type: 'feature', value: 'auto', + description: 'Battery support') +option('plugin-clock', type: 'feature', value: 'auto', + description: 'Clock support') +option('plugin-cpu', type: 'feature', value: 'auto', + description: 'CPU monitoring support') +option('plugin-disk-io', type: 'feature', value: 'auto', + description: 'Disk I/O support') +option('plugin-dwl', type: 'feature', value: 'auto', + description: 'DWL (dwm for wayland) support') +option('plugin-foreign-toplevel', type: 'feature', value: 'auto', + description: 'Foreign toplevel (window tracking for Wayland) support') +option('plugin-mem', type: 'feature', value: 'auto', + description: 'Memory monitoring support') +option('plugin-mpd', type: 'feature', value: 'auto', + description: 'Music Player Daemon (MPD) support') +option('plugin-i3', type: 'feature', value: 'auto', + description: 'i3+Sway support') +option('plugin-label', type: 'feature', value: 'auto', + description: 'Label support') +option('plugin-network', type: 'feature', value: 'auto', + description: 'Network monitoring support') +option('plugin-pipewire', type: 'feature', value: 'auto', + description: 'Pipewire support') +option('plugin-pulse', type: 'feature', value: 'auto', + description: 'PulseAudio support') +option('plugin-removables', type: 'feature', value: 'auto', + description: 'Removables (USB sticks, CD-ROM etc) monitoring support') +option('plugin-river', type: 'feature', value: 'auto', + description: 'River support') +option('plugin-script', type: 'feature', value: 'auto', + description: 'Script support') +option('plugin-sway-xkb', type: 'feature', value: 'auto', + description: 'keyboard support for Sway') +option('plugin-xkb', type: 'feature', value: 'auto', + description: 'keyboard support for X11') +option('plugin-xwindow', type: 'feature', value: 'auto', + description: 'XWindow (window tracking for X11) support') diff --git a/modules/meson.build b/modules/meson.build index 56a4757..066e5d9 100644 --- a/modules/meson.build +++ b/modules/meson.build @@ -2,62 +2,134 @@ module_sdk = declare_dependency(dependencies: [pixman, threads, tllist, fcft]) modules = [] -alsa = dependency('alsa') -udev = dependency('libudev') -json = dependency('json-c') -xcb_xkb = dependency('xcb-xkb', required: get_option('backend-x11')) - # Optional deps +alsa = dependency('alsa', required: get_option('plugin-alsa')) +plugin_alsa_enabled = alsa.found() + +udev_backlight = dependency('libudev', required: get_option('plugin-backlight')) +plugin_backlight_enabled = udev_backlight.found() + +udev_battery = dependency('libudev', required: get_option('plugin-battery')) +plugin_battery_enabled = udev_battery.found() + +plugin_clock_enabled = get_option('plugin-clock').allowed() +plugin_cpu_enabled = get_option('plugin-cpu').allowed() +plugin_disk_io_enabled = get_option('plugin-disk-io').allowed() +plugin_dwl_enabled = get_option('plugin-dwl').allowed() +plugin_foreign_toplevel_enabled = backend_wayland and get_option('plugin-foreign-toplevel').allowed() +plugin_mem_enabled = get_option('plugin-mem').allowed() + mpd = dependency('libmpdclient', required: get_option('plugin-mpd')) plugin_mpd_enabled = mpd.found() + +json_i3 = dependency('json-c', required: get_option('plugin-i3')) +plugin_i3_enabled = json_i3.found() + +plugin_label_enabled = get_option('plugin-label').allowed() +plugin_network_enabled = get_option('plugin-network').allowed() + pipewire = dependency('libpipewire-0.3', required: get_option('plugin-pipewire')) -plugin_pipewire_enabled = pipewire.found() +json_pipewire = dependency('json-c', required: get_option('plugin-pipewire')) +plugin_pipewire_enabled = pipewire.found() and json_pipewire.found() pulse = dependency('libpulse', required: get_option('plugin-pulse')) plugin_pulse_enabled = pulse.found() -plugin_dwl_enabled = get_option('plugin-dwl').allowed() +udev_removables = dependency('libudev', required: get_option('plugin-removables')) +plugin_removables_enabled = udev_removables.found() + +plugin_river_enabled = backend_wayland and get_option('plugin-river').allowed() + +plugin_script_enabled = get_option('plugin-script').allowed() + +json_sway_xkb = dependency('json-c', required: get_option('plugin-sway-xkb')) +plugin_sway_xkb_enabled = json_sway_xkb.found() + +xcb_xkb = dependency('xcb-xkb', required: get_option('plugin-xkb')) +plugin_xkb_enabled = backend_x11 and xcb_xkb.found() + +plugin_xwindow_enabled = backend_x11 and get_option('plugin-xwindow').allowed() # Module name -> (source-list, dep-list) -mod_data = { - 'alsa': [[], [m, alsa]], - 'backlight': [[], [m, udev]], - 'battery': [[], [udev]], - 'clock': [[], []], - 'cpu': [[], []], - 'disk-io': [[], [dynlist]], - 'mem': [[], []], - 'i3': [['i3-common.c', 'i3-common.h'], [dynlist, json]], - 'label': [[], []], - 'network': [[], []], - 'removables': [[], [dynlist, udev]], - 'script': [[], []], - 'sway-xkb': [['i3-common.c', 'i3-common.h'], [dynlist, json]], -} +mod_data = {} + +if plugin_alsa_enabled + mod_data += {'alsa': [[], [m, alsa]]} +endif + +if plugin_backlight_enabled + mod_data += {'backlight': [[], [m, udev_backlight]]} +endif + +if plugin_battery_enabled + mod_data += {'battery': [[], [udev_battery]]} +endif + +if plugin_clock_enabled + mod_data += {'clock': [[], []]} +endif + +if plugin_cpu_enabled + mod_data += {'cpu': [[], []]} +endif + +if plugin_disk_io_enabled + mod_data += {'disk-io': [[], [dynlist]]} +endif if plugin_dwl_enabled mod_data += {'dwl': [[], [dynlist]]} endif +if plugin_mem_enabled + mod_data += {'mem': [[], []]} +endif + if plugin_mpd_enabled mod_data += {'mpd': [[], [mpd]]} endif + +if plugin_i3_enabled + mod_data += {'i3': [['i3-common.c', 'i3-common.h'], [dynlist, json_i3]]} +endif + +if plugin_label_enabled + mod_data += {'label': [[], []]} +endif + +if plugin_network_enabled + mod_data += {'network': [[], []]} +endif + if plugin_pipewire_enabled - mod_data += {'pipewire': [[], [pipewire, dynlist, json]]} + mod_data += {'pipewire': [[], [pipewire, dynlist, json_pipewire]]} endif if plugin_pulse_enabled mod_data += {'pulse': [[], [pulse]]} endif -if backend_x11 - mod_data += { - 'xkb': [[], [xcb_stuff, xcb_xkb]], - 'xwindow': [[], [xcb_stuff]], - } +if plugin_removables_enabled + mod_data += {'removables': [[], [dynlist, udev_removables]]} endif -if backend_wayland +if plugin_script_enabled + mod_data += {'script': [[], []]} +endif + +if plugin_sway_xkb_enabled + mod_data += {'sway-xkb': [['i3-common.c', 'i3-common.h'], [dynlist, json_sway_xkb]]} +endif + +if plugin_xkb_enabled + mod_data += {'xkb': [[], [xcb_stuff, xcb_xkb]]} +endif + +if plugin_xwindow_enabled + mod_data += {'xwindow': [[], [xcb_stuff]]} +endif + +if plugin_river_enabled river_proto_headers = [] river_proto_src = [] @@ -76,10 +148,10 @@ if backend_wayland command: [wscanner_prog, 'private-code', '@INPUT@', '@OUTPUT@']) endforeach - mod_data += { - 'river': [[wl_proto_src + wl_proto_headers + river_proto_src + river_proto_headers], [dynlist, wayland_client]], - } + mod_data += {'river': [[wl_proto_src + wl_proto_headers + river_proto_src + river_proto_headers], [dynlist, wayland_client]]} +endif +if plugin_foreign_toplevel_enabled ftop_proto_headers = [] ftop_proto_src = [] @@ -98,9 +170,7 @@ if backend_wayland command: [wscanner_prog, 'private-code', '@INPUT@', '@OUTPUT@']) endforeach - mod_data += { - 'foreign-toplevel': [[wl_proto_src + wl_proto_headers + ftop_proto_headers + ftop_proto_src], [dynlist, wayland_client]], - } + mod_data += {'foreign-toplevel': [[wl_proto_src + wl_proto_headers + ftop_proto_headers + ftop_proto_src], [dynlist, wayland_client]]} endif foreach mod, data : mod_data diff --git a/plugin.c b/plugin.c index 6320434..ed7f63c 100644 --- a/plugin.c +++ b/plugin.c @@ -32,35 +32,69 @@ keychain_t *chain, const struct yml_node *node); \ extern struct deco *plug_name##_from_conf(const struct yml_node *node); -EXTERN_MODULE(alsa); -EXTERN_MODULE(backlight); -EXTERN_MODULE(battery); -EXTERN_MODULE(clock); -EXTERN_MODULE(disk_io); -#if defined(PLUGIN_ENABLED_DWL) -EXTERN_MODULE(dwl); +#if defined(HAVE_PLUGIN_alsa) + EXTERN_MODULE(alsa); #endif -EXTERN_MODULE(foreign_toplevel); -EXTERN_MODULE(i3); -EXTERN_MODULE(label); -#if defined(PLUGIN_ENABLED_MPD) -EXTERN_MODULE(mpd); +#if defined(HAVE_PLUGIN_backlight) + EXTERN_MODULE(backlight); #endif -EXTERN_MODULE(network); -#if defined(PLUGIN_ENABLED_PULSE) -EXTERN_MODULE(pulse); +#if defined(HAVE_PLUGIN_battery) + EXTERN_MODULE(battery); #endif -#if defined(PLUGIN_ENABLED_PIPEWIRE) -EXTERN_MODULE(pipewire); +#if defined(HAVE_PLUGIN_clock) + EXTERN_MODULE(clock); +#endif +#if defined(HAVE_PLUGIN_cpu) + EXTERN_MODULE(cpu); +#endif +#if defined(HAVE_PLUGIN_disk_io) + EXTERN_MODULE(disk_io); +#endif +#if defined(HAVE_PLUGIN_dwl) + EXTERN_MODULE(dwl); +#endif +#if defined(HAVE_PLUGIN_foreign_toplevel) + EXTERN_MODULE(foreign_toplevel); +#endif +#if defined(HAVE_PLUGIN_mem) + EXTERN_MODULE(mem); +#endif +#if defined(HAVE_PLUGIN_mpd) + EXTERN_MODULE(mpd); +#endif +#if defined(HAVE_PLUGIN_i3) + EXTERN_MODULE(i3); +#endif +#if defined(HAVE_PLUGIN_label) + EXTERN_MODULE(label); +#endif +#if defined(HAVE_PLUGIN_network) + EXTERN_MODULE(network); +#endif +#if defined(HAVE_PLUGIN_pipewire) + EXTERN_MODULE(pipewire); +#endif +#if defined(HAVE_PLUGIN_pulse) + EXTERN_MODULE(pulse); +#endif +#if defined(HAVE_PLUGIN_removables) + EXTERN_MODULE(removables); +#endif +#if defined(HAVE_PLUGIN_river) + EXTERN_MODULE(river); +#endif +#if defined(HAVE_PLUGIN_script) + EXTERN_MODULE(script); +#endif +#if defined(HAVE_PLUGIN_sway_xkb) + EXTERN_MODULE(sway_xkb); +#endif +#if defined(HAVE_PLUGIN_xkb) + EXTERN_MODULE(xkb); +#endif +#if defined(HAVE_PLUGIN_xwindow) + EXTERN_MODULE(xwindow); #endif -EXTERN_MODULE(removables); -EXTERN_MODULE(river); -EXTERN_MODULE(sway_xkb); -EXTERN_MODULE(script); -EXTERN_MODULE(xkb); -EXTERN_MODULE(xwindow); -EXTERN_MODULE(cpu); -EXTERN_MODULE(mem); EXTERN_PARTICLE(empty); EXTERN_PARTICLE(list); @@ -124,43 +158,69 @@ init(void) tll_back(plugins).decoration = &deco_##func_prefix##_iface; \ } while (0) +#if defined(HAVE_PLUGIN_alsa) REGISTER_CORE_MODULE(alsa, alsa); +#endif +#if defined(HAVE_PLUGIN_backlight) REGISTER_CORE_MODULE(backlight, backlight); +#endif +#if defined(HAVE_PLUGIN_battery) REGISTER_CORE_MODULE(battery, battery); +#endif +#if defined(HAVE_PLUGIN_clock) REGISTER_CORE_MODULE(clock, clock); +#endif +#if defined(HAVE_PLUGIN_cpu) + REGISTER_CORE_MODULE(cpu, cpu); +#endif +#if defined(HAVE_PLUGIN_disk_io) REGISTER_CORE_MODULE(disk-io, disk_io); -#if defined(PLUGIN_ENABLED_DWL) +#endif +#if defined(HAVE_PLUGIN_dwl) REGISTER_CORE_MODULE(dwl, dwl); #endif #if defined(HAVE_PLUGIN_foreign_toplevel) REGISTER_CORE_MODULE(foreign-toplevel, foreign_toplevel); #endif - REGISTER_CORE_MODULE(i3, i3); - REGISTER_CORE_MODULE(label, label); -#if defined(PLUGIN_ENABLED_MPD) +#if defined(HAVE_PLUGIN_mem) + REGISTER_CORE_MODULE(mem, mem); +#endif +#if defined(HAVE_PLUGIN_mpd) REGISTER_CORE_MODULE(mpd, mpd); #endif - REGISTER_CORE_MODULE(network, network); -#if defined(PLUGIN_ENABLED_PULSE) - REGISTER_CORE_MODULE(pulse, pulse); +#if defined(HAVE_PLUGIN_i3) + REGISTER_CORE_MODULE(i3, i3); #endif -#if defined(PLUGIN_ENABLED_PIPEWIRE) +#if defined(HAVE_PLUGIN_label) + REGISTER_CORE_MODULE(label, label); +#endif +#if defined(HAVE_PLUGIN_network) + REGISTER_CORE_MODULE(network, network); +#endif +#if defined(HAVE_PLUGIN_pipewire) REGISTER_CORE_MODULE(pipewire, pipewire); #endif +#if defined(HAVE_PLUGIN_pulse) + REGISTER_CORE_MODULE(pulse, pulse); +#endif +#if defined(HAVE_PLUGIN_removables) REGISTER_CORE_MODULE(removables, removables); +#endif #if defined(HAVE_PLUGIN_river) REGISTER_CORE_MODULE(river, river); #endif - REGISTER_CORE_MODULE(sway-xkb, sway_xkb); +#if defined(HAVE_PLUGIN_script) REGISTER_CORE_MODULE(script, script); +#endif +#if defined(HAVE_PLUGIN_sway_xkb) + REGISTER_CORE_MODULE(sway-xkb, sway_xkb); +#endif #if defined(HAVE_PLUGIN_xkb) REGISTER_CORE_MODULE(xkb, xkb); #endif #if defined(HAVE_PLUGIN_xwindow) REGISTER_CORE_MODULE(xwindow, xwindow); #endif - REGISTER_CORE_MODULE(mem, mem); - REGISTER_CORE_MODULE(cpu, cpu); REGISTER_CORE_PARTICLE(empty, empty); REGISTER_CORE_PARTICLE(list, list);