Having just written my perfect screenshot tool, I've been trying to work out how it should set itself up for use by people who are not me. Screenshots are traditionally taken by pressing the PrtSc key. So, I could do the following things:
As soon as the app is installed, make pressing PrtSc invoke the app
Pros:
- works immediately, out of the box, as expected. A user installs the app, hits PrtSc, they get the app they've just installed. Hooray.
Cons:
- unconditionally overrides any existing setup you have for PrtSc, which might be annoying
- if you uninstall the app, it won't reset PrtSc to what it was before, which is also annoying
- problematic for multiple users, because app installation runs under sudo, so how does it know which user's PrtSc setup to override? It's certainly possible to add a gconf key as part of installation, but that may be problematic if two different screenshot apps both try?
On first-run of the app, seize the PrtSc key
Pros:
- avoids the above problem of wrongly seizing other users' PrtSc keys
Cons:
- you have to run the app once manually first, which is annoying (and how do you know how to do that?)
- will still not restore the old setting if the app is uninstalled
Have a configuration dialog in the app where you configure it to seize PrtSc
Pros:
- Only seizes PrtSc for people that really want it to
Cons:
- you have to run the app once manually first, which is annoying (and how do you know how to do that?)
- you have to go into a configuration dialog to make the app actually do what it's intended to do; take screenshots when you press PrtSc. Ubuntu is past that configure-everything stage now, surely? How irritating. Not doing this!
Something else I haven't thought of
A better cleverer approach that just hasn't dawned on me yet.
Suggestions welcomed!
You could perhaps set the keyboard short cut for your app but record what was previously bound to that shortcut. Then on first run (possibly when the user presses prt sc, you could pop up a dialog that asks them something like:
Enabling them to easily get back to the previous settings if they want.
I think scenario A and C are the way to go.
You could plug into the Alternatives system and add the relevant entry to the System → Preferences → Default Applications screen, like this:
I believe that setting yourself as default on install is fine, however. Displaying a notice on first run asking each user if they want to use the previous default instead would be nice.
(Is it even possible to add a new entry in that dialog?)
I will go for a configuration dialog in the app, plus a command line script.
Both should read the previous keyboard shortcut value, store it and restore it when the user asks (or delete the value if no one was present).
The dialog should let final users adjust the behaviour. The command line script can be used by packagers to set the default behaviour according to distribution guidelines, and to make it uninstall clean (restoring the keyboard shortcuts that it grabbed).
It would. As others have said, I'd make this an option somewhere prominent in the preferences, perhaps a first-run choice-dialogue too.
But importantly, I would have it remember the setting it was changing from and store that somewhere. On uninstallation, I'd have it go through all the users and if enabled reset their print-screen keybind to whatever it was before.
The complicated bit is the post-rm script will run as root and you need to run commands as all the desktop users. I'm sure it's possible and it's by far the best solution.