diff --git a/dbus/org.freedesktop.ratbag1.conf b/dbus/org.freedesktop.ratbag1.conf.in
similarity index 88%
rename from dbus/org.freedesktop.ratbag1.conf
rename to dbus/org.freedesktop.ratbag1.conf.in
index f4edc1e1..97229979 100644
--- a/dbus/org.freedesktop.ratbag1.conf
+++ b/dbus/org.freedesktop.ratbag1.conf.in
@@ -11,8 +11,7 @@
-
-
+
diff --git a/meson.build b/meson.build
index ec9fa3fe..588dbca2 100644
--- a/meson.build
+++ b/meson.build
@@ -467,8 +467,23 @@ configure_file(input : 'dbus/org.freedesktop.ratbag1.service.in',
output : 'org.freedesktop.ratbag1.service',
configuration : config_bindir,
install_dir : join_paths(dbusdir, 'system-services'))
-install_data('dbus/org.freedesktop.ratbag1.conf',
- install_dir : join_paths(dbusdir, 'system.d'))
+
+dbusgroup = get_option('dbus-group')
+if dbusgroup == ''
+ # grant everybody access by default
+ access = 'context="default"'
+else
+ # grant access to members of the specified group only
+ access = 'group="@0@"'.format(dbusgroup)
+endif
+
+config_dbusaccess = configuration_data()
+config_dbusaccess.set('access', access)
+
+configure_file(input : 'dbus/org.freedesktop.ratbag1.conf.in',
+ output : 'org.freedesktop.ratbag1.conf',
+ configuration : config_dbusaccess,
+ install_dir : join_paths(dbusdir, 'system.d'))
#### tools ####
diff --git a/meson_options.txt b/meson_options.txt
index f761ad8e..cd164b42 100644
--- a/meson_options.txt
+++ b/meson_options.txt
@@ -22,3 +22,8 @@ option('documentation',
type: 'boolean',
value: false,
description: 'Enable documentation build (default=no)')
+
+option('dbus-group',
+ type: 'string',
+ value : '',
+ description : 'The UNIX group that is granted access to the ratbagd D-Bus service. By default all users may access it.')