kubuntu kwin 快捷键无法与数字键盘配合使用

kubuntu kwin 快捷键无法与数字键盘配合使用

我正在尝试在 Kubuntu 11.04 中映射 KWin 中的键,例如 Meta + KP4。

如果数字锁定处于打开状态,它将被记录为“Meta + 4”,然后与主键盘上的 4 一起使用,但不在小键盘上。

如果数字锁定关闭,它会被记录为“Meta + Left”,然后与主键盘上的左箭头一起使用,但不在小键盘上。

我希望它能在键盘上使用!也许键盘设置中有一些选项……?

答案1

感谢您的指导,其中有一个解决方法的建议。以下是为防止其他人遇到此问题而提供的建议:

创建 ~/.Xmodmap 并添加以下文本:

keycode 87 = XF86Launch1
keycode 88 = XF86Launch2
keycode 89 = XF86Launch3
keycode 83 = XF86Launch4
keycode 84 = XF86Launch5
keycode 85 = XF86Launch6
keycode 79 = XF86Launch7
keycode 80 = XF86Launch8
keycode 81 = XF86Launch9
keycode 90 = XF86LaunchA
keycode 91 = XF86LaunchB

我还添加了

keycode 86 = XF86LaunchC
keycode 82 = XF86LaunchD

用于键盘 +/-。

然后运行 ​​xmodmap ~/.Xmodmap。现在您应该能够将 绑定到按键上。此外,如果其他按键不起作用,请尝试使用实用程序 xev,它可以告诉您特定按键的键码,并以类似的方式添加它。

答案2

也许这是相关的 - 一个错误报告:错误 183458 - 设置全局快捷键时数字键盘(小键盘)键未正确映射 /https://bugs.kde.org/show_bug.cgi?id=183458

答案3

使用 xmodmap 有效,但这意味着数字键盘不能用作实际数字键盘。以下解决方法允许使用数字键盘来平铺窗口,也可以将其用作数字键盘。

安装 xbindkeys

sudo apt-get install xbindkeys

设置热键

将以下内容添加到~/.xbindkeysrc。您可能需要根据您的设置和所需的热键修改组合键。此脚本使用 Windows 键和数字键盘。运行xbindkeys -k将允许您发现按下按键时哪些代码映射到按键上。

"qdbus org.kde.kglobalaccel /component/kwin org.kde.kglobalaccel.Component.invokeShortcut 'Window Quick Tile Bottom Left'"
Mod4 + Super_L + KP_1

"qdbus org.kde.kglobalaccel /component/kwin org.kde.kglobalaccel.Component.invokeShortcut 'Window Quick Tile Bottom'"
Mod4 + Super_L + KP_2

"qdbus org.kde.kglobalaccel /component/kwin org.kde.kglobalaccel.Component.invokeShortcut 'Window Quick Tile Bottom Right'"
Mod4 + Super_L + KP_3

"qdbus org.kde.kglobalaccel /component/kwin org.kde.kglobalaccel.Component.invokeShortcut 'Window Quick Tile Left'"
Mod4 + Super_L + KP_4

"qdbus org.kde.kglobalaccel /component/kwin org.kde.kglobalaccel.Component.invokeShortcut 'Window Maximize'"
Mod4 + Super_L + KP_5

"qdbus org.kde.kglobalaccel /component/kwin org.kde.kglobalaccel.Component.invokeShortcut 'Window Quick Tile Right'"
Mod4 + Super_L + KP_6

"qdbus org.kde.kglobalaccel /component/kwin org.kde.kglobalaccel.Component.invokeShortcut 'Window Quick Tile Top Left'"
Mod4 + Super_L + KP_7

"qdbus org.kde.kglobalaccel /component/kwin org.kde.kglobalaccel.Component.invokeShortcut 'Window Quick Tile Top'"
Mod4 + Super_L + KP_8

"qdbus org.kde.kglobalaccel /component/kwin org.kde.kglobalaccel.Component.invokeShortcut 'Window Quick Tile Top Right'"
Mod4 + Super_L + KP_9

答案4

改进evencoil 的回答您可以更改数字键盘按键的绑定,同时保留正常行为当 Num Lock 处于打开状态时改用这个~/.Xmodmap

! this xmodmap file changes the Num Lock OFF binds of all Keypad keys to make it easier to make custom shortcuts with these keys using XF86Launch codes
! what are XF86Launch symbolic codes: https://askubuntu.com/a/1064810/1560675
! note that by using these you lose the default Num Lock OFF binds  (duh?) I left them here commented out just for reference
! from: https://askubuntu.com/a/1463491/1560675
! you can use the "xev" command to make sure the keys are the same for your keyboard
! you might need to use other XF86Launch codes like XF86LaunchD XF86LaunchE and XF86LaunchF if some of the ones used here are already used by other hardware keys already (some keyboards have dedicated hardware buttons for these codes but they are quite rare) or another custom xmodmap you might be using
! you can comment the lines that change binding you do not need simply by adding a "!" in the beginning of the corrisponding line (lines starting with "!" are comment and will be ignored by xmodmap)
! I have left the original bindings commented out just as reference


! default key 79 uses "Keypad Home" with Num Lock OFF and "Keypad 7" with Num Lock ON
!keycode  79 = KP_Home KP_7 KP_Home KP_7
! custom key 79 uses "XF86Launch0" with Num Lock OFF and "Keypad 7" with Num Lock ON
keycode  79 = XF86Launch0 KP_7 XF86Launch0 KP_7

