Archive for the ‘Hacks’ Category
if the 3.4.1 Debian wheezy gnome-shell starts up slowly for you»
I love titles like that.
Anyway, I am intensely enjoying being back in Debian-space, and I am slowly accreting small mechanisms of usefulness around me. Vim keystrokes are bleeding out everywhere. My caps lock is now a Meta key, and springs up little windows when I dance on it.
I still quite like Gnome 3, although it took a sly upgrade to the unstable version of Debian (now pretty much stable, and pretty much called Wheezy) before it was really usable.
My biggest peeve was that it took a million years to start. I knew it wasn’t doing anything useful in that time. I suspected it was something to do with my Contacts list, which is huge, tied to Google Contacts, and also not doing much that was useful. Gnome Contacts is not a particularly well-excavated place right now, and it seems like tying it to the gnome-shell was a somewhat overambitious idea. I run
strace on the gnome-shell process (as you do), and it confirmed that that was happening was that gnome-shell was excitedly counting my friends and their habits instead of doing something vaguely useful, like letting me run an application or two.
Ideally you shouldn’t mess with the internals of a debian package like this, but it’ll hopefully all be fixed by the next upgrade anyway. Here’s the patch. All it does is stick turns one line into a comment by prepending ‘//’ in front of it. You can do it by hand by
sudo nano /usr/share/gnome-shell/js/ui/overview.js and finding the ContactDisplay line below, or save the lines below and patch it with
patch -p0 < wherever_you_saved_those_linesbelow .
--- /usr/share/gnome-shell/js/ui/overview-dist.js 2012-07-20 13:12:23.564769756 -0700
+++ /usr/share/gnome-shell/js/ui/overview.js 2012-07-20 16:40:14.076527986 -0700
@@ -210,7 +210,7 @@
- this.addSearchProvider(new ContactDisplay.ContactSearchProvider());
+ // this.addSearchProvider(new ContactDisplay.ContactSearchProvider());
// Load remote search providers provided by applications
Tada! It pays to explore some of the other files in that directory, although possibly not mess with them. Gnome 3 really needs better documentation, and if I was a man with infinite time, I would greatly enjoy writing more of it up.
some rambling conversations I’ve had on moving from MacOS to Debian»
When the magic smoke escapes
Drunkenly confessing all with Brady Forrest last week:
“I’ve done an insane thing. I’m abandoning my nice MacOS laptop for Debian.”
“Was it Lion for you too?”
Liz has a Macbook Air, and loves Lion. I bought and installed it on my Macbook Pro when it came out. It has slowly, very slowly, ground away any love I had for Mac. Live by the magic, die by the magic, I guess. You screw up the aesthetics, the usability, for just a second, and the magic goes away.
Lion made the Steve Jobs magic smoke escape for me. I am a touchy, fickle, platform guy, so I really didn’t think anyone else had this problem, but since I mentioned it, everyone goes “Oh, yeah, Lion“, like they’d been warning about it in the Old Testament.
Picking over the embers of the relationship, I think the Lion’s failings are mostly down to a combination of Apple shifting to a world of SSD and not really caring what pre-SSD Macs feel like, and Lion being a short 0.1 step on a Long March to another iOS vision.
My stumbling points on that enforced march:
In my twenty-five years of MultiFinder usage, I’ve never been able to quit apps properly. When you hit Alt-Tab on any Mac I’ve been using, about seventy applications perk up, including ones that I last opened in 1989.
I know that the Appletinis at Cupertino are working on this, and in the iOS-influenced future, applications will just be murdered in a dark corner of the OS when they least expect it. But in the meantime, if I shutdown my computer or if it crashes, every one of those seventy-billion apps restart when I log back on.
On an SSD, I imagine this takes two seconds. On my Macbook Pro, it takes six weeks.
Yes, I know you can turn it off. No, that never seems to work.
I also lost a bunch of mail in an argument between Apple Mail and Microsoft Exchange. I knew this would happen if I didn’t use a known file format for my emails. I knew that backups wouldn’t work. I felt stupid for not being able to save them, like a parent who had dodged vaccinations.
Also, I spilled Coke on my keyboard.
(I want to mention this, because the coke-spilling is indubitably not Apple’s fault, and yet it played a large role in me moving on. People always retro-rationalize why they switch, be it with complex moral journeys, or damning inditements of the objective incompetence of their abandoned lover. I don’t think Apple should work harder to keep people like me who are moving to Debian over a spilled coke. I mean, what? I don’t think I’m part of some universal trend. I just want to describe where I walked, and when.)
When I bond with a computer, what I’m mostly doing is bonding with the input devices. I do it in an intensive burst at the beginning of our relationship.
Right now, I’m forcing my fingers to learn where everything is on this new keyboard, steering them away from the non-existent trackpad gestures, teaching my pinkie to find the Enter. A sizeable proportion of the reason why I stayed with Macs so long because my hands knew their keyboards.
When the coke got spilled, the keyboard response got sticky. I started just not wanting to press certain keys. And then I realised that I didn’t want to take a sticky keyboard into the Apple Store any more, either.
I wanted a new computer, and no longer wanted it to be a Mac.
In the twenty minutes I used the default install of Windows on my Thinkpad…
I somehow managed to install two IE toolbars. One was shovelware with the system (Symantec, I think), and was installed when I foolishly chose the default option for security. The other was adware installed when I downloaded BitTorrent to get hold of the Debian install CD. I don’t think Mac or Linux users realise quite how much real estate in most Windows installs is taken with branding. It’s like a screenshot from Idiocracy.
Also, it is amazing how driven the Windows user experience is by fear. Watch out for them viruses! Windows has detected that NOTHING ONTOWARD JUST HAPPENED ON DRIVE D. Click here for omg psych out!
I feel the same thing watching CNN in airports, incidentally.
On saying goodbye to Mac hardware
“My new name for you will be clattering monkey”
My but there are a lot of sticky labels with trademarks on this Thinkpad. Strange holes and posted instructions and international symbols, too. Liz tells me the keyboard is very loud, from across the room, but that’s the Thinkpad’s Model-M DNA, I expect.
I think I will come to love its clatteriness. The IPS screen is beautiful. When I realised that I could buy chargers for this thing for under $30, I almost cried (most of my Mac chargers have either burned up or snapped apart, and it’s $75 a shot). Also, I can just plug an external monitor into it without worrying that I forgot that Mac dongle again.
With the incorrect sense of affluence that saving a few bucks on power supplies gained me, I bought two different kinds of batteries for it — a slightly sticky-out one, which gives me 8-9 hours, and a flush one that gives me four. Just having options filled me with a strange glee.
It still feels a bit like I’ve borrowed a laptop from work, though.
On the X220′s aura
“So I abandoned my Macbook, and got a new laptop.
“A Thinkpad X220”
“Hahahaha! Well, that’s a surprise.”
The X220 is the default machine of the hacker types around here. I spoke to a Googler who said he’s basically holding out for his annual laptop upgrade until he can get one. The Mozilla guy I know has one. The guy who used to work at the porn site that runs out of the major San Francisco landmark has one too. He left there, but it’s his laptop, so he gets to keep it. If you have a job where you can afford it, and you’ve fallen off the Mac wagon somehow, you get an X220.
Unlike my contradictory sense that this is my work laptop, my Macbook really was paid for by work. I get to mangle this my own way. My plan, I think, is to work out a way to erase all of these brands. I was always covering up that glowing Apple: now I have to work out a way to laser-cut out the Lenovo logo. I think it’s less that I’m ashamed of who made my computer, and more that I don’t really see myself as being used to advertise it further.
Given its hipsterhacker fashionability, somebody should sell a Das Keyboard-style blank keyboard mod for the X220.
On the moral purity of Debian
Even with fashion on your side, there’s no real redemption to be found in moving from a Macbook to a Lenovo Thinkpad. Apple may throw employees off the roof at FoxConn, but Lenovo was spun out from the Chinese state. God knows what it has buried in its TPM: probably the internal organs of dissidents.
Debian, however! Oh Debian! I hope somebody somewhere a hundred years from now writes an epic poem about Debian. Later I will write* about the technical challenges of installing Debian on this X220 (there honestly weren’t much, but it did require me to dance from MacOS Lion to Debian Unstable).
- I will not remember to do this. No-one remembers what they went through to install Linux.
But, god the delight of hunkering down in the Debian commune again. I love how relentless and unsullied they are, even by Ubuntu. Are the number of official Debian developers going up or down? I can’t really tell; it’s like I never left. Could you ever kill Debian?
I’ve often said that I frequently have a mad desire to move to wooden shack and become a Debian developer. Imagine my delight when I discovered that one of my favourite Debian developers really does live in a cabin in the woods.
Is ending up in a shack really that bad, if you never have to feel lonely?
On the post-multi-national status of GNOME
While Debian has remained the same, GNOME seems transformed. I noticed this when I went to GUADEC in 2010. One always got the feeling that somebody was steering GNOME, but it wasn’t clear who. When it started, I thought it was Miguel and Nat, then Novell, then Redhat. Now it has that floaty, determined meandering that the best mass open source projects have. From a distance, everyone seems to be constantly bickering and regretting the next steps; but the steps get made, and slowly everyone adapts to them. GNOME feels like a nation now.
Or maybe even an insipidly post-national alliance of countries. Maybe it was because GUADEC was held that year in Amsterdam, but GNOME these days seems even more international than KDE, and certainly less Anglo than Windows or Apple. I get the sense that bits of it are fiefdoms, and others are more free and democratic. The corporations with an interest in GNOME get to hive off certain parts, more or less, but they still have to respond to public opinion. But there are plenty of people here because they don’t get the chance to express themselves in any other way: either because they are UX people who don’t work for Apple, or users who don’t get to use Catalan on any other platform.
This may all be wrong impressions — I will greatly enjoy discovering how wrong.
I really like GNOME 3, and the shell, even though so much of it is half-baked and unimplemented. I get to be a baker!
song for noisebridge»
It is entirely appropriate that I came from hanging out at Noisebridge today with business cards from an Applied Anthropologist and an associate from the Institute of the Future. I also got to hang out with Dan Kaminsky and Eric Butler (of Firesheep fame). I wrote some Python, sat next to others writing Python in separate rooms (and by the side of a crowd learning machine learning, if that is a sentence). I yelled at someone, which I never do, and made up. Noisebridge drama! I worked at persuading someone that throwing out someone’s entire server rack (with server) onto the streets in the middle of the weekend, was an extremely poor – but not unpermitted – choice of things to do. I marveled at the genius of visually portraying the state of the internal network by nailing it to a wall, which had been some impromptu group’s impromptu project over the same weekend.
Around me ten people learned to solder, someone rebuilt the lighting system with a clutch of borrowed TED-5000s from the great Google PowerMeter shutdown , and I talked Syrian insider politics with someone wanted to teach Scratch to local kids. I gave tours to three groups, including the Applied Anthropologist, and gave the standard pitch: a hackerspace open to all, 24/7, where there was deliberately no rules and no leadership, just decision consensus and the ever-present sudo do-ocracy.
The Applied Anthropologist seemed fascinated, although really it’s hard to tell how rivetted people are when I can’t hear them over the rattle of my own obsessive proclaiming. I sincerely hope he is interested. I’ve often craved a Noisebridge in-house anthropologist, because Noisebridge is deeply, deeply culturally weird, and needs someone to unpick how it even stays in the air.
It’s a hybrid of cold war Berlin radical politics, maker culture, defcon-with-issues emotionality, FSF/EFF idealism, and just San Franciscan High Weirdness. It’s created press passes and space projects and mushrooms and robots. It’s run like an anarchist collective, if all the anarchists were asocial individualists who try to fix problems by throwing technology at them. We put off actual anarchists, because people come to the consensus meetings with T-shirts saying “I BLOCK” and frequently improvise ad-hoc solutions with powertools. In some sort of karmic test, I once had to eject a Buddhist monk from the space.
It provokes a huge range of emotions, and not just within me. Right now, it seems like an engine for generating social ideas, both stupid and painful and inspiring and positive and strange. Lots of people burn out from it, which I totally understand; I think I have only survived this long because I am so crispy for dozens of previous burn-outs. But I watch lots of people continually burn outward from it, or who re-ignite their passions from it, or save themselves from far worse fates. Its most driven members go through huge cycles of love and hate, which I think power the place with their alternating currents. If you’re in San Francisco, I’ll give you a tour.
An Army of Adas»
I gave up picking just one woman in tech who has inspired me over the years. I certainly knew that I couldn’t list them all. Here’s a roughly chronological list, which breaks down at the end when I realise that there could be no end.
I worked a Saturday job as a teenager at an IBM dealership when I was around thirteen. The first professional programmer I’d ever met worked there. She was incredibly smart and calm, and I remember being very impressed that you could actually make a living wage coding, instead of having to hide away in your bedroom hacking up ZX Spectrum platform games until somebody mystically gave you a Jaguar.
To save time, I will now skip a little arbitrarily (hello, Verity Stob!) across a few decades.
Out of my entire generation of Net-inspired London geeks in the Nineties, Pouneh Mortazavi was the only with enough initiative to do what everybody else dreamed of: she upped sticks to San Francisco alone. First she worked at Wired, holding together their databases; thereafter she started the Flaming Lotus Girls. She was always like some George Washington of a self-collected militia, marshalling and deploying technology and resources, cajolling and inspiring.
My ex-wife, Quinn Norton, has a aircraft-carrier full of skills and virtues, but if I had to pick a technological trait I admire most in her, it would be her ability to see its historical context, as well as extropolate it into the far future (and also her Perl coding style, which is the weirdest damn thing I ever did see).
Leslie Harpold simultaneously drove up the standards of web design, usability, and common human decency online. She’s still missed.
Annalee Newitz and I worked at EFF, and shared a career in writing 1000 word pieces on 1000 year topics, before she finally ran off to join the io9 intergalactic circus and exploration unit. She’s the embodiment to me of the one of the sublime joys of technology: jumping into the deep-end with just a laptop and a head filled with implications, and asking smart questions until you know as much as the expert will admit.
Cindy Cohn, legal director, and Shari Steele, executive director, of the EFF: I simply can’t list how much you owe those two people — but free crypto, and a censorship-free US Internet is probably a good start.
Suw Charman-Anderson, the creator of Ada Lovelace Day deserves a place on this list just for that, but she’s takes her place here because of her work binding technology and civil liberties together as the co-founder of the Open Rights Group.
I suspect Valerie Aurora will be on many people’s Ada Lovelace Day lists. A kernel hacker who can write, and whose writing can make me laugh out loud or smack my head in revelation.
Liz Henry wields technology as it should be: a fire to protect what’s right, and a blast of fresh air to winnow out what’s wrong. I’ve never seen any quite so able to pounce on new tech and bring it swiftly to bear on a societal problem, as well as explain its uses to those who might otherwise be bypassed by this revolution.
Becky Hogge was ORG’s second executive director, and another forger of ideas. Astoundingly good at herding other geeks, tech wonks, and MPs into spaces where they could all understand each other.
I get far too much attention for doing one single lousy talk about “life hacking”, whereas Gina Trapani deseves all of the credit for turning a dumb idea into a a brilliant, long-lived work of real usefulness — and for cranking out the code.
On the same note, butshesagirl‘s Getting Things Done application, Tracks, got me through some tough times. I admire anyone whose managed to keep an open source project on course, but I was particularly impressed by bsag’s skills. I watched and I hope learned.
And now no time to talk about the community chops of Cait Hurley, Rachel Chalmers’ piercing analysis, Rebecca Mackinnon’s work at connecting the world, Sara Winge’s genius at O’Reilly, Anno Mitchell’s sardonic Web 2.0 charisma, Strata Chalup’s sysadmin and southbay knowledge, Kass Schmitt sailor and LISPer, Silona Bonewald’s politech savvy, Sumana Harihareswara’s geek-management hybridism, Ana Marie Cox’s snark, Cherie Matrix’s cultural vortex, Elly Millican’s web aesthetic, Wendy Grossman’s sceptical optimism, Desiree Miloshevic’s globe-trotting ICANNoclasm, the piercing tech analysis of Susan Crawford (now working at the Whitehouse!), Sarah Deutsch, Kim Plowright, Paula Le Dieu, Charlie Jane Anders, Violet Berlin, Biella Coleman, Alice Taylor, Sophie Wilson who designed my entire teenage life…
These people make the world my daughter, Ada, lives in. I’m honored she has such shoulders to climb.
This was posted as part of the Ada Lovelace Day project; if you’d like to read more, I enjoyed Liz and butshesagirl‘s entries, spent a long time thinking about this sad and all too typical story, and saved the story of En-hedu-Ana, mapper of the stars, for Ada’s next storytime:
The true woman who possesses exceeding wisdom,
She consults [employs] a tablet of lapis lazuli
She gives advice to all lands…
She measures off the heavens,
She places the measuring-cords on the earth.
actual android hacking»
Just to show that “disappointing” in my previous posts isn’t some euphemism for “die, impure heathens!”, I’ve been continuing to hack on my G1. Honestly, even if it is an impure love, I’m loving both the phone itself and the application environment. Its integration with the Eclipse IDE even managed to draw me away from Vim. You see how its corruption burns into my soul?
Anyway, for your delectation for Hello, World style programming, and also because Liz wanted it, here’s an Android application I threw together that displays an arrow that (should) always point north (it’s not very accurate, but what do you expect from a $200 compass?) (Source etc for Android Compass.)
Things I like about the SDK: it’s well-documented, and when it isn’t, you have all the source to read. I can’t overemphasise how much of a relief this is. I haven’t coded in Java in literally decades, but with enough code examples I got into the swing (ha, ancient java funny) of it fairly quickly, and also I suspect picked up bits of the Android house style.
The community is a little big fractured — I sense there was a lot of early excitement when the first SDK came out, but a lot of those developers wandered off leaving too many ghost sites). Still, there is now a lot of Android hacking going on in public, and the IRC channel remains very informative (when I wandered off into implementing something with SurfaceView instead of just plain View and then wondered why my onDraw method didn’t work, they quickly put me to rights: you don’t use onDraw with SurfaceView, and you probably don’t need SurfaceView to begin with.)
The tools to interact with the phone seem very mature to my have-not-worked-with-embedded-systems-for-a-decade eyes. I found logs where I wanted to find them (in the IDE, and by typing
adb logcat). I didn’t get the sense that Linux was a stepsister to the Windows and MacOS dev environment (and I hope that they do okay by comparison also). The emulator is a godsend, and well-integrated: when I didn’t have the phone plugged in, my code ran in the emulator. When I did, it ran on my phone. Things worked first time. I had fun, and had something to show off on my phone in an evening.
(Two gotchas that I hit when trying to produce this blog entry. I installed the java6-sun packages to run Eclipse and the SDK tools, but you have to actually select it to run rather than the openjdk on my Intrepid Ubuntu setup. Use
sudo update-alternatives --config java to pick between the two. Eclipse actually ran fine under the openjdk, but Android’s
ddms program complained a little about a GNOME Accessibility Bridge until I switched.
If you don’t want to use Sun’s Java, commenting out the single line
/etc/java-6-openjdk/accessibility.properties also lets you run
And when you’re signing your Android package (using these Germanic instructions), it turns out that you should sign the apk file in your bin directory, not the one that Eclipse handily offers to export for you. Thanks to toediggety for that obscure bug. You see? Fun!
python class Culture:»
Every Friday at EFF, we have a Python class, where anyone in the org (and a few friends from outside) join up to learn a little Python, talk about coding and share what they’ve learnt. There’s a good mix of seasoned python hackers, coders who don’t know much python, casual programmers, and people for whom this is their first experience of programming.
The part i enjoy the most (apart from congratulating myself for reaching a level of maturity that means I don’t go I KNOW I KNOW whenever i know the answer) is the material that isn’t about the technicalities of programming, but of the culture. We often discuss, for instance, about the most aesthetically pleasing way of writing code. Watching smart coders attempt to verbalise those instincts is fascinating, especially when the instincts begin to spread through the group.
To give an example, we’ve been coding up a Python version of Conway’s Game of Life. We all spent a fair bit of time discussing that niggling problem with counting up how many neighbours a cell has. Do you do it “manually”:
neighbours = cell(x-1, y-1) + cell(x, y-1) + cell(x+1, y-1) \
+ cell(x-1, y) + cell(x+1, y-1) \
+ cell(x-1, y+1) + cell(x, y+1) + cell(x+1, y+1)
for xi in [-1,0,1]:
for yi in [-1,0,1]:
if (xi or yi):
neighbour = neighbour + cell(x+xi, y+yi)
I think most coders would end up doing the first, but they would feel a bit dirty doing it, just as I always feel a bit dirty when I have x and y as attributes, instead of being able to treat them as different aspects of the same thing. It’s the right instinct to try and generalise, and it was fun seeing starter programmers expressing their mild discomfort.
After we’d got Life to work, Seth rewarded us by showing Golly, which is a great cross-platform Life simulator with many pre-programmed patterns. I really had no idea that they’d managed to code up a Turing machine in Life, let alone patterns that emulate a universal machine, running a program that runs the Game of Life.
I’ve spent today hacking with Django (well, to be accurate, I’ve been hacking on Django intermittently with eating pancakes, playing with kids in the park, and watching the whole Sarah Palin gossip trainwreck ricochet across the Internet: I honestly now have no idea what the hell is going to happen in this election).
I’ve been tracking Django since forever, but held off from doing anything too serious with it until 1.0. I’ve got a work project that fits the bill quite nicely, and I figured that a few days before 1.0′s September 2nd estimated deadline would be good enough to start hacking.
It’s been fascinating working under a codebase that is under heavy but stable development as you work. I hit bugs that I’d find in the bugtracker, filed just a few days ago, and then find them fixed while I slept. I’d also have occasional disconnects where something I’d been using in Django a few months ago had been completely reworked (mostly the admin feature), and I’d have to scramble a little to work out what had changed, and what had remained the same.
Overall, though, I’ve been really enjoying it. The changes that were made, like being able to subclass database models, seem esoteric but end up being really useful (I am uncomfortable with idea of refactoring a database schema, but it’s made much more sense to me now I can fiddle with inheritance instead of bang my head against SQL). The documentation remains first class, and has kept up with all the changes. I’m not far enough through the project to give you a realistic summary of how good a fit it is for my use, but so far, it’s been fun, at least — and it’s definitely good enough for 1.0 status.
the most useful simple script i have»
Lee’s comment that mentions having a folder for items you’re about to delete reminds me of probably the script that has most contributed to sanity in my filing system. It’s pig simple, albeit a bit scary to write and enact. All it does is delete everything in a given folder that’s over a week old.
I’ve had bad experience with handing “delete file” powers to an automatic script before, so I’ll disclaim any warranty (“TO THE EXTENT PERMITTED BY APPLICABLE LAW” as the GPL shouts), but it’s pretty straightforward, and works for me: I have it in a cronjob. The
tmp folder it cleans up is my default save folder on Firefox, and where I generally download everything. If I want to save anything longer than a week, I find it a place in the rest of my filing system. It’s sort of like having a cleaner come around every week: occasionally you go “Garr! Where’s that coffee-stained, have torn copy of last month’s New Yorker! I was going to eventually get around to reading that!”, but mostly your cruft just silently disappears without you noticing a thing.
You’ll need to replace
/home/danny/tmp with your own dumping ground. If you run it like this:
It’ll tell you what it’s planning to delete. Run it without the
-d and it really will delete those things, blam.
# clean_folder -- clean up temporary folders
# Deletes everything under a folder which hasn't been modified
# in a week. Deletes directories that are empty, too.
import os, sys, time
if (len(sys.argv) == 2) and (sys.argv == '-d'):
dryrun = True
dryrun = False
tmpdir = '/home/danny/tmp'
daysback = 7
cutofftime = time.time() - (60 * 60 * 24 * daysback)
for d in os.walk(tmpdir, topdown=False):
(dirpath, dirnames, filenames) = d
for f in filenames:
thisfile = os.path.join(dirpath, f)
if (os.lstat(thisfile).st_mtime < cutofftime):
print "I would delete:", thisfile
except OSError, (errno, strerror):
print "%s: OSError(%s): %s" % (d, errno, strerror)
for d in dirnames:
thisdir = os.path.join(dirpath, d)
if not os.listdir(thisdir):
print "I would delete:", thisfile
except OSError, (errno, strerror):
if (errno != 66):
print "%s: OSError(%s): %s" % (d, errno, strerror)
pomp; patry; gconf-watcher»
Second Circuit Judge Pierre Leval once said that the best way to know you have a mind is to change it, and I have tried to live by that wisdom… There are positions I have taken in the past I no longer hold, and some that I continue to hold. I have tried to be honest with myself: if you are not genuinely honest with yourself, you can’t learn, and if you worry about what others think of you, you will be living their version of your life and not yours.
– William Patry
I didn’t know of Bill Patry before he started blogging, but once he did, I started seeing his name everywhere. Mainly on huge multi-volume collections of hardback legal tomes, titled “PATRY ON COPYRIGHT”. He’s given up blogging because people would insist on quoting his blogging opinions as though they were an official pronouncement of his new employers, Google. Also, the current state of copyright law (and he actually contributed to drafting a chunk of it when he worked for Congress in the Nineties) depressed him too much.
Fortunately, I am never depressed by copyright, and I am confident you will never confuse my pronouncements here with any of my employers, because I have a little box down there that says so. So we are stuck with each other.
Today is column day, which means I have to save my most potentious stuff for one of said employers instead of you. It also means that I have been procrastinating all over the Net. Patry’s mum told him you must learn something new every day: today I learnt that the best way to poo-poo a fusion project is to say “Feh, you’ll never fix the Bremsstrahlung” (and the best way to help is to start a fusor in your home town). I read the best defence ever of a children’s book that has gay marriage in it, and added another Hari Seldon-style modern psychohistory attempt to my list. I also learnt that other far more esteemed columnists look exactly as bad as me on column day.
But if you wanted to know that stuff, you would have Googled for it. What you want to know is this: if I’m using GNOME, and I’m futzing about with my preferences, how can I easily note them down so that I can recreate what I’ve done when I accidentally delete my home directory (again)?
# Print out changes to the environment
import gtk, gconf
v = entry.value
return 'gconftool --set %s "%s" -t %s' % (entry.key, v.to_string(), v.type.value_nick)
return "# Couldn't understand setting %s" % entry.key
def key_changed_callback(client, cnxn_id, entry, other):
client = gconf.client_get_default()
client.notify_add('/', key_changed_callback, 1)
That’s what you were Googling for, my friend. Run this code in the background as you merrily click on Gnome options in most programs, and it’ll spit out a set of commands that if you run will recreate your clicking. Useful for finding where the hell Gnome is hiding certain preferences, or what exactly certain programs are changing behind your back. You’ll need to install
python-gtk in Ubuntu and Debian. And probably a bunch of gotchas that I have pigheadedly ignored and which you will find in the comments below from smarter, friendlier people than me.
rag and bone scripts: switchto»
So I feel a bit bad because I have two half-written long thoughtful posts, but this evening was games night at the EFF’s hollowed-out mountain headquarters, and after a bit too much Settlers of Cataan, beer, Rock Band, and beer, I strangely cannot be bothered to finish those entries. I will just repeat for the record that you have not seen rules lawyering until you have seen EFF’s litigation team play AD&D. I still admire Quinn for daring to DM them.
Anyway, instead, let me fob you off with a couple of tiny hacks I use pretty frequently on my Linux desktop.
They all gank their usefulness from wmctrl, which is a fantastic command line utility for almost any Linux desktop, and lets you control windows and focus from the command line. You can install it from that webpage, or just do
apt-get install wmctrl on Debian/Ubuntu.
# Switch to a screen or do something<br/>
if ! wmctrl -a $1; then $2; fi
I save the above script as ‘switchto’, and use it in GNOME’s keyboard shortcuts like this:
gconftool --set /apps/metacity/keybinding_commands/command_1 'switchto "Mozilla Firefox" "firefox"' -t string<br/>
gconftool --set /apps/metacity/global_keybindings/run_command_1 "<Alt>" -t string<br/>
That should set some options in the standard GNOME editor to run
switchto "Mozilla Firefox" "firefox"
whenever you hit Alt-F. It works with metacity and compiz, which is probably what you’re running with GNOME. Other desktops will have other ways to create keyboard shortcuts — I seem to remember that KDE’s one rocks.
Now, whenever I hit Alt-F on my keyboard, my desktop will switch focus to the first window it finds with “Mozilla Firefox” in its name. If it can’t find one (ie I’m not yet running Firefox), it starts it up for me. One key press gives me a Firefox window, either way. Here’s another one:
gconftool --set /apps/metacity/keybinding_commands/command_2 'switchto `zenity --entry`' -t string<br/>
gconftool --set /apps/metacity/global_keybindings/run_command_2 "<Alt>slash" -t string<br/>
This is the poor man’s QuickSilver — it pops up a box, and switches your focus to a window that matches the text you type into it. It needs a program called Zenity which comes by default on most GNOME desktops.
Actually, I don’t actually use the second of those that much, but I do have a bunch of scripts like the first, setting up command keys to always switch to certain programs like the Terminal (try
switchto "termi"), or IRC or Kontact. Your fingers quickly learn the motion, and finding your key applications even in a mass of desktops becomes instinctive.
I’ve always felt that that was the real power of QuickSilver as a window finder — Alt-Tab never lets you learn a consistent muscle memory to switch to a particular program, so you’re constantly derailing your thought by peering at icons to navigate around. I’d also encourage you to play around with
wmctrl on the command line — you may be able to think of other desktop tricks that you can turn into simple keypresses.
My employer has enough opinions of its own, without having to have mine too.