How to map the Framework symbol key to compose key

I am using Ubuntu 22.04. I would like to switch the framework symbol key on the keyboard (it shares with F12) to compose key. Can somebody please help me out? I am a beginner.

Gnome does provide in settings window, where we can set the compose key but it is limited to only a few options like ctrl, alt, super, menu etc. I can’t set the custom key as a compose key.

Refer: What does the Framework button on my keyboard do?

1 Like

This is not the exact answer, but a clue. The Framework symbol’s keycode is 234, and the symbol is XF86AudioMedia, when typing the key in the monitoring command below.

$ xev -event keyboard
...
KeyPress event, serial 28, synthetic NO, window 0x800001,
    root 0x497, subw 0x0, time 425499241, (401,41), root:(419,532),
    state 0x0, keycode 234 (keysym 0x1008ff32, XF86AudioMedia), same_screen YES,
    XLookupString gives 0 bytes:
    XmbLookupString gives 0 bytes:
    XFilterEvent returns: False

KeyRelease event, serial 28, synthetic NO, window 0x800001,
    root 0x497, subw 0x0, time 425499386, (401,41), root:(419,532),
    state 0x0, keycode 234 (keysym 0x1008ff32, XF86AudioMedia), same_screen YES,
    XLookupString gives 0 bytes:
    XFilterEvent returns: False
...

@junaruga

I am surprised that when I press the Framework key the following appears while the default media player VLC opens.

$ xev -event keyboard

KeymapNotify event, serial 24, synthetic NO, window 0x0,
    keys:  0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   
           0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   

KeymapNotify event, serial 24, synthetic NO, window 0x0,
    keys:  0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   
           0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   

KeymapNotify event, serial 24, synthetic NO, window 0x0,
    keys:  0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   
           0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0  

I think the KeymapNotify events are not relevant to pressing the Framework key. It seems the events happen when bringing the xev window into focus. [1]

The reason you don’t see the KeyPress and KeyRelease events are because your XF86AudioMedia is mapped to run the VLC.

In my config file for the Window manager Sway, here is the setting for XF86AudioMedia. When enabling the line below, I see a similar result that you see. You can check your window manager’s key binding setting, and clear the XF86AudioMedia setting at once.

# Framework Laptop F12: XF86AudioMedia
bindsym XF86AudioMedia exec firefox https://community.frame.work/

References

I am mapping Caps Lock key as Esc key. So, my keyboard has 2 Esc keys, the original Esc and the Caps Lock key. I am mapping each Esc key + Shift key as compose key. It works on both X Window system base window manager and Wayland-based system manager. I am not sure if it is useful or not for you. But I just share it here. I don’t know how to map the Framework key as compose key.

X Window system-based window manager

I am using the xkb’s custom feature. My blog article about how to set up is here.

Wayland system-based window manager Sway

I am using GitHub - xkbcommon/libxkbcommon: keymap handling library for toolkits and window systems to manage the xkb custom layout files under the home directory. Sway supports the libxkbcommon.

$ pwd
/home/jaruga

$ find .xkb/
.xkb/
.xkb/rules
.xkb/rules/evdev.org
.xkb/rules/evdev
.xkb/symbols
.xkb/symbols/custom
$ cat .xkb/rules/evdev
// See https://xkbcommon.org/doc/current/md_doc_user_configuration.html
! option = symbols
  custom:compose_shifted_escape = +custom(compose_shifted_escape)

! include %S/evdev
$ cat .xkb/symbols/custom
hidden partial modifier_keys
xkb_symbols "compose_shifted_escape" {
    key <ESC> { type[Group1]="TWO_LEVEL", [ Escape, Multi_key ] };
};
$ cat ~/.config/sway/config
...
input "1:1:AT_Translated_Set_2_keyboard" {
    xkb_layout us

    # The following files manage the symbols.
    # /usr/share/X11/xkb/rules/evdev
    # /usr/share/X11/xkb/rules/evdev.xml
    # /usr/share/X11/xkb/symbols/*
    #
    # You can set the own custom symbol loading the following files.
    # ~/.xkb/rules/evdev
    # ~/.xkb/symbols/*
    # https://github.com/swaywm/sway/wiki#keyboard-layout
    #
    # The caps:escape_shifted_compose is available on xkeyboard-config >= 2.35.
    # https://gitlab.freedesktop.org/xkeyboard-config/xkeyboard-config/-/commit/8018e2982d1067fc79195e518546fee191b63b6d
    xkb_options "caps:escape_shifted_compose,custom:compose_shifted_escape"
    # Set Shift + Esc as Compose key.
    # https://gitlab.freedesktop.org/xkeyboard-config/xkeyboard-config/-/merge_requests/418
    # xkb_options "caps:escape_shifted_compose,compose:shifted_escape"
}
...
2 Likes

Oops, I posted prematurely, will edit Edited:

@Lamy here’s the solution below:

I’m messing around with custom keymaps at the moment (I’m also using Sway/libxkbcommon like @junaruga).

In my ~/.xkb/symbols/custom file, if I want the Framework symbol key to map to the Compose key, I add this line:

key <I234> { [ Multi_key ] };

(<I234> comes from /usr/share/X11/xkb/keycodes/evdev)

Multi_key is for the Compose key, see:
List of Keysyms Recognised by Xmodmap - LQWiki

Multi_key 0xFF20 Allows odd characters to be entered, in the same way as Compose in loadkeys

You can verify that it’s set correctly by running:

xmodmap -pke

which shows:

...
keycode 234 = XF86AudioMedia NoSymbol Multi_key
...

which means (keycode 234 → XF86AudioMedia) will trigger the Multi_key.

In this way, that key (and others) can be remapped to fit your needs! :melting_face:


Extra note for Sway and perhaps others:
It seems like inet(evdev) can override the custom layout symbols causing it not to work:

$ setxkbmap -print -verbose 10
Setting verbose level to 10
WARNING: Running setxkbmap against an Xwayland server
locale is C
Trying to load rules file ./rules/evdev...
Trying to load rules file /usr/share/X11/xkb/rules/evdev...
Success.
Applied rules from evdev:
rules:      evdev
model:      pc105
layout:     us
Trying to build keymap using the following components:
keycodes:   evdev+aliases(qwerty)
types:      complete
compat:     complete
symbols:    pc+us+inet(evdev)
geometry:   pc(pc105)
xkb_keymap {
	xkb_keycodes  { include "evdev+aliases(qwerty)"};
	xkb_types     { include "complete"	};
	xkb_compat    { include "complete"	};
	xkb_symbols   { include "pc+us+inet(evdev)"	};
	xkb_geometry  { include "pc(pc105)"	};
};

Note that since inet(evdev) is last in this line:

symbols: pc+us+inet(evdev)

that the file /usr/share/X11/xkb/symbols/inet will override the previous pc and us symbols.

To override that file, we can copy it into ~/.xkb/symbols/inet (or ~/config/xkb/symbols/inet). Finally, in override file, update the key <I234> value, e.g.:

key <I234> { [ Multi_key ] };

Another option is overriding everything by dumping and using an xkb_file.
Dump the config:

$ xkbcomp $DISPLAY ~/xkb.dump

and then set the key <I234> value you want in that file.

Finally, use it in your Sway config:

input * xkb_file "~/xkb.dump"

See:
https://github.com/swaywm/sway/issues/3999#issuecomment-650638153
https://github.com/edyounis/sway/commit/08ec244bfdb1ab6d59a1caa39a14ee991c26ceb4

1 Like

Any answer for Fedora 38 with Gnome windows manager?

1 Like

@Lamy, regarding your ticket - we do not provide official Fedora support for custom key remapping. We may provide best effort support, but that is where it ends.

I’m actually using Sway on Fedora 38 with some parts of Gnome. I haven’t tried it with Gnome as the desktop environment, but the steps should be pretty similar and the theory is the same.

I think there’s a risk of rendering your keyboard temporarily useless if you mess something up, so if you do attempt, try to fully understand what’s going on first. And feel free to bounce questions off!

@Matt_Hartley if y’all do end up adding some version into the pipeline, feel free to reach out if needed! I can send over some more info/testing.

2 Likes