Comment 2 for bug 1472912

Revision history for this message
moma (osmoma) wrote :

Just a comment.

Libkeybinder library could be used to implement a global hotkey for audio-recorder.
Ref: https://github.com/kupferlauncher/keybinder

There is a a simple example that uses keybinder.
Compile the code (test1.c) with:

$ gcc test1.c $(pkg-config --libs --cflags gtk+-3.0) $(pkg-config --libs --cflags keybinder-3.0) -o test1

Run it:
$ ./test1

/* Code of test1.c
 * Created in 2010 by Ulrik Sverdrup <email address hidden>
 * This work is placed in the public domain.
   https://github.com/kupferlauncher/keybinder/blob/master/examples/main.c
*/

#include <stdio.h>

#include <gtk/gtk.h>
#include <keybinder.h>

#define EXAMPLE_KEY "<Ctrl>A"

void handler (const char *keystring, void *user_data) {
  printf("Handle %s (%p)!\n", keystring, user_data);
  keybinder_unbind(keystring, handler);
  gtk_main_quit();
}

int main (int argc, char *argv[]) {
  gtk_init(&argc, &argv);

  keybinder_init();
  keybinder_bind(EXAMPLE_KEY, handler, NULL);
  printf("Press " EXAMPLE_KEY " to activate keybinding and quit\n");

  gtk_main();
  return 0;
}