diff --git a/.gitignore b/.gitignore index 82328540a..19253ad28 100644 --- a/.gitignore +++ b/.gitignore @@ -9,6 +9,7 @@ core vgcore.* /docs/*.1 +/docs/dunst.1.pod /docs/*.5 /docs/internal/coverage /docs/internal/html diff --git a/Makefile b/Makefile index f0d4a6f8d..66b33f286 100644 --- a/Makefile +++ b/Makefile @@ -132,8 +132,10 @@ doc: docs/dunst.1 docs/dunst.5 docs/dunstctl.1 # Can't dedup this as we need to explicitly provide the name and title text to # pod2man :( +docs/dunst.1.pod: docs/dunst.1.pod.in + ${SED} "s|@sysconfdir@|${SYSCONFDIR}|" $< > $@ docs/dunst.1: docs/dunst.1.pod - ${SED} "s|##SYSCONFDIR##|${SYSCONFDIR}|" $< | ${POD2MAN} --name=dunst -c "Dunst Reference" --section=1 --release=${VERSION} > $@ + ${POD2MAN} --name=dunst -c "Dunst Reference" --section=1 --release=${VERSION} $< > $@ docs/dunst.5: docs/dunst.5.pod ${POD2MAN} --name=dunst -c "Dunst Reference" --section=5 --release=${VERSION} $< > $@ docs/dunstctl.1: docs/dunstctl.pod @@ -145,11 +147,11 @@ doc-doxygen: .PHONY: service service-dbus service-systemd wayland-protocols service: service-dbus service-dbus: - @${SED} "s|##PREFIX##|$(PREFIX)|" org.knopwob.dunst.service.in > org.knopwob.dunst.service + @${SED} "s|@bindir@|$(BINDIR)|" org.knopwob.dunst.service.in > org.knopwob.dunst.service ifneq (0,${SYSTEMD}) service: service-systemd service-systemd: - @${SED} "s|##PREFIX##|$(PREFIX)|" dunst.systemd.service.in > dunst.systemd.service + @${SED} "s|@bindir@|$(BINDIR)|" dunst.systemd.service.in > dunst.systemd.service endif ifneq (0,${WAYLAND}) diff --git a/docs/dunst.1.pod b/docs/dunst.1.pod.in similarity index 97% rename from docs/dunst.1.pod rename to docs/dunst.1.pod.in index 58038eebd..fb857cb2c 100644 --- a/docs/dunst.1.pod +++ b/docs/dunst.1.pod.in @@ -59,7 +59,7 @@ Display a notification on startup. =head1 CONFIGURATION -A default configuration file is included (usually ##SYSCONFDIR##/dunst/dunstrc) +A default configuration file is included (usually @sysconfdir@/dunst/dunstrc) and serves as the least important configuration file. Note: this was previously /usr/share/dunst/dunstrc. You can edit this file to change the system-wide defaults or copy it to a more important location to override its settings. See @@ -112,7 +112,7 @@ This is the most important directory. (C<$HOME/.config> if unset or empty) This, like C<$PATH> for instance, is a :-separated list of base directories in I. -(F<##SYSCONFDIR##> if unset or empty) +(F<@sysconfdir@> if unset or empty) =back diff --git a/docs/meson.build b/docs/meson.build new file mode 100644 index 000000000..62f6a68a4 --- /dev/null +++ b/docs/meson.build @@ -0,0 +1,60 @@ +man1 = get_option('mandir') / 'man1' +man5 = get_option('mandir') / 'man5' +pod2man_version_arg = '--release=@0@'.format(meson.project_version()) + +dunst1 = configure_file( + input: 'dunst.1.pod.in', + output: 'dunst.1.pod', + configuration: conf_data, +) + +custom_target( + 'dunst1_pod2man', + input: dunst1, + output: 'dunst.1', + command: [ + pod2man, + '--name=dunst', + '--center=Dunst Reference', + '--section=1', + pod2man_version_arg, + '@INPUT@', + '@OUTPUT@', + ], + install: true, + install_dir: man1, +) + +custom_target( + 'dunst5_pod2man', + input: 'dunst.5.pod', + output: 'dunst.5', + command: [ + pod2man, + '--name=dunst', + '--center=Dunst Reference', + '--section=5', + pod2man_version_arg, + '@INPUT@', + '@OUTPUT@', + ], + install: true, + install_dir: man5, +) + +custom_target( + 'dunstctl_pod2man', + input: 'dunstctl.pod', + output: 'dunstctl.1', + command: [ + pod2man, + '--name=dunst', + '--center=dunstctl Reference', + '--section=1', + pod2man_version_arg, + '@INPUT@', + '@OUTPUT@', + ], + install: true, + install_dir: man1, +) diff --git a/dunst.systemd.service.in b/dunst.systemd.service.in index 9fa168ca9..4e566d50c 100644 --- a/dunst.systemd.service.in +++ b/dunst.systemd.service.in @@ -6,4 +6,4 @@ PartOf=graphical-session.target [Service] Type=dbus BusName=org.freedesktop.Notifications -ExecStart=##PREFIX##/bin/dunst +ExecStart=@bindir@/dunst diff --git a/meson.build b/meson.build new file mode 100644 index 000000000..404f995b1 --- /dev/null +++ b/meson.build @@ -0,0 +1,109 @@ +project( + 'dunst', + 'c', + version: '1.9.2', + license: 'MIT', + meson_version: '>=0.60.0', + default_options: [ + 'c_std=gnu99', + 'warning_level=1', + 'b_ndebug=if-release', + ], +) + +add_project_arguments([ + '-Wno-maybe-uninitialized', +], language: 'c') + +if get_option('buildtype').startswith('debug') + add_project_arguments('-DDEBUG_BUILD', language: 'c') +endif + +cc = meson.get_compiler('c') + +cairo = dependency('cairo') +glib = dependency('glib-2.0') +gio = dependency('gio-2.0') +gdk_pixbuf = dependency('gdk-pixbuf-2.0') +pangocairo = dependency('pangocairo') +x11 = dependency('x11', required: get_option('x11')) +xinerama = dependency('xinerama', required: get_option('x11')) +xext = dependency('xext', required: get_option('x11')) +xrandr = dependency('xrandr', required: get_option('x11'), version: '>=1.5') +xscrnsaver = dependency('xscrnsaver', required: get_option('x11')) +systemd = dependency('systemd', required: get_option('systemd')) +libnotify = dependency('libnotify', required: get_option('dunstify')) +realtime = cc.find_library('rt') +math = cc.find_library('m') +wayland_client = dependency('wayland-client', required: get_option('wayland')) +wayland_protos = dependency('wayland-protocols', version: '>=1.12', required: get_option('wayland')) +wayland_cursor = dependency('wayland-cursor', required: get_option('wayland')) + +x11_support = x11.found() and xinerama.found() and xext.found() and xrandr.found() and xscrnsaver.found() +wayland_support = wayland_client.found() and wayland_cursor.found() and wayland_protos.found() + +if not x11_support and not wayland_support + error('either wayland or x11 support is required') +endif + +if wayland_support and not x11_support + add_project_arguments('-DWAYLAND_ONLY', language: 'c') +endif + +c_version_arg = '-DVERSION="@0@"'.format(meson.project_version()) +sysconfdir = get_option('sysconfdir') / 'xdg' + +add_project_arguments( + '-DSYSCONFDIR="@0@"'.format(get_option('prefix') / sysconfdir), + language: 'c' +) + +subdir('src') + +install_data('dunstctl', install_dir: get_option('bindir')) +install_data('dunstrc', install_dir: sysconfdir / 'dunst') + +conf_data = configuration_data() +conf_data.set('bindir', get_option('bindir')) +conf_data.set('sysconfdir', sysconfdir) + +configure_file( + input: 'org.knopwob.dunst.service.in', + output: 'dunst.service', + configuration: conf_data, + install_dir: get_option('datadir') / 'dbus-1/services', +) + +if systemd.found() + user_units_dir = systemd.get_variable(pkgconfig: 'systemduserunitdir') + configure_file( + configuration: conf_data, + input: 'dunst.systemd.service.in', + output: '@BASENAME@', + install_dir: user_units_dir, + ) +endif + +if libnotify.found() + executable( + 'dunstify', + 'dunstify.c', + dependencies: [ glib, libnotify, gdk_pixbuf ], + install: true, + ) +endif + +subdir('test') + +pod2man = find_program('pod2man', native: true, required: get_option('docs')) +if pod2man.found() + subdir('docs') +endif + +summary({ + 'X11 support': x11_support, + 'Wayland support': wayland_support, + 'Man pages': pod2man.found(), + 'Dunstify': libnotify.found(), + 'Install systemd service units': systemd.found(), +}, bool_yn: true) diff --git a/meson_options.txt b/meson_options.txt new file mode 100644 index 000000000..80d272386 --- /dev/null +++ b/meson_options.txt @@ -0,0 +1,5 @@ +option('docs', type: 'feature', value: 'auto', description: 'Generate and install man pages') +option('wayland', type: 'feature', value: 'auto', description: 'Enable wayland support') +option('x11', type: 'feature', value: 'auto', description: 'Enable X11 support') +option('dunstify', type: 'feature', value: 'auto', description: 'Install libnotify dunstify utility') +option('systemd', type: 'feature', value: 'auto', description: 'Install systemd user service unit') diff --git a/org.knopwob.dunst.service.in b/org.knopwob.dunst.service.in index a8e8ac17b..9c3b6beef 100644 --- a/org.knopwob.dunst.service.in +++ b/org.knopwob.dunst.service.in @@ -1,4 +1,4 @@ [D-BUS Service] Name=org.freedesktop.Notifications -Exec=##PREFIX##/bin/dunst +Exec=@bindir@/dunst SystemdService=dunst.service diff --git a/src/meson.build b/src/meson.build new file mode 100644 index 000000000..c833bb6ea --- /dev/null +++ b/src/meson.build @@ -0,0 +1,74 @@ +dunst_depends = [ + cairo, + glib, + gio, + gdk_pixbuf, + pangocairo, + systemd, + libnotify, + realtime, + math, +] + +dunst_src_files = files( + 'dbus.c', + 'draw.c', + 'dunst.c', + 'icon-lookup.c', + 'icon.c', + 'ini.c', + 'input.c', + 'log.c', + 'markup.c', + 'menu.c', + 'notification.c', + 'option_parser.c', + 'output.c', + 'queues.c', + 'rules.c', + 'settings.c', + 'utils.c', +) + +if x11_support + add_global_arguments('-DENABLE_X11', language: 'c') + + dunst_depends += [ + x11, + xinerama, + xext, + xrandr, + xscrnsaver, + ] + dunst_src_files += files( + 'x11/screen.c', + 'x11/x.c', + ) +endif + +if wayland_support + add_global_arguments('-DENABLE_WAYLAND', language: 'c') + + subdir('wayland/protocols') + + dunst_depends += [ + wayland_client, wayland_cursor, + ] + dunst_src_files += files( + 'wayland/foreign_toplevel.c', + 'wayland/libgwater-wayland.c', + 'wayland/pool-buffer.c', + 'wayland/wl.c', + 'wayland/wl_output.c', + 'wayland/wl_seat.c', + ) +endif + +executable( + 'dunst', + '../main.c', + dunst_src_files, + dependencies: dunst_depends, + c_args: c_version_arg, + install: true, +) diff --git a/src/wayland/protocols/meson.build b/src/wayland/protocols/meson.build new file mode 100644 index 000000000..62f4c63b8 --- /dev/null +++ b/src/wayland/protocols/meson.build @@ -0,0 +1,29 @@ +wl_protocol_dir = wayland_protos.get_variable(pkgconfig: 'pkgdatadir') + +wayland_scanner = dependency('wayland-scanner', version: '>=1.14.91', native: true) +wayland_scanner_path = wayland_scanner.get_variable(pkgconfig: 'wayland_scanner') +wayland_scanner_prog = find_program(wayland_scanner_path, native: true) + +wayland_scanner_code = generator( + wayland_scanner_prog, + output: '@BASENAME@.h', + arguments: ['private-code', '@INPUT@', '@OUTPUT@'], +) + +wayland_scanner_client = generator( + wayland_scanner_prog, + output: '@BASENAME@-client-header.h', + arguments: ['client-header', '@INPUT@', '@OUTPUT@'], +) + +client_protocols = [ + wl_protocol_dir / 'stable/xdg-shell/xdg-shell.xml', + 'wlr-layer-shell-unstable-v1.xml', + 'idle.xml', + 'wlr-foreign-toplevel-management-unstable-v1.xml', +] + +foreach p : client_protocols + wayland_scanner_code.process(p) + wayland_scanner_client.process(p) +endforeach diff --git a/test/meson.build b/test/meson.build new file mode 100644 index 000000000..4a96c91f8 --- /dev/null +++ b/test/meson.build @@ -0,0 +1,41 @@ +test_src_files = [ + 'dbus.c', + 'draw.c', + 'dunst.c', + 'helpers.c', + 'icon-lookup.c', + 'icon.c', + 'ini.c', + 'input.c', + 'log.c', + 'markup.c', + 'menu.c', + 'misc.c', + 'notification.c', + 'option_parser.c', + 'queues.c', + 'rules.c', + 'setting.c', + 'settings_data.c', + 'test.c', + 'utils.c', +] + +fs = import('fs') +foreach dunst_src_file : dunst_src_files + if fs.name(dunst_src_file) not in test_src_files + test_src_files += dunst_src_file + endif +endforeach + +test_prog = executable('test-runner', + test_src_files, + dependencies: dunst_depends, + c_args: c_version_arg, + install: false, +) + +test('Run tests', + test_prog, + args: meson.current_source_dir(), +)