diff --git a/Makefile.am b/Makefile.am index 8f97c06..ede1f24 100644 --- a/Makefile.am +++ b/Makefile.am @@ -35,6 +35,7 @@ check_PROGRAMS = noinst_PROGRAMS = lib_LTLIBRARIES = noinst_LTLIBRARIES = +bin_SCRIPTS = moduledir = $(libdir)/kmscon module_LTLIBRARIES = @@ -475,6 +476,7 @@ mod_pixman_la_LDFLAGS = \ # built as part of kmscon. # +bin_SCRIPTS += docs/kmscon.sh bin_PROGRAMS += kmscon check_PROGRAMS += \ test_output \ diff --git a/docs/kmscon.service b/docs/kmscon.service index a3cc4ed..5d460f7 100644 --- a/docs/kmscon.service +++ b/docs/kmscon.service @@ -3,7 +3,7 @@ Description=KMS System Console Documentation=man:kmscon(1) [Service] -ExecStart=/usr/bin/kmscon -l /bin/login +ExecStart=/usr/bin/kmscon.sh -l /bin/login [Install] WantedBy=multi-user.target diff --git a/docs/kmscon.sh b/docs/kmscon.sh new file mode 100755 index 0000000..fcd672d --- /dev/null +++ b/docs/kmscon.sh @@ -0,0 +1,52 @@ +#!/bin/sh +# +# Copyright (c) 2018 Aetf +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in all +# copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. + +# Get a property from org.freedesktop.locale1 +queryLocale1() { + dbus-send --system --print-reply=literal --dest=org.freedesktop.locale1 /org/freedesktop/locale1 org.freedesktop.DBus.Properties.Get "string:org.freedesktop.locale1" "string:$1" | awk '{print $1}' +} + +# Query and setup system locale settings before start kmscon +setupLocale() { + # Fallback to do nothing if we don't have the command + if ! command -v dbus-send >/dev/null 2>/dev/null; then + return + fi + + # Don't override existing values. Also there is no point in setting only some of them + # as then they would not match anymore. + if test -n "${XKB_DEFAULT_MODEL}" -o -n "${XKB_DEFAULT_LAYOUT}" -o -n "${XKB_DEFAULT_VARIANT}" -o -n "${XKB_DEFAULT_OPTIONS}"; then + return + fi + + X11MODEL="$(queryLocale1 X11Model)" + X11LAYOUT="$(queryLocale1 X11Layout)" + X11VARIANT="$(queryLocale1 X11Variant)" + X11OPTIONS="$(queryLocale1 X11Options)" + [ -n "${X11MODEL}" ] && export XKB_DEFAULT_MODEL="${X11MODEL}" + [ -n "${X11LAYOUT}" ] && export XKB_DEFAULT_LAYOUT="${X11LAYOUT}" + [ -n "${X11VARIANT}" ] && export XKB_DEFAULT_VARIANT="${X11VARIANT}" + [ -n "${X11OPTIONS}" ] && export XKB_DEFAULT_OPTIONS="${X11OPTIONS}" +} + +setupLocale +exec kmscon "$@" diff --git a/docs/kmsconvt@.service b/docs/kmsconvt@.service index 7b64823..20907b4 100644 --- a/docs/kmsconvt@.service +++ b/docs/kmsconvt@.service @@ -37,7 +37,7 @@ IgnoreOnIsolate=yes ConditionPathExists=/dev/tty0 [Service] -ExecStart=/usr/bin/kmscon "--vt=%I" --seats=seat0 --no-switchvt +ExecStart=/usr/bin/kmscon.sh "--vt=%I" --seats=seat0 --no-switchvt UtmpIdentifier=%I TTYPath=/dev/%I TTYReset=yes