summaryrefslogtreecommitdiff
path: root/plugins/meson.build
blob: ce7d86f532721f01ecea1066e36db89e2d1f78ce (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
enabled_plugins = [
  ['a11y-settings', 'A11ySettings', ''],
  ['color', 'Color', ''],
  ['datetime', 'Datetime'],
  ['dummy', ''],
  ['power', 'Power'],
  ['housekeeping', 'Housekeeping'],
  ['keyboard', 'Keyboard'],
  ['media-keys', 'MediaKeys'],
  ['screensaver-proxy', 'ScreensaverProxy'],
  ['sharing', 'Sharing'],
  ['sound', 'Sound'],
  ['usb-protection', 'UsbProtection'],
  ['xsettings', 'XSettings']
]

if enable_smartcard
  enabled_plugins += [['smartcard', 'Smartcard']]
endif

if enable_wacom
  enabled_plugins += [['wacom', 'Wacom', 'wacom.target.wants/']]
endif

if enable_cups
  enabled_plugins += [['print-notifications', 'PrintNotifications']]
endif

if enable_rfkill
  enabled_plugins += [['rfkill', 'Rfkill']]
endif

if enable_wwan
  enabled_plugins += [['wwan', 'Wwan']]
endif

plugin_install_extra_wants = {
  'xsettings': ['gnome-session-x11-services.target.wants/'],
#  'dummy': ['required-started.target.wants/'],
#  'wacom': ['wacom.target.wants/'],
#  'smartcard': ['smartcard.target.wants/'],
}

plugins_conf = configuration_data()
plugins_conf.set('libexecdir', gsd_libexecdir)
plugins_conf.set('systemd_hidden', enable_systemd ? 'true' : 'false')

plugins_deps = [libgsd_dep]

plugins_cflags = ['-DGNOME_SETTINGS_LOCALEDIR="@0@"'.format(gsd_localedir)]

enabled_plugins_file = []

foreach plugin: [['common', '']] + enabled_plugins
  plugin_name = plugin[0]
  desktop = 'org.gnome.SettingsDaemon.@0@.desktop'.format(plugin[1])

  if plugin[1] == '' # common or dummy
    desktop_in_file = ''
  else
    desktop_in_file = files(join_paths(plugin_name, desktop + '.in'))
  endif

  enabled_plugins_file += [[plugin_name, plugin[1], desktop_in_file]]
endforeach

foreach plugin: enabled_plugins_file
  plugin_name = plugin[0]
  plugin_name_case = plugin[1]
  plugin_dbus_name='org.gnome.SettingsDaemon.@0@'.format(plugin_name_case)

  cflags = [
    '-DG_LOG_DOMAIN="@0@-plugin"'.format(plugin_name),
    '-DPLUGIN_NAME="@0@"'.format(plugin_name),
    '-DPLUGIN_DBUS_NAME="@0@"'.format(plugin_dbus_name),
  ] + plugins_cflags

  if not ['common', 'dummy'].contains(plugin_name)
    desktop = 'org.gnome.SettingsDaemon.@0@.desktop'.format(plugin[1])
    desktop_in_file = plugin[2]
    user_target = 'gsd-@0@.target'.format(plugin_name)
    user_service = 'gsd-@0@.service'.format(plugin_name)

    unit_conf = configuration_data()
    unit_conf.set('libexecdir', gsd_libexecdir)
    unit_conf.set('plugin_dbus_name', plugin_dbus_name)

    configure_file(
      input: desktop_in_file,
      output: desktop,
      configuration: plugins_conf,
      install: true,
      install_dir: gsd_xdg_autostart
    )
    if enable_systemd
      configure_file(
        input: join_paths(plugin_name, user_service + '.in'),
        output: user_service,
        configuration: unit_conf,
        install: true,
        install_dir: systemd_userunitdir
     )
      configure_file(
        input: join_paths(plugin_name, user_target + '.in'),
        output: user_target,
        configuration: unit_conf,
        install: true,
        install_dir: systemd_userunitdir
     )

     wants = []
     if plugin_name != 'xsettings'
       wants += ['gnome-session-initialized.target.wants/']
     endif

     if plugin_name in plugin_install_extra_wants
       wants += [plugin_install_extra_wants[plugin_name]]
     endif

     foreach target: wants
       meson.add_install_script('meson-add-wants.sh', systemd_userunitdir, target, user_target)
     endforeach
   endif
  endif

  subdir(plugin_name)
endforeach