XCAPE(1)

πŸ“¦
version 1.2 Β· 2 versions
  • 1.2 Β· arch rolling, debian bookworm, debian trixie, nixpkgs unstable, opensuse-leap 16.0, ubuntu jammy, ubuntu noble, ubuntu questing, ubuntu resolute, ubuntu stonking (latest)
  • 2018-03 Β· nixos 26.05
, in arch rolling, debian bookworm, debian trixie, nixpkgs unstable, opensuse-leap 16.0, ubuntu jammy, ubuntu noble, ubuntu questing, ubuntu resolute, ubuntu stonking

πŸ’– XCAPE πŸ’–

okay bestie, welcome to the xcape manual page (section 1 of the xcape Manual, if we're being official about it) 🌸


✨ NAME ✨

xcape β€” use a modifier key as another key πŸ‘‘


🌈 SYNOPSIS 🌈

xcape [-d] [-t timeout] [-e map-expression]

πŸ’… DESCRIPTION πŸ’…

so here's the tea πŸ“: xcape lets a modifier key do a whole other job when you press it and let it go all by itself. like, tapped solo, no other key invited to the party.

the default behaviour? genuinely iconic: it generates the Escape key instead of Control_L (that's Left Control, the one on the left, yes).


πŸŽ€ OPTIONS πŸŽ€

  • -d β€” Debug mode πŸ›. it will run as a foreground process, so it's right there in your terminal being loud and proud.
  • -t timeout β€” give a timeout in milliseconds ⏱️. if you hold a key longer than timeout, a key event will not be generated. so hold it too long and, nope, nothing, sorry babe.
  • -e map-expression β€” use map-expression as the expression(s) πŸ’«.

πŸ¦‹ EXPRESSION SYNTAX πŸ¦‹

the expression syntax is Β΄ModKey=Key[|OtherKey]Β΄ β€” yes, that's the shape of it, that's the vibe ✨

you can pass multiple expressions, and you delimit them with semi-colons (;). stack 'em up, bestie.

a whole list of keysyms lives in the header file <X11/keysymdef.h> β€” and psst, you drop the XK_ prefix when you use them 🫢

⚠️ important caveat, do not skip this: shifted keys have to be specified as a shift key followed by the key to be pressed, not the actual name of the character. so if you wanna generate {, you'd use the expression Β΄ModKey=Shift_L|bracketleftΒ΄ β€” that's assuming you've got a key with Β΄{Β΄ sitting above Β΄[Β΄, iykyk 😌

you can also specify ModKey in decimal (prefix #), octal (#0), or hexadecimal (#0x) πŸ”’. it'll be interpreted as a keycode unless no corresponding key name is found. that last bit matters, fr fr.


πŸ”₯ EXAMPLES πŸ”₯

make Left Shift pop off as Escape, and Left Control do a Ctrl-O combo

make Left Shift generate Escape when it's pressed and released on its own, and make Left Control generate a Ctrl-O combination when it's pressed and released on its own πŸŽ‰

xcape -e 'Shift_L=Escape;Control_L=Control_L|O'

the xmodmap collab 🀝

in conjugation with xmodmap it is possible to make an ordinary key act as an extra modifier. the move is: first map the key to the modifier with xmodmap, and then map the modifier back to the key with xcape πŸ”

as an example, we can make the space bar work as an additional ctrl key when held, with the following sequence of commands πŸ‘‡

step one: give the modifier a home

first, map an unused modifier's keysym to the spacebar's keycode, and make it a control modifier. it needs to be an existing key so that emacs won't spazz out when you press it 😭. Hyper_L is a good candidate πŸ’œ

spare_modifier="Hyper_L"
xmodmap -e "keycode 65 = $spare_modifier"
xmodmap -e "remove mod4 = $spare_modifier"
# hyper_l is mod4 by default
xmodmap -e "add Control = $spare_modifier"

step two: stash space somewhere safe

next, map space to an unused keycode β€” this is so it's kept around for xcape to use 🧚

xmodmap -e "keycode any = space"

step three: the actual xcape moment ✨

finally, use xcape to cause the space bar to generate a space when tapped 🫢

xcape -e "$spare_modifier=space"

🌸 SEE ALSO 🌸

xmodmap(1), xev(1)


πŸ‘‘ AUTHOR πŸ‘‘

xcape was written by Albin Olsson (albin dot olsson at gmail dot com) πŸ’Œ


and that's a wrap, bestie πŸ’– this page came from John Hill, dated 2014-02-13, for XCAPE(1) β€” periodt. πŸŽ€πŸ¦‹