3

Background: I got an Acer Chromebook yesterday and I am running Ubuntu on it (I am also somewhat new to Linux). The keyboard does not have dedicated Home and End buttons since in ChromeOS there are replacement key bindings (that do not work under the running Linux).

My question: is if there is a way to assign certain key binding in Linux to Home and End key actions so that I can recover those two keys by key combinations.

  • Which key combination would you prefer to assign to Home and End? If it's a combination with modifiers, there's an added difficulty in not transmitting the modifiers to the application. – Gilles Nov 9 '14 at 0:28
  • The ChromeOS combinates are ctrl+alt+up/down for [home] and [end] -I think. And there is not much room to spare on the keuboard, so I guess I am looking for something with the modifiers, if possible. – oligilo Nov 9 '14 at 3:45
3

Here's how it used to be done, with XKB. More recent versions of Chrome OS now use Ash.

Create a directories called ~/.xkb/keymap, ~/.xkb/types and ~/.xkb/symbols. Create a file ~/.xkb/types/chromebook containing the following definition:

xkb_types "chromebook" {
    virtual_modifiers Alt;
    type "ARROW" {
        modifiers              = Shift+Lock+Alt+Control;
        map[Shift]             = Level2;
        map[Lock]              = Level2;
        map[Alt]               = Level3;
        map[Alt+Shift]         = Level3;
        map[Alt+Lock]          = Level3;
        map[Control+Alt]       = Level4;
        map[Control+Alt+Shift] = Level4;
        map[Control+Alt+Lock]  = Level4;
        level_name[Level1]     = "Base";
        level_name[Level2]     = "Caps";
        level_name[Level3]     = "Alt";
        level_name[Level4]     = "ControlAlt";
    };
}

Create a file ~/.xkb/symbols/chromebook containing the following definition:

xkb_symbols "chromebook" {
    key <UP> {
        type="ARROW",
        repeat=yes,
        [ Up, Up, Prior, Home ],
        actions[Group1] = [
            NoAction(),
            NoAction(),
            RedirectKey(key=<PGUP>, clearmods=Alt),
            RedirectKey(key=<HOME>, clearmods=Control+Alt)
        ]
    };
    key <DOWN> {
        type="ARROW",
        repeat=yes,
        [ Down, Down, Next, End ],
        actions[Group1] = [
            NoAction(),
            NoAction(),
            RedirectKey(key=<PGDN>, clearmods=Alt),
            RedirectKey(key=<END>, clearmods=Control+Alt)
        ]
    };
};

Run the command setxkbmap -print >~/.xkb/keymap/chromebook. Edit the resulting file and add +chromebook inside the include directives for xkb_types and xkb_symbols; the file should look like this:

xkb_keymap {
        xkb_keycodes  { include "evdev+aliases(qwerty)" };
        xkb_types     { include "complete+chromebook"      };
        xkb_compat    { include "complete"      };
        xkb_symbols   { include "pc+us+inet(evdev)+chromebook"     };
        xkb_geometry  { include "pc(pc105)"     };
};

Add the following command to the startup applications:

xkbcomp -I ~/.xkb -R ~/.xkb keymap/chromebook $DISPLAY

Note: this is untested, I'm not very familiar with XKB and it's poorly documented. I tried to follow Vincent Lefèvre's XKB tips.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.