Tags:
create new tag
, view all tags
I've been looking for a keyboard macro facility in X for quite a while. The most promising short term solution possibility I've found is xvkbd (suggested by Ivan Pascal in a note on Bug 43).


Checkout Xkeyboard, written as part of Midori Linux, so far it's the best virtual keyboard I've found. http://tinycode.com/xkeyboard-0.2.tar.gz and http://nathanlaredo.com/ for the author. I suspect adding macros to this would be pretty easy to do. Works great for me with all sorts of X apps, on a tablet. -- SethCohn

See also:

Note: The main reason I'm digging into X is to find or create a keyboard macro facility. I've got related information scattered among quite a few pages, including:

I've also got some more general information / pages on X:

And, some pages related to using X remotely:

See:

Contents

Notes

The most promising short term solution possibility I've found is xvkbd (suggested by Ivan Pascal in a note on Bug 43). It is not the approach I envisioned -- it is a keyboard emulator — it displays a keyboard on the screen and sends key events to the current application (the application with the current focus) as you click the keys and it can have arbitrary strings assigned to the function keys (or almost any other key). It's also a small tar file. Tentative plan:

  • Download, compile, install, and play with it -- confirm that it works with my "usual" applications:
    • Mozilla
    • nedit
    • konqueror (all kde applications)
    • AbiWord
    • Gnumeric
    • joe, jstar, vi
  • Consider modifying it (or suggesting modifications to the developer) to work with the "real" keyboard (like string assigned to <ctrl><alt>s on the real keyboard)
  • I'll also write to Tom Sato (the developer of xvkbd) to see if he's thought about doing this (or whatever else he can suggest)

Update: Found gtkeyboard and an rpm for it in Mandrake 9.0 and installed it. So far it works at the bash prompt in konsole, and in nedit and vim started from there. Does not work in Mozilla, konqueror (that is, a text edit window like used for updating TWiki wink or the address bar), or kmail (specifically composer).

Next Update:

I got a prompt response from David Allen, author of gtkeyboard. (Thanks, David!) If I understand his answer (and he's right) it looks like gtkeyboard (and probably xvkbd) will not work with Mozilla, and probably will not work with kde applications unless there is a user level setting somewhere to get kde applications to accept SendEvents from other applications.

Sooo, it looks like I'm back to thinking about a modification to the X server. Maybe I can put that on my next 5 year plan -- my current five year plan includes making collapsible outlining work in AbiWord. wink

His answer did point at some security issues, like suppose someone gets control of my keyboard thingie and issues something like an "rm -r" or whatever. I'll try to think about that, but:

  1. it sounds no worse than if they actually get control of my keyboard, remotely somehow
  2. maybe that even argues for making the modification in the X server -- maybe that is as (or almost as) secure as my physical keyboard

Anyway, other thoughts, hints, etc. welcome at any time.

I'll put his explanation (or maybe his whole email) below.

I also got a prompt reply from Tom Sato -- not much to add -- he thinks xvkbd should work with Mozilla and kde programs, but offered no suggestions on what to do to make it work with them. Oops, wait -- he did mention that there should be no major problem implementing shortcuts with combinations of the modifier keys -- he didn't do it because he didn't think there was a need.

Note that xvkbd has some limitations on the programs it can work with — see xvkbd - Possible Problems and Solutions and the "More Informations --> Notes" section on xvkbd - virtual keyboard for X window system. (For some applications (like xterm and kterm) certain options must be set, it won't work with XView based applications, if "Alt or Meta is not defined as modifier, the key can't be used as modifier ... You can use `xmodmap -pm' to check how modifiers are defined", ...)

Quoting some of the limitations from that page note that there are potential workarounds:

XView-based clients Normally, XView-based clients (such as DeskSet tools in OpenWindows) will not accept input from xvkbd. You may avoid this restriction by invoking those clients with -WS (or -defeateventsecurity) option, like ``cmdtool -WS''.

Other Clients There may be other clients which will not work with xvkbd. The main cause is the client can be coded so that it will ignore events from other clients.

Also, it currently only works with four modifier keys (see below) and not combinations of them: oops, wrong about that, it apparently does work for some combinations -- didn't read carefully enough

F1 text for F1
F2 text for F2
s:F1 text for Shift-F1
c:F1 text for Control-F1
m:F1 text for Meta-F1
a:F1 text for Alt-F1

Finally(??), there is a word completion feature that may be of value -- it might even be modified to become a text completion feature (sentences, paragraphs, books wink ).

Reminds me of my old question — what is the meta key — is that a Windows agnostic way of referring to the Windows key?

Email from David Allen (Excerpts)

With the comments in my reply to him (9 Apr 2003).

> There are two reasons why sometimes keypress redirecting won't work. The first is that some applications (notably a lot of KDE stuff) is explicitly written to disallow what gtkeyboard is trying to do for security reasons. (Imagine somebody writing a program that automatically entered the keypresses "rm -rf /\n" into your shell window without asking) For example, try loading the xterm program, it actually has a setting through a menu called "Allow SendEvents" which toggles whether or not this is allowed.

It sounds like I might get gtkeyboard to work with kde if the disallowing for security reason is done in some user changable manner (config file or similar). So, I'm walking away thinking of kde as a "maybe" at this point in time.

> The second reason that it sometimes doesn't work is because X has a concept of mouse focus, and keyboard focus. Keyboard focus determines where the button presses go. For example in mozilla, if you highlighted the "home" button and pressed the L key, nothing would happen because L doesn't mean anything in that focus "context". Getting the application and the window manager to collaborate to make sure the keyboard focus is in the right place is not always easy. This is why some applications (specifically mozilla) that have complicated nested widgets won't work. It actually does work, it's just that the keyboard focus isn't where you are expecting it to be, so instead of the keypress going into the location bar like you would expect, it might go somewhere else where the effect is that nothing happens. smile

Ok, it sounds like Mozilla is a lost cause -- or am I missing something?

Resources

See ResourceRecommendations. Feel free to add additional resources to these lists, but please follow the guidelines on ResourceRecommendations including ResourceRecommendations#Guidelines_for_Rating_Resources.

Recommended

Contributors

  • () RandyKramer - 08 Apr 2003
  • If you edit this page: add your name here; move this to the next line; and include your comment marker (initials), if you have created one, in parenthesis before your WikiName.

Page Ratings

Edit | Attach | Watch | Print version | History: r7 < r6 < r5 < r4 < r3 | Backlinks | Raw View | Raw edit | More topic actions
Topic revision: r7 - 2004-03-25 - SethCohn
 
  • Learn about TWiki  
  • Download TWiki
This site is powered by the TWiki collaboration platform Powered by PerlCopyright 1999-2017 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding WikiLearn? WebBottomBar">Send feedback
See TWiki's New Look