[ Home > Softwares > xvkbd ]

Hints to use xvkbd -text

xvkbd and xbindkeys

It appears many users of xvkbd use it with xbindkeys, mainly to use extra buttons on their multi-button mouse.

Here is a hypothetical example of the $HOME/.xbindkeysrc file.

  # button 9 without modifiers -> Control+Alt+Left
  "xvkbd -no-jump-pointer -text '\C\A\[Left]'"
    m:0x0 + b:9

  # button 8 without modifiers -> Control+Alt+Right
  "xvkbd -no-jump-pointer -text '\C\A\[Right]'"
    m:0x0 + b:8

  # Cotnrol + button 9 -> Left on the root window
  "xvkbd -window root -text '\[Left]'"
    Control + b:9

  # Cotnrol + button 8 -> Right on the root window
  "xvkbd -window root -text '\[Right]'"
    Control + b:8

  # Shift + Control + button 3 -> click button 1, then Meta+Q
  "xvkbd -text '\m1\Mq'"
    Shift + Control + b:3 + Release

  # Shift + button 4, 5, 6 or 7 -> move mouse pointer
  "xvkbd -window root -text '\x+50'"
    Shift + b:7
  "xvkbd -window root -text '\x-50'"
    Shift + b:6
  "xvkbd -window root -text '\y+50'"
    Shift + b:5
  "xvkbd -window root -text '\y-50'"
    Shift + b:4

Maybe you need to use -xsendevent option, too.

For information how to setup xbindkeys and for more examples, search the Internet with keyword xvkbd xbindkeys.

xvkbd -text vs. xvkbd -file

When sequence of keys is to be read from a file rather than the command line, we can use xvkbd -file instead of xvkbd -text.

However, you can't use xvkbd -file if you wish to use escape sequences, such as \A and \[Right] for example, in the text.

In such case, maybe you can use xvkbd -text with shell backquoting instead:

  xvkbd -text `cat filename`

Exotic characters

xvkbd 3.6 and later support -utf option, which can be used to use exotic characters such as Kanji's, Cyrillic characters, etc. with -text option. [Version 3.6]

To use -utf option, the text must be converted to UTF16 encoding:

  echo -n 'français' | iconv -f UTF8 -t UTF16 | xvkbd -utf -file -

Another possible solution maybe to put the text in the clipboard by, for example, using xclip, and then use xvkbd to trigger the paste action:

  echo something-to-be-pasted | xclip -in -selection clipboard;
  xvkbd -text '\Cv'

Current date

You can use $(date) with xvkbd to insert current date/time:

  xvkbd -no-jump-pointer -text $(date +%Y-%m-%d)

If you wish, you can use this with xbindkeys desribed above.

If the string contains exotic characters, maybe you need to use it with a trick above.

Why I can't use \ sequence in -text?

A common cause of the problem is that \ (and maybe also some other special characters) was not escaped and hence processed by the shell.

For example,

  xvkbd -text \C\A\[Left]
wouldn't work, and you need to write
  xvkbd -text '\C\A\[Left]'
or
  xvkbd -text \\C\\A\[Left\]
instead.


by Tom Sato, 2010-01-24, 2015-03-22