summaryrefslogtreecommitdiffstats
path: root/plugins/meson.build
blob: 16397dc63dc15e2232f638083716e9436685610b (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
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
all_plugins = [
    ['a11y-settings', 'A11ySettings', 'GNOME accessibility'],
    ['color', 'Color', 'GNOME color management'],
    ['datetime', 'Datetime', 'GNOME date & time'],
    ['power', 'Power', 'GNOME power management'],
    ['housekeeping', 'Housekeeping', 'GNOME maintenance of expirable data'],
    ['keyboard', 'Keyboard', 'GNOME keyboard configuration'],
    ['media-keys', 'MediaKeys', 'GNOME keyboard shortcuts'],
    ['screensaver-proxy', 'ScreensaverProxy', 'GNOME FreeDesktop screensaver'],
    ['sharing', 'Sharing', 'GNOME file sharing'],
    ['sound', 'Sound', 'GNOME sound sample caching'],
    ['usb-protection', 'UsbProtection', 'GNOME USB protection'],
    ['xsettings', 'XSettings', 'GNOME XSettings'],
    ['smartcard', 'Smartcard', 'GNOME smartcard'],
    ['wacom', 'Wacom', 'GNOME Wacom tablet support'],
    ['print-notifications', 'PrintNotifications', 'GNOME printer notifications'],
    ['rfkill', 'Rfkill', 'GNOME RFKill support'],
    ['wwan', 'Wwan', 'GNOME WWan support'],
]

disabled_plugins = []

if not enable_smartcard
    disabled_plugins += ['smartcard']
endif

if not enable_usb_protection
    disabled_plugins += ['usb-protection']
endif

if not enable_wacom
    disabled_plugins += ['wacom']
endif

if not enable_cups
    disabled_plugins += ['cups']
endif

if not enable_rfkill
    disabled_plugins += ['rfkill']
endif

if not enable_wwan
    disabled_plugins += ['wwan']
endif

if not enable_colord
  disabled_plugins += ['color']
endif

if not enable_cups
  disabled_plugins += ['print-notifications']
endif

# Specify futher required units, 'before' or 'after' may be specified if ordering is needed
plugin_gate_units = {
    'xsettings': [
      # Both after/before. after for stopping reliably, before for synchronisation
      ['gnome-session-x11-services.target', 'after'],
      ['gnome-session-x11-services-ready.target', 'before'],
    ],
#    'wacom': [['wacom.target']],
#    'smartcard': [['smartcard.target']],
}

plugins_conf = configuration_data()
plugins_conf.set('libexecdir', gsd_libexecdir)

plugins_deps = [libgsd_dep]

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

all_plugins_file = []

cflags = [
    '-DG_LOG_DOMAIN="common"'
] + plugins_cflags
plugin_name = 'common'
subdir('common')

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

    desktop = 'org.gnome.SettingsDaemon.@0@.desktop'.format(plugin[1])

    if disabled_plugins.contains(plugin_name)
        desktop_in_file = files('org.gnome.SettingsDaemon.Dummy.desktop.in')
    else
        desktop_in_file = files('org.gnome.SettingsDaemon.Real.desktop.in')
    endif

    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

    desktop = 'org.gnome.SettingsDaemon.@0@.desktop'.format(plugin[1])
    desktop_conf = configuration_data()
    desktop_conf.set('libexecdir', gsd_libexecdir)
    desktop_conf.set('systemd_hidden', enable_systemd ? 'true' : 'false')
    desktop_conf.set('pluginname', plugin_name)
    desktop_conf.set('description', plugin_description)
    configure_file(
        input: desktop_in_file,
        output: desktop,
        configuration: desktop_conf,
        install_dir: gsd_xdg_autostart
    )

    if not disabled_plugins.contains(plugin_name)
        user_target = 'org.gnome.SettingsDaemon.@0@.target'.format(plugin[1])
        user_service = 'org.gnome.SettingsDaemon.@0@.service'.format(plugin[1])

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

        gates_all = []
        gates_after = []
        gates_before = []
        foreach gate: plugin_gate_units.get(plugin_name, [])
            gates_all += [gate[0]]
            if gate.length() > 1
                if gate[1] == 'before'
                    gates_before += [gate[0]]
                elif gate[1] == 'after'
                    gates_after += [gate[0]]
                else
                    error('Ordering key must be either "before" or "after"')
                endif
            endif
        endforeach
        gate_unit_section = []
        if gates_all.length() > 0
            gate_unit_section += ['Requisite=' + ' '.join(gates_all)]
            gate_unit_section += ['PartOf=' + ' '.join(gates_all)]

            if gates_after.length() > 0
                gate_unit_section += ['After=' + ' '.join(gates_after)]
            endif
            if gates_before.length() > 0
                gate_unit_section += ['Before=' + ' '.join(gates_before)]
            endif
        endif
        unit_conf.set('plugin_gate_units_section', '\n'.join(gate_unit_section))

        if enable_systemd
            configure_file(
                input: 'gsd.service.in',
                output: user_service,
                configuration: unit_conf,
                install_dir: systemd_userunitdir
            )
            configure_file(
                input: 'gsd.target.in',
                output: user_target,
                configuration: unit_conf,
                install_dir: systemd_userunitdir
            )

            # Wipe out old target names if our prefix differes from the
            # systemd one, i.e. we are probably in a virtual environment and
            # may be picking up old units from a system installation.
            # This saves a lot of pain when running a new g-s-d inside
            # jhbuild on an old host.
            # TODO: Should be deleted once we can assume developers have 3.38
            #       installed on their machines.
            if gsd_prefix != systemd_dep.get_pkgconfig_variable('prefix')
                meson.add_install_script('sh', '-c', 'ln -vfs /dev/null "${DESTDIR:-}$1"', 'sh', systemd_userunitdir / 'gsd-@0@.target'.format(plugin_name))
            endif

            foreach target: gates_all
                meson.add_install_script('meson-add-wants.sh', systemd_userunitdir, target + '.wants/', user_service)
            endforeach
        endif

        subdir(plugin_name)
    endif
endforeach