unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: Yuri Khan <yuri.v.khan@gmail.com>
To: Rusi <rustompmody@gmail.com>
Cc: "help-gnu-emacs@gnu.org" <help-gnu-emacs@gnu.org>
Subject: Re: How bind "Super" key *all by itself* to a function?
Date: Mon, 19 Jan 2015 16:08:00 +0700	[thread overview]
Message-ID: <CAP_d_8VRHdm=_QJm=3KKAK2QGAs9M3KFR33RRY8c63PewzVMYQ@mail.gmail.com> (raw)
In-Reply-To: <50ee152f-7dd7-4325-8b38-728e3e971338@googlegroups.com>

[Damn Gmail. Its Send button is too near the “show quote” button and
too high-contrast.]

On Mon, Jan 19, 2015 at 1:35 PM, Rusi <rustompmody@gmail.com> wrote:

>> However, you can use XKB (in X) and/or loadkeys (in tty) to map the
>> Windows key to produce a different keycode such as F13, and then bind
>> that to any function you like.
>
> Do you have a simple howto on that? [XKB]
> With xmodmap it was at least conceivable
> Xkb is too much of a dragon
>
> eg Say I have a broken ~ key and I want to make F12 generate ~

Not quite qualifies as “simple” but not very complicated.

* Find the XKB data directory. [Normally, this is /usr/share/X11/xkb.]
* In its “keycodes” subdirectory, create a file that is unlikely to be
overwritten by a future version of XKB (e.g. by prefixing it with your
initials). [Let’s name it “rusi” for the sake of this example.]
* In this file, paste the following:

===
xkb_keycodes "f12tilde" {
    # remappings go here…
};

# you can have multiple remapping sections
# and activate any subset thereof, just add more
# xkb_keycodes "some_name" {
#   # …
# };
===

Each remapping takes the form: <KEYNAME> = KEYCODE;

Refer to the existing entries in the section “default xkb_keycodes
"evdev"” for key names and codes.

For keyname, find the name of the key you want to generate. In your
case, it’s <TLDE>.

For keycode, find the numeric code of the key you want to remap. In
your case, it’s the code which is normally bound to <FK12>, namely,
96.

So:

===
    <TLDE> = 96;
===

* Now that you have a keycodes section of your own, make a
corresponding option. In the rules/evdev file, find the following
header:

===
! option = keycodes
===

In that section, add something like:

===
  rusi:f12tilde = +rusi(f12tilde)
===

Here, the form on the right refers to the keycodes filename and
section, and the name on the left specifies the option name.

* Next, you want your X server to pick up this option. You can do it
system-wide or per-user; I’ll describe the system-wide setup because I
find it easier and less DE-specific.
* In the /usr/share/X11/xorg.conf.d directory [or its equivalent on
your system], create a uniquely named file [e.g.
11-rusi-keycodes.conf]:

===
Section "InputClass"
    Identifier "Keyboard layouts"
    Driver "evdev"
    Option "XkbOptions" "rusi:f12tilde"
    Option "AutoServerLayout" "on"
    MatchIsKeyboard "on"
    MatchDevicePath "/dev/input/event*"
EndSection
===

In the XkbOptions line, refer to the option name you added to rules/evdev.

Next time you boot X or plug in a keyboard, it should use your customization.

You can check the current set of XKB options by executing the
following command in a terminal emulator within an X session:

$ setxkbmap -query

----

Legend has it that there is a possibility of using xkbcomp(1) on a
user-specific configuration file, but I never learned that;
system-wide is good enough for me.

One caveat: whenever you update the package that contains the
rules/evdev file, it may be overwritten and you might have to re-add
your option line.



  parent reply	other threads:[~2015-01-19  9:08 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-01-19  6:57 How bind "Super" key *all by itself* to a function? Chris Seberino
2015-01-19  7:16 ` Yuri Khan
     [not found] ` <mailman.18124.1421651779.1147.help-gnu-emacs@gnu.org>
2015-01-19  7:35   ` Rusi
2015-01-19  8:25     ` Yuri Khan
2015-01-19  9:08     ` Yuri Khan [this message]
     [not found]     ` <mailman.18131.1421658484.1147.help-gnu-emacs@gnu.org>
2015-01-19 13:54       ` Rusi
2015-01-19 14:33       ` Rusi
2015-01-19 15:32         ` Yuri Khan

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAP_d_8VRHdm=_QJm=3KKAK2QGAs9M3KFR33RRY8c63PewzVMYQ@mail.gmail.com' \
    --to=yuri.v.khan@gmail.com \
    --cc=help-gnu-emacs@gnu.org \
    --cc=rustompmody@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).