Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Keyboard shortcut in GnomeICU
View unanswered posts
View posts from last 24 hours

Reply to topic    Gentoo Forums Forum Index Documentation, Tips & Tricks
View previous topic :: View next topic  
Author Message

Joined: 19 Jan 2003
Posts: 2
Location: Salvador/Brazil

PostPosted: Sun Jan 19, 2003 4:49 am    Post subject: Keyboard shortcut in GnomeICU Reply with quote

One thing i always missed in gnomeicu or any other icq clone in linux was keyboard shortcut ( ctrl + shift + i for pop a msg, ctrl + shift + a for pop contact list). In fact i really _hate_ to leave keyboard to just click in the applet and come back to keyboard to answer. Here is a little hack in C solving this (by now).


/* A little hack to send commands to gnomeICU.
 *  This code is borrowed heavily (read: cut&paste) from gnomeicu-applet.
 *   Thanks Jeremy.
 *  This program is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; either version 2 of the License, or
 *  (at your option) any later version.
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  GNU General Public License for more details.
 *  You should have received a copy of the GNU General Public License
 *  along with this program; if not, write to the Free Software
 *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.

#include <glib.h>
#include <string.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/un.h>
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
#include <pwd.h>
#include <netinet/in.h>

void usage(char *name)

   printf("* Usage: %s command\n");
   printf("* Some useful commands: show, hide, showhide, readevent\n");
   printf("* See README for more commands\n");

int main(int argc, char **argv)
   gint socket_fd, cmdlen = 0, i;
   gulong   u;
   gchar c = 1;
   gchar *command;
   struct passwd   *pw;
   char *user;
   struct sockaddr_un addr;

   if(argc == 1)
      for(i = 1; i < argc; i++)
         cmdlen += strlen(argv[i]) + 1;

      command = malloc(sizeof(gchar) * cmdlen);
      command[0] = '\0';
      for(i = 1; i < argc; i++)
         strcat (command, argv[i]);

   /* gnomeicu_applet_control_connect */
   pw = getpwuid (getuid ());
   if (!pw) {
      fprintf (stderr, "Unable to get current login name, naming service down?\n");
      return (-1);

   user = strdup (pw->pw_name);

   sprintf (addr.sun_path, "/tmp/.gnomeicu-%s/ctl", user);
   addr.sun_family = AF_UNIX;

   if(access(addr.sun_path, F_OK) != 0)
      return -1;
   socket_fd = socket(AF_UNIX, SOCK_STREAM, 0);

   if(socket_fd >= 0) {
      if(connect(socket_fd, (struct sockaddr *)&addr, sizeof(addr.sun_family) + strlen(addr.sun_path) + 1) != 0)
            return -1;
      perror ("socket");
      return -1;

   /* gnomeicu_applet_control_send_command */
   u = htonl (strlen (command)+1);

   write (socket_fd, &c, 1);
   write (socket_fd, &u, sizeof (gulong));
   write (socket_fd, command, strlen (command)+1);

   return 0;

Sorry, but no README yet. but most useful commands are showhide (show or hide contact list), readevent (pop incoming events) and msg <uin> <text> (send a msg to someone). try "grep COMMAND gnomeicu-0.98.123/src/userserver.c " to list all commands.

Compile it with:
 gcc  -o icucmd keyboard.c `pkg-config --libs --cflags-only-I glib-2.0`

Infaithful: "but it's just a command-line app. where's keyboard shortcut?"

Just put your window manager to execute it. In metacity:

gconftool-2 -s --type=string /apps/metacity/keybinding_commands/command_1 "icucmd  showhide"
gconftool-2 -s --type=string /apps/metacity/global_keybindings/run_command_1 "<Control><Shift>a"

Repeat that changing command, command number and shortcut if you want (i did for "<Control><Shift>i" pop msgs). and never let you hands left your keyboard again. :P
Back to top
View user's profile Send private message
Tux's lil' helper
Tux's lil' helper

Joined: 12 Oct 2002
Posts: 96

PostPosted: Mon Feb 03, 2003 3:52 pm    Post subject: Reply with quote


I'm using this with fluxbox shortcuts, works fine :)

Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Documentation, Tips & Tricks All times are GMT
Page 1 of 1

Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum