Skip to content

Commit 54f5388

Browse files
committed
Merge remote-tracking branch 'ArrayBolt3/arraybolt3/trixie'
2 parents 7d5fff8 + 74cf4ae commit 54f5388

File tree

3 files changed

+111
-0
lines changed

3 files changed

+111
-0
lines changed

debian/usability-misc.postinst

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,25 @@ systemd_journald_audit_transport_enable() {
3737
touch "/var/lib/usability-misc/do_once/${FUNCNAME}_version_1"
3838
}
3939

40+
generate_grub_keyboard_layouts_maybe() {
41+
if [ -f "/var/lib/usability-misc/do_once/${FUNCNAME}_version_1" ]; then
42+
return 0
43+
fi
44+
45+
if ! [ -d /boot/grub/kb_layouts ]; then
46+
if timeout --kill-after 5 5 localectl >/dev/null; then
47+
if ischroot; then
48+
true "INFO: Skipping 'set-grub-keymap --build-all' because postinst is running in chroot, ok."
49+
else
50+
set-grub-keymap --build-all || true
51+
fi
52+
fi
53+
fi
54+
55+
mkdir -p "/var/lib/usability-misc/do_once"
56+
touch "/var/lib/usability-misc/do_once/${FUNCNAME}_version_1"
57+
}
58+
4059
true "
4160
#####################################################################
4261
## INFO: BEGIN: $DPKG_MAINTSCRIPT_PACKAGE $DPKG_MAINTSCRIPT_NAME $@
@@ -61,6 +80,8 @@ case "$1" in
6180

6281
adduser --home /run/tunnel --no-create-home --quiet --system --group --shell /bin/false "tunnel" || true
6382

83+
generate_grub_keyboard_layouts_maybe
84+
6485
true "INFO: End configuring $DPKG_MAINTSCRIPT_PACKAGE."
6586

6687
;;

etc/grub.d/44_kb_layout

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
#!/bin/sh
2+
3+
## Copyright (c) 2019 - 2025 ENCRYPTED SUPPORT LLC <[email protected]>
4+
## See the file COPYING for copying conditions.
5+
6+
#set -x
7+
8+
true "usability-misc $0: START"
9+
10+
set -e
11+
12+
if ! [ -d /boot/grub/kb_layouts ]; then
13+
exit 0
14+
fi
15+
16+
printf '%s\n' "\
17+
function load_kb_layout {
18+
kb_layout_name=\"\$1\"
19+
20+
if [ x\$kb_layout_name = x ]; then
21+
echo \"No keyboard layout specified! Press 'Enter' to continue.\"
22+
read
23+
return 1
24+
fi
25+
26+
if ! [ -f \"\${prefix}/kb_layouts/\${kb_layout_name}.gkb\" ]; then
27+
echo \"Keyboard layout '\$kb_layout_name' does not exist! Press 'Enter' to continue.\"
28+
read
29+
return 1
30+
fi
31+
32+
echo \"Switching keyboard layouts may cause the keyboard to malfunction or\"
33+
echo \"become unresponsive. If this occurs, force-reboot the machine to\"
34+
echo \"fix this.\"
35+
echo
36+
if ! terminal_input at_keyboard; then
37+
echo \"Could not enable at_keyboard driver! Press 'Enter' to continue.\"
38+
read
39+
return 1
40+
fi
41+
42+
if ! keymap \"\${prefix}/kb_layouts/\${kb_layout_name}.gkb\"; then
43+
echo \"Could not load keyboard layout '\$kb_layout_name'! Press 'Enter' to continue.\"
44+
read
45+
return 1
46+
fi
47+
48+
echo \"Keyboard layout '\$kb_layout_name' loaded. Press 'Enter' to continue.\"
49+
read
50+
return 0
51+
}
52+
53+
submenu 'Keyboard layout options' \$menuentry_id_option 'kb-layout-options' {"
54+
55+
if [ -f /boot/grub/kb_layouts/user-layout.gkb ]; then
56+
if [ -f /boot/grub/kb_layouts/user-layout.name ]; then
57+
user_layout_name="$(cat /boot/grub/kb_layouts/user-layout.name)" || { user_layout_name='unknown'; true; }
58+
else
59+
user_layout_name='unknown'
60+
fi
61+
62+
printf '%s\n' "\
63+
menuentry \"SWITCH to user-defined keyboard layout '$user_layout_name'\" \$menuentry_id_option 'switch-kb-layout-user-defined' {
64+
load_kb_layout 'user-layout'
65+
}"
66+
fi
67+
68+
for layout_file in /boot/grub/kb_layouts/*.gkb; do
69+
if ! [ -f "$layout_file" ]; then
70+
continue
71+
fi
72+
if [ "$layout_file" = '/boot/grub/kb_layouts/user-layout.gkb' ]; then
73+
continue
74+
fi
75+
layout_name="$(basename "$layout_file" | sed 's/\..*//')"
76+
printf '%s\n' "\
77+
menuentry \"SWITCH to layout '$layout_name'\" \$menuentry_id_option 'switch-kb-layout-$layout_name' {
78+
load_kb_layout '$layout_name'
79+
}"
80+
done
81+
82+
printf '%s\n' "\
83+
}
84+
"
85+
86+
true "usability-misc $0: END"

usr/share/lintian/overrides/usability-misc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,7 @@ usability-misc: conflicts-with-version desktop-config-dist *
1313

1414
usability-misc: desktop-command-not-in-package usr/bin/dist-virtual-keyboard [usr/share/applications/dist-virtual-keyboard.desktop]
1515
usability-misc: desktop-command-not-in-package usr/bin/dist-virtual-keyboard [usr/share/applications/dist-stop-virtual-keyboard.desktop]
16+
17+
## These occur in strings and are part of GRUB's syntax, they aren't part of
18+
## the script itself.
19+
usability-misc: bash-term-in-posix-shell 'read' [etc/grub.d/44_kb_layout*]

0 commit comments

Comments
 (0)