Skip to content

Instantly share code, notes, and snippets.

@meatcar
Created January 13, 2018 16:32
Show Gist options
  • Select an option

  • Save meatcar/82d504baab3e4b4339d71caa874ff6c1 to your computer and use it in GitHub Desktop.

Select an option

Save meatcar/82d504baab3e4b4339d71caa874ff6c1 to your computer and use it in GitHub Desktop.

Re-map Surface Pro 3 buttons

This how I remap my SP3's screen buttons to something more useable than the default binding.

By default Linux binds the windows key to LWIN, which overlaps with my window manager's meta binding, and is pretty useless when using the Surface with the keyboard folded. I remap it to F13 so I can bind it to custom scripts with xbindkeys, but you can customize it to suit your needs.

There's probably a better place to put the xkb and have it loaded at system boot instead, but this works good enough for me.

Setup is as follows:

~/.xinitrc

#...
SP3_BUTTON_XINPUT_ID=$(xinput | grep 'Surface Pro 3/4 Buttons' | sed 's/\s/\n/g' | grep id | sed 's/id=//')
xkbcomp -i "$SP3_BUTTON_XINPUT_ID" ~/.config/sp3buttons.xkb "$DISPLAY" &
#...

~/.config/sp3buttons.xkb

xkb_keymap {

    xkb_keycodes { include "evdev" };

    xkb_types { include "complete" };
    xkb_compat { include "complete" };

    xkb_symbols {
        key <LWIN> { [ F13 ] };
        key <VOL-> { [ XF86AudioLowerVolume ] };
        key <VOL+> { [ XF86AudioRaiseVolume ] };
    };
};

Restart X and enjoy :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment