xbindkeys-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

A fork of xbindkeys with changes for conditions hosted on github


From: Richard Sharman
Subject: A fork of xbindkeys with changes for conditions hosted on github
Date: Sat, 19 Feb 2022 00:24:35 -0800

I made some changes to xbindkeys,  too big to send as diff files, so created a repository on github.

https://github.com/sharmanr/xbindkeys


Much of the following is in the README-Conditions file that hopefully explains what and why:

I wanted a way of changing keys depending on the program running.  I’ll explain what I mean.  My fingers “know” emacs and it’s hard to use programs where some keybindings are different.  For example, in Firefox I wanted a control-b to go back a character rather than it bringing up bookmarks. On the Mac there is a really useful program, karabiner, that allows marvellous customization of keys depending what program they originated in.    I was looking for something like that for Linux. 

I figured I could use xbindkeys in conjunction with xdotool to translate a control-b to the Left character,  control-f to Right, but would not want to do that in an emacs window.  (Otherwise C-x 4 f would become C-x 4 Right;  not good!)

So, I allowed the rc file to have an optional condition line between the command and the key, e.g.

“xdotool key —clearmodifiers Left"
%EXCLUDE CLASS emacs|xterm|xedit
   control + b

Here, the test is made on the class of the window; if the condition is satisfied the command is executed.   (An alternative would be “%WHEN CLASS firefox|libreoffice” to allow specific window classes.  It can test against a window’s name or command, too.)

For guile files I added a new function, xbindkey-condition-function, that does the test itself (through new guile functions such as window-class) and optionally runs the command.  The function is to return true if the condition was satisfied (and so the command was run) else false.

There were some unexpected complications!  A small delay is needed before running the command if the command is xdotool (otherwise xbindkeys sees the key even though it hasn’t been bound and shouldn’t be getting it I think!).    Also, if the condition was not satisfied (and the command not run)  the event was lost unless the grab was synchronous.  But making it always synchronous caused problems such as lockups when debugging with gdb, so I added a way to specify in the control files to allow it.

See the man page that hopefully explains things,  and also the files in new directory Examples.  Most of them are tiny sample/demo/test programs, but there is a [guile] file emacsbindings.scm that is actually useful.

The delay is a kludge I know.  I tried various ways to try and avoid it but none worked.  

Feedback and suggestions are most welcome!

Richard Sharman  Feb 2022


reply via email to

[Prev in Thread] Current Thread [Next in Thread]