Working in an office with lots of windows, I get a great view, but I often have trouble finding the mouse cursor. I needed larger, more contrasty mouse cursors.
I found that there isn't a lot of documentation on how to change X cursors. So here's what I've learned:
Debian has a package called big-cursor, so I tried that first. Installing it, and restarting X, made all the cursors much bigger. So far so good -- except in a lot of cases they were really TOO big. I couldn't see where I was pointing in apps like Firefox. And they were still just black and white, no more contrasty than before. Worse, it offers no way to enable or disable it easily. It simply replaces all the default cursors with larger version of themselves. Better than nothing, but I wasn't satisfied.
Once I discovered the existence of "cursor themes",
aptitude search cursor | grep theme gave me a list
of themes I could install with apt-get. I uninstalled big-cursor and
installed a few of them. But none of them came with instructions on
how to install them or preview them.
Some web searching suggested
$ mkdir -p ~/.icons/default $ ln -s /etc/X11/cursors/THEMENAME.theme ~/.icons/default/index.themefor whatever THEMENAME I wanted to try. So I tried that, and restarted X. Sure enough: all the cursors changed.
But the packages I'd chosen had installed 101 different .theme files, and I sure didn't want to have to restart X for all of them. Fortunately, a little experimenting showed that I didn't actually have to restart X; just restarting my window manager was enough. Fortunately openbox has a nice command-line way to do that, which was enough to let me write a little zsh shell function to loop over each theme, print the theme name, switch to that theme and wait for me to hit return before continuing to the next theme:
foreach theme (/etc/X11/cursors/*.theme) basename $theme rm ~/.icons/default/index.theme ln -s $theme ~/.icons/default/index.theme openbox --restart read end
Nice! I quickly decided that ComixCursors-Opaque-Blue was the most contrasty for the sorts of windows and backgrounds I run, as well as being colorful and generally nice looking.
But I wasn't fully happy with it. For one thing, the cursors in some
windows, notably emacs and firefox, were HUGE. And other apps, like
xterm, didn't show any cursor change at all -- despite
ComixCursors-Opaque-Blue having a cursor specificall called xterm
when I looked at its cursor files in
/usr/share/icons/ComixCursors-Opaque-Blue/cursors (which I
learned about via
dpkg -L comixcursors-righthanded-opaque).
Now my goal was to learn how to modify specific cursors.
Let's start with that file
(which is a symlink to a file named text in the same directory).
says "X11 cursor". Is there a way to edit one of these files?
Google was no help, so I tried loading it in GIMP. Success! GIMP
showed it as a file with four layers -- four different sizes of the
same cursor, with the smallest size on top. I made a change and exported
it, and used GIMP's "Select File Type" expander to discover the "X11
Mouse Cursor" type, with .xmc as an extension.
GIMP refuses to save without the extension, so after modifying the file,
I had to save it as xterm.xmc or text.xmc, then rename it in the shell.
However, modifying the cursors in the file named "text" had no effect on the cursors shown in xterm windows -- or on the I-beam cursor inside Firefox or emacs, either. So much for that idea.
I did a lot of searching with no clear answer, but somewhere along the line I stumbled upon a reference to cursor themes specified in ~/.gtkrc-2.0. I know Firefox uses GTK, and I already have that file, in order to specify other items like
gtk-key-theme-name = "Emacs" gtk-entry-select-on-focus = 0 gtk-cursor-blink = 0so I edited the file and added these two lines:
Then I restarted openbox. Voilà! Now Firefox's default cursor was smaller, and its text cursor followed the text cursor specified by the theme.
The weird thing was, Emacs, too, had changed in the same way. It turned out the default emacs on Debian is built with GTK, so it follows the cursor themes specified in the GTK settings.
Note: if you use a GTK settings manager, editing .gtkrc-2.0 probably won't do anything. You may have to run something like gconftool in order to make changes.
Not only is there a theme specified, there's also a size. Remember how the ComixCursors files I opened in GIMP had four different sizes? I'd been wondering how to specify different cursors. Now, at least for GTK apps, I had a way of specifying a size -- and that size can be different from the size that non-GTK apps are using.
As far as I can tell without documentation, the four sizes correspond to size specifiers of 16, 32, 48 and 64, and both X and GTK will default to the largest size if you don't specify otherwise.
Not all sets of cursors are scalable; some apparently have only one size. But many of the cursor themes include scalable cursor images.
But how could I get non-GTK apps to use a different size?
Remember all that deleting and symlinking I had to do while I was testing various cursor themes? It turns out, at least for non-GTK apps that pay attention to X resources, that you don't need to do that. I just needed to add these lines to my .Xdefaults file:
Xcursor.theme: default Xcursor.size: 48
And, indeed, that's the answer for how to get non-GTK apps to use a different size of cursor. At least for the root window, and for apps that pay any attention to the Xcursor theme.
The theme name is specified here as "default" because I've made the symlink to ~/.icons/default, where I've made local copies of the icons so I can modify them with GIMP. But I could just as well use a name like ComixCursors-Opaque-Blue there.
While all this was going on, I was hanging out on #emacs -- they didn't know anything about cursor themes or how to specify a specific cursor in emacs. Outside of text areas, emacs is still using the default cursor -- the same one used on the root window -- and I haven't found any way to change that.
But when emacs started getting segmentation faults while I experimented with some sample theme files I'd found on the web, the folks in #emacs informed me that the GTK emacs front-end is prone to be crashy, and that there's another back-end called "luckd" which is much more solid.
"Lucid" is the company that used to put out an Emacs variant called Xemacs, but emacs-lucid is not the same as Xemacs; it's regular GNU emacs with a different X front end. I'd been having problems with emacs crashing in other contexts (it crashes every time I shut my machine down, if I don't close emacs with C-x C-c first) so I tried Debian's emacs24-lucid package. Sure enough, it isn't as crashy. It seems to get its cursor theme frmm X resources, not from .gtkrc-2.0.
I spent a long time searching for information on xterm and fiddling with X resource settings, but it was no use. Nothing I did made xterm take any notice of the cursor theme.
But I did manage to make xterm's own I-beam cursor stand out quite a bit more, with these X resources:
XTerm*pointerColor: blue XTerm*pointerColorBackground: red
You can also change the pointer shape -- but apparently only to shapes specified in the X cursor font, not to other icons loaded as part of a cursor theme:
XTerm*pointerShape: double_arrowThe default I-beam cursor is called "xterm", and some other options that might be usable for text are "diamond_cross" and "fleur". But I decided I was okay with the I-beam "xterm" cursor as long as I could thicken it and change the color with pointerColorBackground.
So that's it: everything I know at this point about X cursor themes. I still have a lot of unanswered questions. In particular, I'd really love to be able to specify a themed cursor for xterm windows, and for non text areas in emacs and firefox. But at least for now, I have a great big bright blue mouse cursor that I can easily see, even when I have my big picture windows open and the light streaming in.