! default key 80 uses "Keypad Up" with Num Lock OFF and "Keypad 8" with Num Lock ON
!keycode  80 = KP_Up KP_8 KP_Up KP_8
! custom key 80 uses "XF86Launch1" with Num Lock OFF and "Keypad 8" with Num Lock ON
keycode  80 = XF86Launch1 KP_8 XF86Launch1 KP_8

! default key 81 uses "Keypad Prior" with Num Lock OFF and "Keypad 9" with Num Lock ON
!keycode  81 = KP_Prior KP_9 KP_Prior KP_9
! custom key 81 uses "XF86Launch2" with Num Lock OFF and "Keypad 9" with Num Lock ON
keycode  81 = XF86Launch2 KP_9 XF86Launch2 KP_9

! default key 82 uses "Keypad Subtract" with Num Lock OFF and "Keypad Subtract" with Num Lock ON
!keycode  82 = KP_Subtract KP_Subtract KP_Subtract KP_Subtract KP_Subtract KP_Subtract XF86Prev_VMode
! custom key 82 uses "XF86Launch3" with Num Lock OFF and "Keypad Subtract" with Num Lock ON
keycode  82 = XF86Launch3 KP_Subtract XF86Launch3 KP_Subtract KP_Subtract KP_Subtract XF86Prev_VMode

! default key 83 uses "Keypad Left" with Num Lock OFF and "Keypad 4" with Num Lock ON
!keycode  83 = KP_Left KP_4 KP_Left KP_4
! custom key 83 uses "XF86Launch4" with Num Lock OFF and "Keypad 4" with Num Lock ON
keycode  83 = XF86Launch4 KP_4 XF86Launch4 KP_4

! default key 84 uses "Keypad Begin" with Num Lock OFF and "Keypad 5" with Num Lock ON
!keycode  84 = KP_Begin KP_5 KP_Begin KP_5
! custom key 84 uses "XF86Launch5" with Num Lock OFF and "Keypad 5" with Num Lock ON
keycode  84 = XF86Launch5 KP_5 XF86Launch5 KP_5

! default key 85 uses "Keypad Right" with Num Lock OFF and "Keypad 6" with Num Lock ON
!keycode  85 = KP_Right KP_6 KP_Right KP_6
! custom key 85 uses "XF86Launch6" with Num Lock OFF and "Keypad 6" with Num Lock ON
keycode  85 = XF86Launch6 KP_6 XF86Launch6 KP_6

! default key 86 uses "Keypad Add" with Num Lock OFF and "Keypad 6" with Num Lock ON
!keycode  86 = KP_Add KP_Add KP_Add KP_Add KP_Add KP_Add XF86Next_VMode
! custom key 86 uses "XF86Launch7" with Num Lock OFF and "Keypad 6" with Num Lock ON
keycode  86 = XF86Launch7 KP_Add XF86Launch7 KP_Add KP_Add KP_Add XF86Next_VMode

! default key 87 uses "Keypad End" with Num Lock OFF and "Keypad 1" with Num Lock ON
!keycode  87 = KP_End KP_1 KP_End KP_1
! custom key 87 uses "XF86Launch8" with Num Lock OFF and "Keypad 1" with Num Lock ON
keycode  87 = XF86Launch8 KP_1 XF86Launch8 KP_1

! default key 88 uses "Keypad Down" with Num Lock OFF and "Keypad 2" with Num Lock ON
!keycode  88 = KP_Down KP_2 KP_Down KP_2
! custom key 88 uses "XF86Launch9" with Num Lock OFF and "Keypad 2" with Num Lock ON
keycode  88 = XF86Launch9 KP_2 XF86Launch9 KP_2

! default key 89 uses "Keypad Next" with Num Lock OFF and "Keypad 3" with Num Lock ON
!keycode  89 = KP_Next KP_3 KP_Next KP_3
! default key 89 uses "XF86LaunchA" with Num Lock OFF and "Keypad 3" with Num Lock ON
keycode  89 = XF86LaunchA KP_3 XF86LaunchA KP_3

! default key 90 uses "Keypad Insert" with Num Lock OFF and "Keypad 0" with Num Lock ON
!keycode  90 = KP_Insert KP_0 KP_Insert KP_0
! default key 90 uses "XF86LaunchB" with Num Lock OFF and "Keypad 0" with Num Lock ON
keycode  90 = XF86LaunchB KP_0 XF86LaunchB KP_0

! default key 91 uses "Keypad Delete" with Num Lock OFF and "Keypad Decimal" with Num Lock ON
!keycode  91 = KP_Delete KP_Decimal KP_Delete KP_Decimal
! default key 91 uses "XF86LaunchC" with Num Lock OFF and "Keypad Decimal" with Num Lock ON
keycode  91 = XF86LaunchC KP_Decimal XF86LaunchC KP_Decimal

为此,您可以使用任何编辑器(例如 nano),运行:nano ~/.Xmodmap并将上述内容粘贴到其中,然后按 Ctrl+s 和 Ctrl+x 保存并退出,然后重新启动或重启 x 会话。如果重新启动或重启 x 会话后它不起作用,您可能需要检查以下内容:https://askubuntu.com/a/1463479/1560675

相关内容