4

I find myself using the irony mark ⸮ unicode U+2E2E (or ؟ unicode U+061F) in both mcabber and vim a lot. The old copy-and-paste antipattern is tedious so I thought I would rename one of the many useless keyboard keys I have to print it. So, my question is three-fold (but really the same question):

  • How to do it in mcabber?
  • How to do it in awesome? Since that's the window manager I use, it should work for all application, right?
  • How to do it using xmodmap or some other arcane X11 incantation?

Note that in vim this is trivial, just add map! ;; ⸮ in your ~/.vimrc file so in insert mode all you need is to type ";;" to get it replaced.

1
  • never knew there was an irony mark...
    – schaiba
    Jun 4, 2014 at 14:16

3 Answers 3

5

I prefer using the Compose key system, I've just checked and it seems I've had Compose-/-? (and Compose-?-/) set to output U+2E2E for some time now (? reflected off the /)

My .XCompose file looks like this:

#
# add in the original stuff (what's usually there)
include "%L"
#
# Compose key sequences
#
# generate PI char
<Multi_key> <p> <i>     : U03C0 # U03C0 PI
<Multi_key> <P> <I>     : U03C0 # U03C0 PI
#
<Multi_key> <i> <n> <f> : U221E # U221E infinity
<Multi_key> <I> <N> <F> : U221E # U221E infinity
#
<Multi_key> </> <?>     : U2E2E # U2E2E irony punctuation (reversed ?)
<Multi_key> <?> </>     : U2E2E # U2E2E irony punctuation (reversed ?)
#
<Multi_key> <3> <*>     : U2042 # U2042 asterism
#
#

Here I pull in the proper 'preset' Compose keystrokes with the include "%L" line, then add my own customizations after that...

I've got Capslock remapped to be my Compose key, check your Window Manager how to do that, or read about the setxkbmap command. But here's mine:

setxkbmap -model pc101 -layout us -option -option compose:caps -option shift:both_capslock

Sets Capslock to be Compose, also sets Shift+Shift (both) keys to toggle Capslock. (for those rare occasions). Many more -option options, I stripped off a couple for brevity, mainly X Windows ZAP (Ctrl-Alt-Backspace) keystrokes and Left-Win being Meta

2
  • I like this method. No need to use deprecated xmodmap or customize XKB layout files. There are several predefined options for Multi_key mapping also: grep 'compose:' /usr/share/X11/xkb/rules/evdev.lst
    – montiainen
    Jun 5, 2014 at 5:58
  • Three things to mention: α) No need to write a custom file by yourself, you may find on github a written ones. E.g I am using this one β) Usually no need to use a terminal commands to set the Compose key, most popular environments already have it included somewhere in keyboard settings. γ) You may encounter an issue that the key doesn't work in some apps, or print a different characters for the same combination. To do it right you have to set xim as your input method with app im-config.
    – Hi-Angel
    Mar 6, 2015 at 12:43
5

This is possible to do in several ways. In X11 Xmodmap is probably one of the easier ways, for a simple change like this.

Wikipedia article about Irony punctuation:

This character can be represented using the reversed question mark (⸮) found in Unicode as U+2E2E; another character approximating it is the Arabic question mark (؟), U+061F.

Xmodmap manual:

Keysyms matching Unicode characters may be specified as "U0020" to "U007E" and "U00A0" to "U10FFFF" for all possible Unicode characters.

I just tried, and

xmodmap -e "keysym F8 = U061F"

seems to do the trick. The command above binds that symbol on F8 key by keysym. Of course you can bind that symbol on key of your choice. All possible keysyms (not necessarily mapped currently, though) can usually be found in files /usr/include/X11/{keysymdef,XF86keysym}.h. You can map it by keycode also. With tools like xev you can check keycodes and their mapped keysyms on your system.

Check out some decent xmodmap tutorial on Internet.

3
  • Yes, it is that easy with xmodmap... WOW, but I do feel sheepish... I'll accept your answer tomorrow unless someone put me (even more) to shame ^_~ Jun 4, 2014 at 16:29
  • @Sardathrion, I hope that I didn't make you feel so. I joined Stack Exchange just couple of days ago, I'm just learning the ways here. I read your question and knew the answer (or one of the many). When I wrote the answer I just thought about making it as usable as possible for anybody. Although I just realized that you actually gave the link to Wikipedia article, as well as Unicode values in your question... :)
    – montiainen
    Jun 4, 2014 at 16:57
  • ^_~ It's all good. I knew about xmodmap, I just blank forgot about it hence feeling sheepish. Still, this is a very nice answer. Many thanks! Jun 5, 2014 at 6:38
2

The best way to do it is in the keyboard configuration.

I don't know if you can set a custom shortcut to print the character in your jabber client, but then it would be just for that application. As for Awesome : it's a window manager, so it's not its job.

How to input it (or any unicode character) in some (GTK at least) applications :

Ctrl+Shift+U then 2E2E (the hexadecimal code).

How to configure the keyboad to get it elsewhere too :

xmodmap is one way, but it's being deprecated in favor of Xkb even if Xkb configuration can look more complex. But you asked for arcane incantations :D

setxkbmap -print prints the keymap in use. You can send that into a file to use it as base for your new keymap. (Skip to exemple below for the quick version of "how").

xkbcomp is an utility that can be used to compile and send a keymap to the X server.

xkbcomp $DISPLAY keymap.dump will dump the current configuration in the file keymap.dump. It's quite long as it is the same as previously, but with the values obtained from combining the included elements. It can be useful to look up the names that are given to the keys. We need the name to assign another symbol to a key. You could also modify and use it directly, but you can also use the includes and just redefine what you want. The include are files in /usr/share/X11/xkb/, in directories corresponding to the sections.

The keymap file has multiple sections :

  • xkb_keycodes: the part that maps keyboard X keycodes to a key name used in other sections. You can get the X keycode with xev and find the associated name in this part.
  • xkb_types : the part that describe types and which level correspond to which keyboard modifiers (Shift, Control, Alt, any combination of those, etc ..)
  • xkb_compatibility : For "applications that aren't Xkb aware", from what I've read .. I'm not sure what goes here.
  • xkb_symbols: the part that maps the key names to keysyms, and the one where we'll rewrite one of the definitions to add that unicode character. You can see the current definition of the key you want to use.
  • xkb_geometry: the physical keyboard shape .. not sure what uses that.

If you look at key definitions in the dumped keymap, you'll see they have an associated type. The type of the key determine which modifiers are available and corresponding to which level. The combination of key and level correspond to a keysym. The type is one defined in the xkb_types section. If you don't specify another type when redefining the key, it will be the one defined in the included xkb_symbols map.

If I take for example my I key, there are four levels, corresponding to : just the key, key + Shift, key + AltGr, key + Shift+AltGr.

For the group, if you aren't using more than one layout (in your keyboard configuration), you probably have just one, and don't need to specify it. (You can use multiple groups to switch between key definitions associated with that group).

Here is an example of modified keymap file :

xkb_keymap {
 xkb_keycodes { include "evdev+aliases(azerty)"};
 xkb_types { include "complete"};
 xkb_compatibility {include "complete"};
 xkb_symbols {
  include "pc+fr+inet(evdev)"
  key <AD08> {[ i, I, U2E2E, idotless]};
  key <AD09> {[ o, O, oslash, U262F]};
 };
 xkb_geometry { include "pc(pc104)"};
};

With this keymap AltGr+I gives ⸮ and Shift+AltGr+O gives ☯.

To set the keymap : xkbcomp mykeymap.xkb $DISPLAY

The Archlinux wiki have more details, and some other links at the end.

2

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .