This forum has been archived. All content is frozen. Please use KDE Discuss instead.

Konsole: how to suppress F12

Tags: konsole konsole konsole
(comma "," separated)
solardde
Registered Member
Posts
8
Karma
0

Konsole: how to suppress F12

Sat Sep 19, 2009 9:41 pm
On KDE Konsole (Terminal Program), if F12 is pressed on the keyboard, a tilde (~) gets inserted. However, I want Konsole to ignore F12. One of my USB devices uses F12 as a hotkey, and hence F12 conflicts with Konsole.

I know how to configure Terminal to ignore F12 on Mac OS X. However, I do not know how to configure Konsole on Linux for this purpose.

Mac OS X comes with Terminal, which I think is developed by Apple but not by KDE. On Mac OS X Leopard,
Terminal > Preferences... > Settings > Keyboard
stores the mapping between the F12 key and the action.
By default, F12 is associated with "send string to shell", where the string is \033[24~
By deleting this string, Terminal on Mac OS X will ignore F12.

Now, on KDE Konsole on Linux, how can I configure Konsole to ignore F12?

(My Linux came with Konsole 1.6.6 using KDE 3.5.9.)

.
.
.
User avatar
bcooksley
Administrator
Posts
19765
Karma
87
OS

Re: Konsole: how to suppress F12

Sat Sep 19, 2009 10:35 pm
This is possible. You need to change the keybindings type that Konsole uses.
Konsole > Settings > Configure Konsole > Session > Keytab. Unfortunately the KDE 3 version does not allow customising the terminal keyboard layout, while the KDE 4 version does.


KDE Sysadmin
[img]content/bcooksley_sig.png[/img]
solardde
Registered Member
Posts
8
Karma
0
Thanks, bcooksley, for the solution on KDE 4.

It has been a year. I have leaned Unix and Linux more. Now, I have a solution that works on KDE 3.5.10.

To disable the F12 key on KDE 3.5.10, I have found a solution using the "xmodmap" command and putting it in a script file in the directory "~/.kde/Autostart/". In the following, I will explain how the solution works.

When a key is pressed on the keyboard, the keyboard driver passes a keycode to X11. Next, X11, interprets and converts the keycode into a character or an action. The conversion is made based on a keymap. Finally, X11 passes the resultant character or action to the client X11 applications (including Konsole and all the KDE applications).

The "xmodmap" command modifies the keymap that X11 uses. The "xmodmap" command can also display the current keymap.

Consider the following assignment in a keymap.

keycode 38 = a A

The left hand side is the keycode that X11 receives from the keyboard driver. The right hand side can hold two or more symbols, although a single symbol is also acceptable. Each symbol on the right hand side represents the character or action that X11 passes to its client applications (including Konsole and all the KDE applications). The first symbol is the one when no modifier (e.g., Shift, Control, Alt or Option) is held down. The second symbol is the one when Shift is held down.


Note the distinction between the following two kinds of conversions. The conversion from a keycode into a character/action is done by X11. The conversion from a key on the keyboard into a keycode is done by the keyboard driver (together with the keyboard).

The mapping from keys on keyboard to keycodes depends on the system. For example, when the "A" key is pressed on a keyboard, the driver may generate Keycode 38 on one system, but may generate 40 on another system.

Now, this post is supposed to explain how to suppress F12. So, the keycode corresponding to the F12 key for a given system must be found.

xmodmap -pke | grep F12

The above command line displays the assignments involving F12 in the current keymap. You will see something like below.

keycode 96 = F12 XF86_Switch_VT_12

The above assignment tells that, when X11 receives Keycode 96 from the driver, X11 passes F12 to its client applications if accompanied by no modifier, and XF86_Switch_VT_12 if accompanied by Shift. Before customized, the keymap is supposed to be straightforward so that the key pressed on the keyboard matches the character or action X11 passes to its client applications. So, it is very likely that keycode 96 is what X11 receives from the driver when the F12 key is pressed for this specific system.

Now, let us disable F12 by the following command line, assuming that X11 receives keycode 96 when the F12 key is pressed.

xmodmap -e "keycode 96 = NoSymbol XF86_Switch_VT_12"

The quoted assignment tells that, when X11 receives Keycode 96 from the driver, X11 passes nothing to its client applications if accompanied by no modifier, and XF86_Switch_VT_12 if accompanied by Shift.


If the above command line works, the next step is to put it into a script file that is automatically executed at a boot time. To tell the conclusion first, the script file should be placed in the directory "~/.kde/Autostart/".

Other directories for startup scripts at boot time failed to suppress F12 by xmodmap.

Here are the directories related to run control.

/etc/rc.d/rc0.d/
/etc/rc.d/rc1.d/
/etc/rc.d/rc2.d/
/etc/rc.d/rc3.d/
/etc/rc.d/rc4.d/
/etc/rc.d/rc5.d/
/etc/rc.d/rc6.d/

My system never executes the startup scripts in rc4.d and rc5.d. My system executes startup scripts in rc3.d. However, rc3.d is so early in the boot process that X11 is not running yet. To issue the xmodmap command, X11 has to be already running. rc6.d is too late. See /etc/inittab for the detail of run control of your system.


As KDE starts up, the following scripts are executed in the following order.

(1) /etc/kde/kdm/Xsession
(2) /usr/bin/startkde
(3) scripts in ~/.kde/Autostart/

KDE loads its own keymap after "startkde" and before "Autostart". Thus, it is useless to put the xmodmap customization into the script "Xsession" or "startkde". The xmodmap customization in "Xsession" or "startkde" would vanish when KDE loads its own keymap afterward.

Comments in Xsession claim that the xmodmap customization should be done at Xsession. However, this claim applies to only systems on which KDE is not installed but only X11 is installed. On systems with KDE installed, the xmodmap customization should be done at "Autostart".


I am glad that I have found a solution to suppress F12 on KDE 3.5. However, I posted the original question a year ago. I wish someone in this forum had posted this kind of solution last year :)


Bookmarks



Who is online

Registered users: Bing [Bot], claydoh, Google [Bot], rblackwell