Wandering Thoughts archives

2013-08-29

A new piece of my environment: clearing the X selection

I've mentioned before that one of my little twitches is keeping my X selection empty so that I don't have any accidents with accidental pastes. For a long time I'd often do this by starting a new xterm, selecting a space, and then closing the xterm again. I was recently fiddling with my FVWM menus when it occurred to me that this was a crazy way of clearing the X selection and I should be able to do better.

So now I have a little script that clears the X selection and along with it a menu item that is called simply 'Clear' to run the script. Instead of going through a whole rigmarole with xterms I can just fidget with this by popping up the relevant menu and selecting it. I can't say that this exactly saves me time (this is a reflexive twitch), but it does make the whole thing less distracting because it's over faster and it makes me feel better about it. In retrospect I should have done this years ago.

(It also makes me happier. For all that I didn't think of the whole old rigmarole as any particular burden, I think it actually was and I just didn't notice it. There is probably a lesson to be learned here about other aspects of my environment but the problem is that these things are 'fish in water' issues; I'm probably not going to notice them until after I stumble into a fix.)

The script itself is:

#!/bin/sh
xsel -c
xcb -s 0 </dev/null

(This should probably also have 'xsel -c -b' to clear the clipboard selection too. So far I haven't needed that; programs like xterm ignore the clipboard if the primary selection and the cut buffer are empty.)

xsel is probably packaged for your Linux distribution. I had to compile xcb from source, but it's not exactly a big program.

(You need two programs because X has two separate selection systems. It's a long story.)

sysadmin/ToolsClear written at 04:28:22; Add Comment


Page tools: See As Normal.
Search:
Login: Password:
Atom Syndication: Recent Pages, Recent Comments.

This dinky wiki is brought to you by the Insane Hackers Guild, Python sub-branch.