We want to avoid any static files that are shared between multiple
programs but are not part of SHL. These make the build-process just more
complex.
Move log.[ch] to SHL so we have a known context.
Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
Afterchecks should be always performed when reading data into a config
context. So perform them after copy operations, too.
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
We can now check keysym names on case-insensitive basis. We can use this
to try to give hints to the user what they probably meant when mistyping a
keysym name.
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
The xkbcommon API was changed for 0.2.0 release. But now it should be
stable so we hopefully fixed it for the last time.
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
We need to call afterchecks after any parsing we do. To signal that there
are no extra-arguments, we pass argv==NULL.
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
The "file" callback is used to parse configuration files. If it is not
given, the string is parsed via "parse".
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
We allow options to specify "aftercheck" callbacks but do not call them
during a copy. Therefore, we need a way to copy side-effects. As we cannot
do that generically, we now allow each option to specify such a callback.
We use it for the "all_seats" and "argv" parameters in kmscon.
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
If we copy entries into another context, we must not overwrite locked
entries. Furthermore, if we copy a locked entry, we must also copy that
lock.
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
Sorry for the huge commit, but this reworks the whole configuration
handler. We now provide conf_ctx contexts which contain a pointer to the
backing storage and the config-options that are used.
It is also possible to copy config-options now. So we can use the
main-config as default value for seat-configurations.
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
This drops all config-file support except for the new
/etc/kmscon/kmscon.conf. For backwards-compatibility, we still parse
/etc/kmscon.conf but this will be removed soon.
We want to add one kmscon-config for each seat so you can have different
configurations per seat. These will all be put into /etc/kmscon/ so we
need this directory.
We also drop ~/.kmscon.conf. This was never really useful as kmscon is a
system daemon and should not be used with user-configuration files.
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
This new helper allows easily parsing arbitrary filenames. It does the
same as conf_parse_file() but allows giving filenames in printf format.
The other parsers are slightly adjusted so they can be more easily reused
by other projects.
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
We allow users to specify grabs on the command-line or in config-options.
We sometimes want multiple grabs to do the same. Therefore, this changes
the grab-parser and handlers to allow this.
Furthermore, this adds support for keysyms that are assembled of multiple
syms. This isn't needed by any keymap, yet, but might be used in the
future.
Last but not least, you can also specify modifiers only now. This might be
used by subsystems to use the default keysyms but let the user specify
what modifiers should be used.
However, be careful when specifying modifiers-only for normal grabs as
this means the grab is executed everytime the modifier is reported with
_any_ key.
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
We really need to clean this up and allow parsing of grabs in conf.c
again. xkbcommon is now mandatory so we can fix all the input layers to
use it.
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
When enabling the printf() logic for the logging subsystem, several
warnings were produced about missing or wrong specifiers. This fixes all
those occurrences.
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
This is very similar to the UINT datatype but allows signed values. This
will be required for the coming --vt option as default value.
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
We move the GRAB type into kmscon-main.c to avoid any uterm dependency in
the conf subsystem. It is still open how we can better handle the
key-parser without a valid uterm_input object, but when there will be a
xkbcommon release, we can hopefully add a hard depedency to it.
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
Grabs are used to specify keyboard shortcuts so they do not have to be
hardcoded into the binary.
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
The string-list type parses an argument as a list of strings separated
with commas. Empty arguments are accepted and correctly parsed.
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
The main configuration is now limited to kmscon and thus should not use
the conf_* prefix. Move all code to use the new name and introduce the new
main.h header mainly for kmscon.
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
This replaces the global conf-options array with a parameter so we can use
the config parsers with different argument-lists.
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
In order to make the conf subsystem more open we need to make all
important symbols visible so others can include them.
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
The aftercheck logic allows each argument to make adjustments after the
argument-list has been parsed. It is also used to consume remaining
arguments.
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
It is not acceptable to start the applications with wrong parameters. A
typo must be corrected before starting the application so simply fail
loudly on errors.
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
Whether an option takes an argument or not is definitely a property of the
type and not of the option. Therefore, move the flag to the type structure
and remove it from the option structure.
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
This abstracts the type system of the config parser so other types can be
added without changing the parser itself. This will also be required to
make the conf-subsystem exportable to other users.
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
This is part of an effort to make the conf-subsystem more friendly for
external users like the tests/* binaries.
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
We must not assume that the string is longer than 0 characters. Therefore,
check whether we would access invalid memory before the string when
removing trailing whitespaces.
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
This again refactors the whole config subsystem but this should be the
last time. We now have generic parsers for booleans and strings and don't
leak any memory, anymore. Furthermore, this adds a config-file parser so
common options can now be placed into /etc/kmscon.conf or ~/.kmscon.conf.
The config files parse the same arguments as the command-line and the
command-line always has precedence even though it is parsed first.
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
We want to be able to parse our argument-list from other sources, too, so
put them into a separate array so we are not dependent of getopt() and
others.
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
The new --fbdev option allows runtime switching between the two backends.
That is, we only use fbdev devices when --fbdev is given. Otherwise, DRM
is used.
Technically, it would also be possible to use both. However, almost every
DRM device does also register an fbdev device for backwards compatibility.
Therefore, we must avoid using both, the DRM and fbdev device of the same
display at the same time. As this would also mean dealing with failures in
one backend and then switching to the other, we avoid this for complexity
reasons. Who needs fbdev and drm simultaneously, anyway?
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
The --seat parameter specifies which seat is used for drm and input
devices. Default is seat0.
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
I don't know the reason but negative values don't work here. We simply use
big integers now to avoid clashes with valid getopt() values.
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
We assigned stack-storage to a global pointer and therefore we got
seg-faults when using the default. Fix that.
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
Allow to specify a separate login-program that is executed instead of the
default. All arguments specified after --login are considered argv[] of
the new process and not parsed by the library.
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
Suppress debug, info, notice and warning messages if --silent is given.
This is overwritten by --debug and --verbose.
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
--switchvt enables kmscon to automatically switch to the new VT that was
opened by kmscon. If this is the current VT, then this has obviously no
effect.
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
The conf-subsystem is used throughout the whole source and provides a
global static read-only configuration. The configuration is read on
startup from the command-line and filesystem and then provided to the
other subsystems.
This is no database, that is, the data is not written to a file on
shutdown!
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>