Add support for creating utmp records

This patch adds support for creating utmp records using the ‘utempter’
helper binary from the ‘libutempter’ package.

* New config option ‘main.utempter’
* New meson command line option, -Ddefault-utempter-path. Defaults to
  auto-detecting the path.

The default value of the new ‘main.utempter’ config option depends on
the meson command line option ‘-Ddefault-utempter-path’.

If ‘main.utempter’ is *not* set to ‘none’, foot will try to execute
the utempter helper binary to create utmp records when a new terminal
is instantiated. The record is removed when the terminal instance is
destroyed.
This commit is contained in:
Daniel Eklöf 2022-09-23 20:24:04 +02:00
parent 77b74734a4
commit aa10b1d2da
No known key found for this signature in database
GPG key ID: 5BBD4992C116573F
11 changed files with 105 additions and 11 deletions

View file

@ -16,9 +16,30 @@ if cc.has_function('memfd_create')
add_project_arguments('-DMEMFD_CREATE', language: 'c')
endif
utempter_path = get_option('default-utempter-path')
if utempter_path == ''
utempter = find_program(
'utempter',
required: false,
dirs: [join_paths(get_option('prefix'), get_option('libdir'), 'utempter'),
join_paths(get_option('prefix'), get_option('libexecdir'), 'utempter'),
'/usr/lib/utempter',
'/usr/libexec/utempter',
'/lib/utempter']
)
if utempter.found()
utempter_path = utempter.full_path()
else
utempter_path = ''
endif
elif utempter_path == 'none'
utempter_path = ''
endif
add_project_arguments(
['-D_GNU_SOURCE=200809L',
'-DFOOT_DEFAULT_TERM="@0@"'.format(get_option('default-terminfo'))] +
'-DFOOT_DEFAULT_TERM="@0@"'.format(get_option('default-terminfo')),
'-DFOOT_DEFAULT_UTEMPTER_PATH="@0@"'.format(utempter_path)] +
(is_debug_build
? ['-D_DEBUG']
: [cc.get_supported_arguments('-fno-asynchronous-unwind-tables')]) +
@ -321,6 +342,7 @@ summary(
'Themes': get_option('themes'),
'IME': get_option('ime'),
'Grapheme clustering': utf8proc.found(),
'Utempter path': utempter_path,
'Build terminfo': tic.found(),
'Terminfo install location': terminfo_install_location,
'Default TERM': get_option('default-terminfo'),