void handle_key (XCape_t* self, int key_event) { if ( key_event == KeyPress ) { g_debug ("Key Pressed!\n"); key_press_cnt++; } else { g_debug ("Key Released!\n"); if ( (key_press_cnt == 1) && (super_press) ) { /*if ( (key_press_cnt == 1) ) {*/ if ( is_grabbed () ) { return ; } KeySym key_sym; key_sym = XkbKeycodeToKeysym (self->ctrl_conn, self->key, 0, 0); gchar* key_str = g_strdup_printf ("%lu", (gulong)key_sym); if ( key_str ) { gchar* cmd = g_hash_table_lookup (key_table, key_str); if ( cmd ) { if ( system (cmd) == -1 ) { g_debug ("system exec error!"); } } g_free ( key_str); } } key_press_cnt = 0; super_press = False; } }
static void exec_action (int code) { gchar *action = g_hash_table_lookup (key_table, GINT_TO_POINTER (code)); /*g_debug ("exec action: %s\n", action);*/ if (action) { if (!is_grabbed()) { g_spawn_command_line_async (action, NULL); } } }