mirror of
https://codeberg.org/dnkl/foot.git
synced 2026-04-27 06:46:44 -04:00
utmp: add suppport for FreeBSD
FreeBSD does not have utempter helper but instead have a ulog-helper which provides the same set of functionnality, but the call and arguments are slightly different.
This commit is contained in:
parent
c13495e26e
commit
aa2b29b1bd
4 changed files with 37 additions and 14 deletions
|
|
@ -344,8 +344,10 @@ empty string to be set, but it must be quoted: *KEY=""*)
|
|||
some cases, the number of physical _cores_ is better.
|
||||
|
||||
*utempter*
|
||||
Path to utempter helper binary. Set to *none* to disable utmp
|
||||
Path to _@utempter_name@_ helper binary. Set to *none* to disable utmp
|
||||
records. Default: _@utempter@_.
|
||||
Foot will execute the binary with _@utempter_add@_ when starting
|
||||
and with _@utempter_del@_ when exiting.
|
||||
|
||||
# SECTION: environment
|
||||
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ scdoc_prog = find_program(scdoc.get_variable('scdoc'), native: true)
|
|||
|
||||
if utempter_path == ''
|
||||
default_utempter_value = 'not set'
|
||||
utempter_name = 'none'
|
||||
else
|
||||
default_utempter_value = utempter_path
|
||||
endif
|
||||
|
|
@ -12,6 +13,9 @@ conf_data = configuration_data(
|
|||
{
|
||||
'default_terminfo': get_option('default-terminfo'),
|
||||
'utempter': default_utempter_value,
|
||||
'utempter_name': utempter_name,
|
||||
'utempter_add': utempter_add,
|
||||
'utempter_del': utempter_del,
|
||||
}
|
||||
)
|
||||
|
||||
|
|
|
|||
34
meson.build
34
meson.build
|
|
@ -18,28 +18,40 @@ 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()
|
||||
host_system = host_machine.system()
|
||||
if host_system == 'linux'
|
||||
utempter_path = join_paths(get_option('libdir'),'/utempter/utempter')
|
||||
utempter_add = 'add'
|
||||
utempter_name = 'utempter'
|
||||
utempter_del_arguments = true
|
||||
utempter_del = 'del'
|
||||
elif host_system == 'freebsd'
|
||||
utempter_path = '/usr/libexec/ulog-helper'
|
||||
utempter_name = 'ulog-helper'
|
||||
utempter_add = 'login'
|
||||
utempter_del_arguments = false
|
||||
utempter_del = 'logout'
|
||||
else
|
||||
utempter_path = ''
|
||||
utempter_add = ''
|
||||
utempter_del = ''
|
||||
utempter_del_arguments = false
|
||||
endif
|
||||
elif utempter_path == 'none'
|
||||
utempter_path = ''
|
||||
utempter_add = ''
|
||||
utempter_del = ''
|
||||
utempter_del_arguments = false
|
||||
endif
|
||||
|
||||
add_project_arguments(
|
||||
['-D_GNU_SOURCE=200809L',
|
||||
'-DFOOT_DEFAULT_TERM="@0@"'.format(get_option('default-terminfo')),
|
||||
'-DFOOT_UTEMPTER_ADD="@0@"'.format(utempter_add),
|
||||
'-DFOOT_UTEMPTER_DEL="@0@"'.format(utempter_del),
|
||||
'-DFOOT_DEFAULT_UTEMPTER_PATH="@0@"'.format(utempter_path)] +
|
||||
(utempter_del_arguments
|
||||
? [ '-DFOOT_UTEMPTER_DEL_ARGUMENTS' ] : []) +
|
||||
(is_debug_build
|
||||
? ['-D_DEBUG']
|
||||
: [cc.get_supported_arguments('-fno-asynchronous-unwind-tables')]) +
|
||||
|
|
|
|||
|
|
@ -212,19 +212,24 @@ add_utmp_record(const struct config *conf, struct reaper *reaper, int ptmx)
|
|||
if (conf->utempter_path == NULL)
|
||||
return true;
|
||||
|
||||
char *const argv[] = {conf->utempter_path, "add", getenv("WAYLAND_DISPLAY"), NULL};
|
||||
char *const argv[] = {conf->utempter_path, FOOT_UTEMPTER_ADD, getenv("WAYLAND_DISPLAY"), NULL};
|
||||
return spawn(reaper, NULL, argv, ptmx, ptmx, -1, NULL);
|
||||
|
||||
}
|
||||
|
||||
static bool
|
||||
del_utmp_record(const struct config *conf, struct reaper *reaper, int ptmx)
|
||||
{
|
||||
char *arg1 = NULL;
|
||||
if (ptmx < 0)
|
||||
return true;
|
||||
if (conf->utempter_path == NULL)
|
||||
return true;
|
||||
#ifdef FOOT_UTEMPTER_DEL_ARGUMENTS
|
||||
arg1 = getenv("WAYLAD_DISPLAY");
|
||||
#endif
|
||||
|
||||
char *const argv[] = {conf->utempter_path, "del", getenv("WAYLAND_DISPLAY"), NULL};
|
||||
char *const argv[] = {conf->utempter_path, FOOT_UTEMPTER_DEL, arg1, NULL};
|
||||
return spawn(reaper, NULL, argv, ptmx, ptmx, -1, NULL);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue