weblog d’un abbe


How is this new Blog Title ?

Filed under: Personal — abbe @ 0248

How is this new blog title ? I just wanted some cool thing, so here is what I did ? What does it look to you ?

2 years 2 days

Filed under: Personal — abbe @ 0246

It’s been 2 years 2 days since I uploaded my first open source project on internet. It was LibXMS2, still available from Geocities.com, an open source .NET library for interfacing PCs with mobile phones. It was uploaded on 28th August, 2004 from a Sify iWay. It was the result of my nearly 1 month research on deciphering SMS PDUs, reading Nokia AT Command Set specifications. Those were the days, when I don’t had any regular internet connection and I used to access internet from my Sify iWay or my Nokia 6610 black color phone via Hutch GPRS connection. That time, Hutch made their GPRS service available at monthly subscription of INR 99.00 with no usage charges ( though these days they charge for every 10Kb downloaded (like our Indian Telcos ;-) ) ).

Anyways, today I’m saying thanks to Gautam aka G0D, Saurabh aka MSN and Nikhilesh aka Nix for listening to me when I talked to them about this project. :-D

smart package manager

Filed under: Experiences — abbe @ 0215

Being a Fedora Core user, I’ve to use yum for installation, updation of software. yum is a cool package manager but it is quite irritating for me. Why ? Whenever you start yum, it implicitly checks for updates in repositories everytime you run it. That’s quite irritating if you’re on a low speed connection. I’ve used Ubuntu for some time, and used apt there. apt was my favorite package management tool, as you need to explicitly update repositories, but it is not supported very well on Fedora systems, as it need different style of repository (if I’m not mistaken).

And now few weeks back, when I was browsing Fedora Extras, I’ve seen this package manager, named smart . smart is a really smart package management system. It can connect to different kind of repositories. Currently, I’ve tried only rpm-md repositories (aka yum repositories aka RPM meta-data repositories). So, no more yumming only smarting. Its configuration is quite easy. If you’re lazy (or dumb) when it comes to editing configuration files, you can also configure it on command line ;-) . It is able to download simultaneous 2-3 files. And there is not much difference in installing packages via smart, apt-get, or yum.To install package, do :

smart install package

To remove package, do:

smart remove package

To upgrade package, do:

smart upgrade package

To reinstall a package, do:

smart reinstall package

It is currently in beta testing, but I never experienced any problems with it. Happy smarting.


Xfixes or ऍक्स-जुगाड़

Filed under: Hacking, Research — abbe @ 0335

One of my recent researches are how to monitor X clipboard. After searching for X Windows Protocol specification, I didn’t find any reference to such functionality like being notified on selection ownership. I became quite disappointed. So, I thought may be ICCCM might have something for this but then I realized that since ICCCM is a layer on top of X server, so if X server doesn’t provide anything, how is it possible for ICCCM to provide something for this.

So, I thought this functionality must be provided by some extension that plugs in to X server. So, then I headed to my first choice for finding X extensions docs, FreeDesktop.org . The first extension listed there is Xfixes . After reading its description, I realized that this is the extension I needed. Then I just did a xdpyinfo to check whether I’m running this extension or not. And yes, I’m running it already. So I then started reading its specification and wrote the following piece of code, that monitors for ownership of PRIMARY selection.

/****** look.c ******/
#include <X11/Xlib.h>
#include <X11/Xatom.h>
#include <X11/extensions/Xfixes.h>
#include <stdio.h>
#include <signal.h>

static int	running = 0;

ctrl_c(int signum)
	running = ~running;

	Display        *display;
	int		ver_major , ver_minor;
	int		evt_base  , err_base;
	XEvent		event;
	XFixesSelectionNotifyEvent *selection_event;
	char           *sz;
	Window		win;

	if (!(display = XOpenDisplay(NULL)))
		fprintf(stderr, "Error opening X display\n");
		return 1;
	if (!XFixesQueryExtension(display, &evt_base, &err_base))
		fprintf(stderr, "XFixes n/a.\n");
		return 2;
	if (!XFixesQueryVersion(display, &ver_major, &ver_minor))
		fprintf(stderr, "XFixes version not queriable.\n");
	printf("XFixes v%d.%d available with ", ver_major, ver_minor);
	printf("Event Base: 0x%x and Error Base: 0x%x\n", evt_base, err_base);

	win = XCreateWindow(display, DefaultRootWindow(display), 0, 0, 1, 1, 0, 0, InputOnly,
			    NULL, 0, NULL);

	XFixesSelectSelectionInput(display, win, XA_PRIMARY, XFixesSetSelectionOwnerNotifyMask);

	running = ~running;

	/* install a ctrl+c handler */
	signal(SIGINT, ctrl_c);

	while (running)
		XNextEvent(display, &event);
		if (event.type == XFixesSelectionNotify + evt_base)
			selection_event = (XFixesSelectionNotifyEvent *) & event;
			if (selection_event->subtype == XFixesSetSelectionOwnerNotify)
				fprintf(stderr, "\"%s\" is now owned by ", 
					(sz = XGetAtomName(display, 
				XFetchName(display, selection_event->owner, &sz);
				fprintf(stderr, "\"%s\" (WM_NAME of %d).\n",
					sz, selection_event->owner);

	XDestroyWindow(display, win);


	return 0;

 * vim:ts=4

###### Makefile #######
look: look.c
	$(CC) -o $@ $^ `pkg-config --cflags --libs x11 xfixes`
# if you're user of X11Ry where y < 7, then uncomment following line (in BSD make syntax)
# and commentabove line (in GNU make syntax)
#	$(CC) -o $@ $> -I/usr/X11R6/include -L/usr/X11R6/lib -lX11 -lXfixes

To clean shutdown the above program you need to change selection after CTRL-C in the terminal window. And to compile it, just make or gmake.Anyways, this is the extension acting as fix for this situation, that’s why it is called Xfixes (or localized in Hindi as ऍक्स-जुगाड़) ;-)


/ME ports XCB

Filed under: Hacking — Tags: , , , , — abbe @ 0229

I’ve ported XCB to FreeBSD. So if you want to try XCB on FreeBSD 6.1 grab them. If they approve it you can get it from ports. It is a quite learning experience for me like how to fix things in others source code and exporting them as patches. I’m now quite happy :-) :-D :-) :-D

Oops :-(, I’ve made a mistake (in excitement) by not giving proper subject in PRs.


X Cut-and-Paste aka X Clipboard

Filed under: Research — Tags: , , , , , — abbe @ 0240

As, I’ve completely migrated myself to Linux, few months ago and started using Linux (& FreeBSD) regularly. I find one thing quite strange (Unknown to me) in X (as I was a Microsoft Windows user in past ), i.e. Clipboard . Clipboard in X works differently and it is not integrated in X Window System. To me it looks like a hack built on top of X Window System.

What I find strange is you can also copy-paste text without explicitly copy-pasting ( i.e. no Ctrl+C + Ctrl+V or Edit|Copy + Edit|Paste ) text. You just select the text from source window, and middle click on the destination window, text will get copied implicitly and pasted. And if you’ve already copied some text previously via explicit copy it is also retained (not destroyed) after implicit copy. Isn’t this interesting.

Well more details can be found on jwz‘s article titled X Selections, Cut Buffers, and Kill Rings. Inspired from his article, I’ve wrote the following C program (requires Xlib) which currently just prints the WM_NAME property of the window currently owning the specific selections.

 * clip.c
 * to compile and link (on X11R7): cc -o clip clip.c -lX11
 * to compile and link (on X11R6): cc -o clip clip.c -L/usr/X11R6/lib{libsuffix} -I/usr/X11R6/include -lX11
 * where libsuffix is 32 or 64 or 128 ( I wish I will get a chance to compile on this architecture ) 
 * depending on your machine word size.
#include <stdio.h>
#include <stdlib.h>

#include <X11/Xlib.h>

#define s_PRIMARY   "PRIMARY"

static Atom get_atom(Display*, const char*);
static void print_stuff0(Display*, Atom);

  Atom a_Primary, a_Clipboard;
  Display* display = NULL;
  char* display_name = NULL;
  char* window_name = NULL;
  Window win;

  if(!(display = XOpenDisplay(display_name)))
      fprintf(stderr, "Error opening %s\n", XDisplayName(display_name));
      return 0;

  a_Primary = get_atom(display, s_PRIMARY);
  a_Clipboard = get_atom(display, s_CLIPBOARD);

  print_stuff0(display, a_Primary);
  print_stuff0(display, a_Clipboard);


print_stuff0(Display* display, Atom atom)
  Window win;
  char* window_name;
  char* atom_name;

  atom_name = XGetAtomName(display, atom);

  if((win = XGetSelectionOwner(display, atom)) != None)

      XFetchName(display, win, &window_name);
      printf("\"%s\" (WM_NAME of %ld) owns selection of \"%s\" atom.\n", window_name, win, atom_name);
      printf("No body owns selection \"%s\"\n", atom_name);


get_atom(Display* display, const char* atom)
  Atom a;
  if((a = XInternAtom(display, atom, True)) == None)
      fprintf(stderr, "Oops, \"%s\" atom doesn't exists.\n", atom);

  return a;


jwz aka Jamie W. Zawinski hacked most of the XScreenSaver stuff and he also contributed to projects like Mozilla, XEmacs etc. The articles on his website and homepage of his website are really cool :-). Just bookmark it.

Create a free website or blog at WordPress.com.