Showing posts with label gnome-screenshot. Show all posts
Showing posts with label gnome-screenshot. Show all posts

10 June 2012

184. Fixing Gnome screenshot (3.4.1) in Debian Wheezy by patching and compiling

Approach
Putting a hold on gnome-screenshot forever will likely prevent gnome from upgrading properly since I'd suspect it's a required dependency.

Clarification: this fix restores the original behaviour. gnome-screenshot --interactive is NOT an acceptable solution. This guide restores gnome-screenshot to it's good old functional state.

So, time to build our own gnome-screenshot -- but one which actually works in a reasonable way. The gnome-screenshot cockup is just another sign that something is clearly amiss with the way gnome is being developed. And this, if true, is another truly idiotic 'feature' -- turn gnome into windows? Most of us left for a reason...

Anyway, linux is still sane though -- if we don't like something we're not entirely up a creek, which will buy us a bit more time while we're getting ready to move to xmonad  -- or for debian to move away from not making downstreams changes to gnome.

We have two options:
Either look here: http://git.gnome.org/browse/gnome-screenshot/commit/?id=3bbc1e158fd58ec7f4f984f6d3c15ec95e65a035&ignorews=1 and try to come up with your own way of reverting the crippling.

Or use the ubuntu patches as a guide: http://packages.ubuntu.com/precise/gnome-screenshot

Normally you shouldn't mix ubuntu and debian packages, and we won't: we'll be compiling our own package, but using the work done by the ubuntu maintainers.

In particular, look at this: http://archive.ubuntu.com/ubuntu/pool/main/g/gnome-screenshot/gnome-screenshot_3.4.1-0ubuntu1.debian.tar.gz

Look in the debian/patches directory and you'll find the ubuntu_interative_screenshots.patch

Building:
sudo apt-get install libgtk-3-dev libcanberra-gtk3-dev intltool
wget http://ftp.de.debian.org/debian/pool/main/g/gnome-screenshot/gnome-screenshot_3.4.1.orig.tar.xz
tar xvf gnome-screenshot_3.4.1.orig.tar.xz
cd gnome-screenshot-3.4.1/src

You can wget http://archive.ubuntu.com/ubuntu/pool/main/g/gnome-screenshot/gnome-screenshot_3.4.1-0ubuntu1.debian.tar.gz and untar it to look at the debian/patches/ubuntu_interactive_screenshots.patch, which what we do below is based on:

In the ubuntu patch there's a test to see whether unity is used. We'll do it a bit cruder -- we'll just make sure the condition is always true by testing for 0<1.


Edit src/screenshot-application.c and change the part in red

130 static void
131 save_pixbuf_handle_error (ScreenshotApplication *self,
132                           GError *error)
133 {
134   if (screenshot_config->interactive)
135     {
136       ScreenshotDialog *dialog = self->priv->dialog;
137       GtkWidget *toplevel = screenshot_dialog_get_toplevel (dialog);
138 
139       screenshot_dialog_set_busy (dialog, FALSE);
to

134   if (0 < 1)

Also, change

348   screenshot_play_sound_effect ("screen-capture", _("Screenshot taken"));
349 
350   if (screenshot_config->interactive)
351     {
352       self->priv->dialog = screenshot_dialog_new (self->priv->screenshot, self->priv->save_uri);
353       toplevel = screenshot_dialog_get_toplevel (self->priv->dialog);
354       gtk_widget_show (toplevel);
to


350   if (0 < 1 )

Time to build!
./configure --prefix=${HOME}/.gsc --program-suffix=.debugged
make
make install

Note: the install prefix here works fine for a single-user desktop. If you want everyone to be able to use our shiny new gnome-screenshot, put everything in /usr/bin instead.

We now have a working gnome screenshot in ~/.gsc that behaves as intended.
tree -L 2 -d
.
|-- bin
`-- share
    |-- applications
    |-- GConf
    |-- glib-2.0
    |-- gnome-screenshot
    |-- locale
    `-- man


 However, we need to make sure our fixed gnome-screenshot gets invoked.

In Gnome Shell 3.2.X
sudo apt-get install gconf-editor
Start gconf-editor
go to /apps/metacity/keybinding_commands/command_screenshot
change to e.g.  /home/verahill/.gsc/bin/gnome-screenshot.debugged
Also, change command_window_screenshot to
/home/verahill/.gsc/bin/gnome-screenshot.debugged --window

Note: defining Print/Alt+print keyboard shortcuts the 'gnome-shell' way (i.e. via system-settings) doesn't seem to work in gnome 3.2. Conversely, doing it the gconf-editor way in gnome 3.4 doesn't work.


In Gnome Shell 3.4.X
Go to System Settings, Keyboard, Shortcuts
Disable the automatically defined shortcuts for gnome-screenshot

And add your own under custom shortcuts:




Done! 
Unless you want to add to PATH in which case you can put this in your ~/.bashrc:
export PATH=$PATH:${HOME}/.gsc/bin




Note: If it's still not working, try to launch from the terminal. If you get
(gnome-screenshot.debugged:7493): GLib-GIO-ERROR **: Settings schema 'org.gnome.gnome-screenshot' does not contain a key named 'auto-save-directory'
Trace/breakpoint trap
it's because you had the old, good gnome-screenshot. 
sudo su
echo "gnome-screenshot install"|dpkg --set-selections
exit
sudo apt-get install gnome-screenshot

Now try
gsettings get org.gnome.gnome-screenshot auto-save-directory
which should be empty.

gsettings set org.gnome.gnome-screenshot auto-save-directory '/home/verahill/Pictures'

Finally, make sure to re-set your keybindings.



Links to this post:
http://qfox.nl/notes/153

03 May 2012

131. Sort of Fixed: Gnome-screenshot (3.4.1) broken in debian testing -- how to fix it

UPDATE 9/6/2012: It's becoming incrasingly difficult to revert back to the old version of gnome-screenshot, hence the changed title of the post. I can't believe the gnome-screenshot hasn't been reverted back to a more sane behaviour -- any behaviour that leads to a score of bug reports (remember that there's a lot of self-censorship as few people submit bug reports even if they encounter a bug) is highly undesirable. I would not include screenshot in my posts if I hadn't already put a hold on my gnome-screenshot package. Anyway, keep an eye on this one for (a lack of) updates: https://bugzilla.gnome.org/show_bug.cgi?id=669629

Original post
Something weird happened after the updates today (http://verahill.blogspot.com.au/2012/05/todays-3rd-of-may-2012-debian.html). When taking screenshots I didn't get a save dialogue.

I naturally presumed this to be a crippling bug:

gnome-screenshot

** (gnome-screenshot:8520): WARNING **: Unable to use GNOME Shell's builtin screenshot interface, resorting to fallback X11. Error: GDBus.Error:org.freedesktop.DBus.Error.Failed: Error: Expected type utf8 for Argument 'filename' but got type 'boolean' (nil)
After reading bug reports I noticed that a new screenshot shows up in the ~/Pictures folder -- but you get no dialogue re saving and name etc, so I might be forgiven for thinking that it didn't work at all. Yet, something was clearly out of whack.

Yes. The broken behaviour is a design feature. It's idiotic.

I like gnome-shell now that I've customized it. But seriously, what the gnome devs want as default behaviour can only be considered as broken behaviour by any long term desktop user. This new behaviour is idiotic and will only benefit those who don't use screenshot very often  -- those who do will definitely want control over where screenshots are saved and under what names.

The worst, intended 'solution':
If I would guess at the intentions of the gnome dev/s, they'd suggest you map your print scrn key to gnome-screenshot -i. This brings up a dialogue. Asking you to select full screen, window or area. You can then click on take screen shot, and you then get the save dialogue. Suddenly it got a lot less convenient. Something that was quick and easy now has become clunky.

The better solution:
I used the snapshot archive:

1. Download the previous version, e.g. 
wget http://snapshot.debian.org/archive/debian/20120313T034114Z/pool/main/g/gnome-utils/gnome-screenshot_3.2.1-3_amd64.deb

2. And install
 sudo dpkg -i gnome-screenshot_3.2.1-3_amd64.deb 
dpkg: warning: downgrading gnome-screenshot from 3.4.1-1 to 3.2.1-3.
3. Prevent the package from being upgraded again:
sudo su
echo "gnome-screenshot hold"|dpkg --set-selections

The behaviour should now be back to usable.

This post contained no screenshots. For obvious reasons.

Links to this post:
http://qfox.nl/notes/153