project(
'c8-shell',
'c',
version: '0.1.0',
license: 'CC0-1.0',
meson_version: '>=1.3.0',
default_options: ['c_std=c11', 'warning_level=2', 'buildtype=debugoptimized', 'werror=false'],
)
add_project_arguments(
'-D_POSIX_C_SOURCE=200809L',
'-Wno-unused-parameter',
'-Wno-missing-field-initializers',
'-DC8_DATADIR="@0@"'.format(get_option('prefix') / get_option('datadir')),
language: 'c',
)
cc = meson.get_compiler('c')
c8ui = dependency('c8ui')
# json.h, clock.h, rfkill.h: the copy every program used to carry (c8ui's repo)
base = dependency('c8-base')
c8_protocols = dependency('c8-protocols')
wayland_client = dependency('wayland-client')
glib = dependency('glib-2.0')
gio = dependency('gio-2.0')
gio_unix = dependency('gio-unix-2.0')
pam = cc.find_library('pam', has_headers: ['security/pam_appl.h'],
required: get_option('lock'))
xkbcommon = dependency('xkbcommon')
wayland_protocols = dependency('wayland-protocols', version: '>=1.37')
gdk_pixbuf = dependency('gdk-pixbuf-2.0')
math = cc.find_library('m')
wayland_scanner = find_program(
dependency('wayland-scanner', native: true).get_variable('wayland_scanner'),
native: true,
)
protocols = [
c8_protocols.get_variable('pkgdatadir') / 'cont8nuum-shell-v1.xml',
]
lock_protocols = [
wayland_protocols.get_variable('pkgdatadir') /
'staging/ext-session-lock/ext-session-lock-v1.xml',
]
protos_src = []
lock_protos_src = []
askpass_protocols = [
c8_protocols.get_variable('pkgdatadir') / 'wlr-layer-shell-unstable-v1.xml',
# layer shell refers to xdg_popup
wayland_protocols.get_variable('pkgdatadir') / 'stable/xdg-shell/xdg-shell.xml',
]
askpass_protos_src = []
foreach xml : askpass_protocols
name = xml.split('/')[-1].replace('.xml', '')
askpass_protos_src += custom_target(
'askpass_' + name + '_client_h',
input: xml,
output: 'askpass-@BASENAME@-client-protocol.h',
command: [wayland_scanner, 'client-header', '@INPUT@', '@OUTPUT@'],
)
askpass_protos_src += custom_target(
'askpass_' + name + '_code',
input: xml,
output: 'askpass-@BASENAME@-protocol.c',
command: [wayland_scanner, 'private-code', '@INPUT@', '@OUTPUT@'],
)
endforeach
foreach xml : lock_protocols
name = xml.split('/')[-1].replace('.xml', '')
lock_protos_src += custom_target(
name + '_client_h',
input: xml,
output: '@BASENAME@-client-protocol.h',
command: [wayland_scanner, 'client-header', '@INPUT@', '@OUTPUT@'],
)
lock_protos_src += custom_target(
name + '_code',
input: xml,
output: '@BASENAME@-protocol.c',
command: [wayland_scanner, 'private-code', '@INPUT@', '@OUTPUT@'],
)
endforeach
foreach xml : protocols
name = xml.split('/')[-1].replace('.xml', '')
protos_src += custom_target(
name + '_client_h',
input: xml,
output: '@BASENAME@-client-protocol.h',
command: [wayland_scanner, 'client-header', '@INPUT@', '@OUTPUT@'],
)
protos_src += custom_target(
name + '_code',
input: xml,
output: '@BASENAME@-protocol.c',
command: [wayland_scanner, 'private-code', '@INPUT@', '@OUTPUT@'],
)
endforeach
# The live tile service's D-Bus interface, as introspection data
gdbus_codegen = find_program('gdbus-codegen')
tiles_xml = c8_protocols.get_variable('pkgdatadir') / 'org.cont8nuum.Tiles1.xml'
protos_src += custom_target(
'tiles_info_h',
input: tiles_xml,
output: 'tiles-info.h',
command: [gdbus_codegen, '--interface-info-header', '--output', '@OUTPUT@',
'@INPUT@'],
)
protos_src += custom_target(
'tiles_info_c',
input: tiles_xml,
output: 'tiles-info.c',
command: [gdbus_codegen, '--interface-info-body', '--output', '@OUTPUT@',
'@INPUT@'],
)
# The same for wake-ups
wake_xml = c8_protocols.get_variable('pkgdatadir') / 'org.cont8nuum.Wake1.xml'
protos_src += custom_target(
'wake_info_h',
input: wake_xml,
output: 'wake-info.h',
command: [gdbus_codegen, '--interface-info-header', '--output', '@OUTPUT@',
'@INPUT@'],
)
protos_src += custom_target(
'wake_info_c',
input: wake_xml,
output: 'wake-info.c',
command: [gdbus_codegen, '--interface-info-body', '--output', '@OUTPUT@',
'@INPUT@'],
)
# The login screen's copy of the lock picture: a root helper run by
# pkexec, and its polkit action (polkit reads only /usr/share, so only a
# /usr install has it; without, the shell doesn't ask)
login_picture = get_option('prefix') / get_option('libexecdir') / 'c8-login-picture'
login_picture_policy = '/usr/share/polkit-1/actions/org.cont8nuum.login-picture.policy'
executable(
'c8-login-picture',
files('src/login-picture.c'),
install: true,
install_dir: get_option('libexecdir'),
)
if get_option('login_picture') and get_option('prefix').startswith('/usr')
configure_file(
input: 'data/polkit/org.cont8nuum.login-picture.policy.in',
output: 'org.cont8nuum.login-picture.policy',
configuration: {'helper': login_picture},
install_dir: '/usr/share/polkit-1/actions',
)
endif
executable(
'c8-shell',
files('src/main.c', 'src/surface.c', 'src/start.c',
'src/panels.c', 'src/tiles.c', 'src/live.c', 'src/templates.c',
'src/apps.c', 'src/splash.c', 'src/media.c', 'src/notify.c',
'src/pattern.c', 'src/logind.c', 'src/status.c', 'src/drives.c',
'src/network.c',
'src/quick.c', 'src/profiles.c', 'src/tray.c', 'src/search.c', 'src/files.c', 'src/context.c',
'src/defaults.c', 'src/project.c', 'src/wake.c', 'src/loginpic.c'),
protos_src,
c_args: [
'-DLOGIN_PICTURE="' + login_picture + '"',
'-DLOGIN_PICTURE_POLICY="' + login_picture_policy + '"',
],
dependencies: [c8ui, base, wayland_client, glib, gio, gio_unix, gdk_pixbuf, math],
install: true,
)
# Asks for passwords for sudo -A, ssh and git, as Windows 8's UAC did
executable(
'c8-askpass',
files('src/askpass.c'),
askpass_protos_src,
dependencies: [c8ui, base, wayland_client, glib, gdk_pixbuf, xkbcommon, math],
install: true,
)
# Picks the screen or window an app shares, for xdg-desktop-portal-wlr
share_protos_src = []
foreach xml : ['staging/ext-foreign-toplevel-list/ext-foreign-toplevel-list-v1.xml',
'staging/ext-image-capture-source/ext-image-capture-source-v1.xml',
'staging/ext-image-copy-capture/ext-image-copy-capture-v1.xml']
path = wayland_protocols.get_variable('pkgdatadir') / xml
share_protos_src += custom_target(
'share_' + xml.split('/')[-1] + '_client_h',
input: path,
output: '@BASENAME@-client-protocol.h',
command: [wayland_scanner, 'client-header', '@INPUT@', '@OUTPUT@'],
)
share_protos_src += custom_target(
'share_' + xml.split('/')[-1] + '_code',
input: path,
output: '@BASENAME@-protocol.c',
command: [wayland_scanner, 'private-code', '@INPUT@', '@OUTPUT@'],
)
endforeach
executable(
'c8-share',
files('src/share.c'),
askpass_protos_src, share_protos_src,
dependencies: [c8ui, base, wayland_client, glib, gio, gio_unix, xkbcommon,
math],
install: true,
)
# The polkit agent: the same card when an app asks for admin rights
polkit_agent = dependency('polkit-agent-1', required: get_option('polkit'))
if polkit_agent.found()
executable(
'c8-polkit',
files('src/polkit.c'),
askpass_protos_src,
dependencies: [c8ui, base, wayland_client, glib, gio, gdk_pixbuf,
xkbcommon, polkit_agent, dependency('polkit-gobject-1'), math],
install: true,
install_dir: get_option('libexecdir'),
)
endif
# Opens the oo7 wallet for cont8nuum sessions (run by the session target)
oo7_daemon = get_option('oo7_daemon')
executable(
'c8-wallet',
files('src/wallet.c'),
c_args: ['-DC8_OO7_DAEMON="@0@"'.format(oo7_daemon)],
dependencies: [glib, gio, gio_unix],
install: true,
install_dir: get_option('libexecdir'),
)
configure_file(
input: 'data/wallet/cont8nuum-wallet.service.in',
output: 'cont8nuum-wallet.service',
configuration: {
'libexecdir': get_option('prefix') / get_option('libexecdir'),
'oo7_daemon': oo7_daemon,
},
install_dir: get_option('prefix') / 'lib' / 'systemd' / 'user',
)
# Copies what KWallet (or another Secret Service) holds into it
install_data('data/wallet/c8-wallet-import',
install_dir: get_option('bindir'),
install_mode: 'rwxr-xr-x')
# The askpass for the whole system, not just cont8nuum sessions (where c8
# sets it anyway). Like the PAM file, only for a real install.
if get_option('askpass_default') and get_option('prefix').startswith('/usr')
askpass_path = get_option('prefix') / get_option('bindir') / 'c8-askpass'
configure_file(
input: 'data/askpass/c8-askpass.sh.in',
output: 'c8-askpass.sh',
configuration: {'ASKPASS': askpass_path},
install_dir: '/etc/profile.d',
)
meson.add_install_script('data/askpass/sudo-askpass.sh', askpass_path)
endif
# The lock screen, started by c8 when the session locks
if not pam.found()
warning('No PAM headers (pam-devel): building without c8-lock')
subdir_done()
endif
executable(
'c8-lock',
files('src/lock.c', 'src/pattern.c', 'src/status.c'),
lock_protos_src,
dependencies: [c8ui, base, wayland_client, glib, gio, gdk_pixbuf, pam, xkbcommon,
math],
install: true,
)
# Opens the wallet with the login password: the PAM module keeps it,
# the keeper (as the user) gives it to c8-wallet once
keeper_path = get_option('prefix') / get_option('libexecdir') / 'c8-wallet-keeper'
executable(
'c8-wallet-keeper',
files('src/wallet-keeper.c'),
c_args: ['-DC8_WALLET="@0@"'.format(
get_option('prefix') / get_option('libexecdir') / 'c8-wallet')],
install: true,
install_dir: get_option('libexecdir'),
)
pam_module_dir = get_option('prefix') / get_option('libdir') / 'security'
shared_module(
'pam_c8wallet',
files('src/pam-wallet.c'),
name_prefix: '',
c_args: ['-DC8_WALLET_KEEPER="@0@"'.format(keeper_path)],
dependencies: [pam],
install: true,
install_dir: pam_module_dir,
)
# SDDM's and passwd's PAM files get the module (by full path, so it
# can stay in the prefix); only for a real install
if get_option('wallet_pam') and get_option('prefix').startswith('/usr')
meson.add_install_script('data/wallet/pam-c8wallet.sh',
pam_module_dir / 'pam_c8wallet.so')
endif
# PAM reads /etc/pam.d whatever the prefix; a build for running from the
# tree leaves it out, and c8-lock then uses the login service's rules
pam_dir = get_option('pam_dir')
if pam_dir == '' and get_option('prefix').startswith('/usr')
pam_dir = '/etc/pam.d'
endif
if pam_dir != ''
install_data('data/pam/c8-lock', install_dir: pam_dir)
endif