Skip to content

Commit

Permalink
Merge pull request #315 from yast/kbd-model-map-2
Browse files Browse the repository at this point in the history
use also kbd-model-map.xkb-generated (bsc#1211104)
  • Loading branch information
mvidner committed Oct 11, 2023
2 parents b6e437d + 3934c15 commit fcbc7fd
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 4 deletions.
1 change: 1 addition & 0 deletions keyboard/src/lib/y2keyboard/dialogs/layout_selector.rb
Expand Up @@ -36,6 +36,7 @@ class LayoutSelector < UI::Dialog
def initialize
textdomain "country"
@keyboard_layouts = KeyboardLayout.all
@keyboard_layouts.sort! { |a, b| Yast.strcoll(a.description, b.description) }
@previous_selected_layout = KeyboardLayout.current_layout
end

Expand Down
16 changes: 14 additions & 2 deletions keyboard/src/lib/y2keyboard/keyboards.rb
Expand Up @@ -334,6 +334,19 @@ def self.always_present_keyboards
]
end

# @return [Array<String>]
def self.kbd_model_map_lines
filenames = [
"/usr/share/systemd/kbd-model-map",
# https://bugzilla.suse.com/show_bug.cgi?id=1211104
"/usr/share/systemd/kbd-model-map.xkb-generated"
]
lines = filenames.map do |fn|
File.exist?(fn) ? File.readlines(fn) : []
end.flatten
lines
end

# Some keyboards are present in new openSUSE releases but not in older SLE
# @see all_keyboards
def self.optional_keyboards
Expand All @@ -345,8 +358,7 @@ def self.optional_keyboards
# The afnor layout was added to xkeyboard-config in 2019-06
# but SLE15-SP4 only has 2.23 released in 2018
afnor_test = lambda do
kmm = File.read("/usr/share/systemd/kbd-model-map") rescue ""
kmm.match?("^fr-afnor")
kbd_model_map_lines.any?(/^fr-afnor/)
end
afnor = {
"description" => _("French (AFNOR)"),
Expand Down
2 changes: 1 addition & 1 deletion keyboard/test/keyboards_spec.rb
Expand Up @@ -20,7 +20,7 @@

it "returns a list with all valid models from systemd" do
# read valid codes from systemd as xkbctrl read it from there
valid_codes = File.readlines("/usr/share/systemd/kbd-model-map")
valid_codes = Keyboards.kbd_model_map_lines
valid_codes.map! { |l| l.strip.sub(/^(\S+)\s+.*$/, "\\1") }
Keyboards.all_keyboards.each do |kb_map|
code = kb_map["code"]
Expand Down
7 changes: 7 additions & 0 deletions package/yast2-country.changes
@@ -1,3 +1,10 @@
-------------------------------------------------------------------
Tue Oct 10 09:38:22 UTC 2023 - Martin Vidner <mvidner@suse.com>

- use also kbd-model-map.xkb-generated (bsc#1211104)
- sort the selection box of keyboard layouts alphabetically
- 5.0.1

-------------------------------------------------------------------
Wed Aug 30 20:16:10 UTC 2023 - Josef Reidinger <jreidinger@suse.cz>

Expand Down
2 changes: 1 addition & 1 deletion package/yast2-country.spec
Expand Up @@ -16,7 +16,7 @@
#

Name: yast2-country
Version: 5.0.0
Version: 5.0.1
Release: 0
Summary: YaST2 - Country Settings (Language, Keyboard, and Timezone)
License: GPL-2.0-only
Expand Down

0 comments on commit fcbc7fd

Please sign in to comment.