Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use keyboard configuration from Gnome Shell live #4976

Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Move get_missing_keyboard_configuration method
This method is not directly bound to localed and will be enhanced to
also take into account Live system configuration. So let's move it first.
  • Loading branch information
jkonecny12 committed Aug 9, 2023
commit b8d4dbff1089ccf0b2ec0f19a72e6a747b6465f6
2 changes: 1 addition & 1 deletion pyanaconda/modules/localization/installation.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
from pyanaconda.modules.common.errors.installation import LanguageInstallationError, \
KeyboardInstallationError
from pyanaconda.modules.common.task import Task
from pyanaconda.modules.localization.localed import get_missing_keyboard_configuration
from pyanaconda.modules.localization.utils import get_missing_keyboard_configuration

log = get_module_logger(__name__)

Expand Down
29 changes: 0 additions & 29 deletions pyanaconda/modules/localization/localed.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
from pyanaconda.core.configuration.anaconda import conf
from pyanaconda.keyboard import join_layout_variant, parse_layout_variant, \
InvalidLayoutVariantSpec
from pyanaconda.core.constants import DEFAULT_KEYBOARD

from pyanaconda.anaconda_loggers import get_module_logger
log = get_module_logger(__name__)
Expand Down Expand Up @@ -228,31 +227,3 @@ def convert_layouts(self, layouts_variants):
self.set_keymap(orig_keymap)

return ret


def get_missing_keyboard_configuration(localed_wrapper, x_layouts, vc_keymap):
"""Get missing keyboard settings by conversion and default values.

:param localed_wrapper: instance of systemd-localed service wrapper
:type localed_wrapper: LocaledWrapper
:param x_layouts: list of X layout specifications
:type x_layouts: list(str)
:param vc_keymap: virtual console keyboard mapping name
:type vc_keymap: str
:returns: tuple of X layouts and VC keyboard settings
:rtype: (list(str), str))
"""
if not vc_keymap and not x_layouts:
log.debug("Using default value %s for missing virtual console keymap.", DEFAULT_KEYBOARD)
vc_keymap = DEFAULT_KEYBOARD

if not vc_keymap:
vc_keymap = localed_wrapper.convert_layouts(x_layouts)
log.debug("Missing virtual console keymap value %s converted from %s X layouts",
vc_keymap, x_layouts)
if not x_layouts:
x_layouts = localed_wrapper.convert_keymap(vc_keymap)
log.debug("Missing X layouts value %s converted from %s virtual console keymap",
x_layouts, vc_keymap)

return x_layouts, vc_keymap
2 changes: 1 addition & 1 deletion pyanaconda/modules/localization/runtime.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
from pyanaconda.core.configuration.anaconda import conf
from pyanaconda.modules.common.errors.configuration import KeyboardConfigurationError
from pyanaconda.modules.common.task import Task
from pyanaconda.modules.localization.localed import get_missing_keyboard_configuration
from pyanaconda.modules.localization.utils import get_missing_keyboard_configuration
from pyanaconda.anaconda_loggers import get_module_logger
from pyanaconda.modules.localization.installation import write_vc_configuration

Expand Down
49 changes: 49 additions & 0 deletions pyanaconda/modules/localization/utils.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
#
# Copyright (C) 2023 Red Hat, Inc.
#
# This copyrighted material is made available to anyone wishing to use,
# modify, copy, or redistribute it subject to the terms and conditions of
# the GNU General Public License v.2, or (at your option) any later version.
# This program is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY expressed or implied, including the implied warranties of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
# Public License for more details. You should have received a copy of the
# GNU General Public License along with this program; if not, write to the
# Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
# 02110-1301, USA. Any Red Hat trademarks that are incorporated in the
# source code or documentation are not subject to the GNU General Public
# License and may only be used or replicated with the express permission of
# Red Hat, Inc.
#
from pyanaconda.core.constants import DEFAULT_KEYBOARD

from pyanaconda.anaconda_loggers import get_module_logger
log = get_module_logger(__name__)


def get_missing_keyboard_configuration(localed_wrapper, x_layouts, vc_keymap):
"""Get missing keyboard settings by conversion and default values.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is missing some context what we are trying to accomplish and how. Why is the keyboard configuration missing & how are we going to get se settings (conversion of what ? where do the default values come from ?).

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Honestly, the original code was so confusing because it was just about conversion but no word about defaults. I tried to improve the state but not that successful.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is greatly improved in the last commit change.


:param localed_wrapper: instance of systemd-localed service wrapper
:type localed_wrapper: LocaledWrapper
:param x_layouts: list of X layout specifications
:type x_layouts: list(str)
:param vc_keymap: virtual console keyboard mapping name
:type vc_keymap: str
:returns: tuple of X layouts and VC keyboard settings
:rtype: (list(str), str))
"""
if not vc_keymap and not x_layouts:
log.debug("Using default value %s for missing virtual console keymap", DEFAULT_KEYBOARD)
vc_keymap = DEFAULT_KEYBOARD

if not vc_keymap:
vc_keymap = localed_wrapper.convert_layouts(x_layouts)
log.debug("Missing virtual console keymap value %s converted from %s X layouts",
vc_keymap, x_layouts)
if not x_layouts:
x_layouts = localed_wrapper.convert_keymap(vc_keymap)
log.debug("Missing X layouts value %s converted from %s virtual console keymap",
x_layouts, vc_keymap)

return x_layouts, vc_keymap
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,11 @@
KeyboardInstallationTask, write_vc_configuration, VC_CONF_FILE_PATH, write_x_configuration, \
X_CONF_DIR, X_CONF_FILE_NAME
from pyanaconda.modules.localization.localization import LocalizationService
from pyanaconda.modules.localization.localed import get_missing_keyboard_configuration, \
LocaledWrapper
from pyanaconda.modules.localization.localed import LocaledWrapper
from pyanaconda.modules.localization.localization_interface import LocalizationInterface
from pyanaconda.modules.localization.runtime import GetMissingKeyboardConfigurationTask, \
ApplyKeyboardTask, AssignGenericKeyboardSettingTask, try_to_load_keymap
from pyanaconda.modules.localization.utils import get_missing_keyboard_configuration
from pyanaconda.modules.common.task import TaskInterface
from dasbus.typing import get_variant, Str, Bool

Expand Down