Skip to content

Commit

Permalink
Merge pull request #7 from Aetf/feature/locale
Browse files Browse the repository at this point in the history
Feature/locale
  • Loading branch information
Aetf authored Jul 25, 2018
2 parents a861a03 + 015997e commit 3f8b688
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 2 deletions.
5 changes: 4 additions & 1 deletion Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,12 @@ MANPAGES_ALIASES =
TPHONY =

bin_PROGRAMS =
libexec_PROGRAMS =
check_PROGRAMS =
noinst_PROGRAMS =
lib_LTLIBRARIES =
noinst_LTLIBRARIES =
bin_SCRIPTS =

moduledir = $(libdir)/kmscon
module_LTLIBRARIES =
Expand Down Expand Up @@ -475,7 +477,8 @@ mod_pixman_la_LDFLAGS = \
# built as part of kmscon.
#

bin_PROGRAMS += kmscon
bin_SCRIPTS += scripts/kmscon
libexec_PROGRAMS += kmscon
check_PROGRAMS += \
test_output \
test_vt \
Expand Down
2 changes: 1 addition & 1 deletion configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -791,7 +791,7 @@ fi
# makefiles.
#

AC_CONFIG_FILES([Makefile])
AC_CONFIG_FILES([Makefile scripts/kmscon])
AC_OUTPUT

#
Expand Down
58 changes: 58 additions & 0 deletions scripts/kmscon.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
#!/bin/sh
#
# Copyright (c) 2018 Aetf <aetf@unlimitedcodeworks.xyz>
# Copyright (c) 2018 Fabian Vogt <fvogt@suse.com>
#
# 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.

# configuration path
prefix=@prefix@
exec_prefix=@exec_prefix@
libexecdir=@libexecdir@

# 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 $2}'
}

# 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 ${libexecdir}/kmscon "$@"

0 comments on commit 3f8b688

Please sign in to comment.