Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Taking screenshots of an area doesn't work via keyboard shortcut #37

Open
silviucc opened this issue Oct 10, 2013 · 32 comments
Open

Taking screenshots of an area doesn't work via keyboard shortcut #37

silviucc opened this issue Oct 10, 2013 · 32 comments

Comments

@silviucc
Copy link

silviucc commented Oct 10, 2013

I'm trying to create a custom keyboard shortcut that invokes mate-screenshot with the option to select only an area of the screen. This should mean invoking the command with the -a or --area switch but it only works in a terminal. If I try to create the keyboard shortcut it always takes a screenshot of the whole screen. Does not allow me to select any area.

The workaround was to use the -i option which allows me to select what I want to do, but still, it looks like a bug.

Using Mate 1.6 on Manjaro 64bit.

--- Want to back this issue? **[Post a bounty on it!](https://www.bountysource.com/issues/4782493-taking-screenshots-of-an-area-doesn-t-work-via-keyboard-shortcut?utm_campaign=plugin&utm_content=tracker%2F1509859&utm_medium=issues&utm_source=github)** We accept bounties via [Bountysource](https://www.bountysource.com/?utm_campaign=plugin&utm_content=tracker%2F1509859&utm_medium=issues&utm_source=github).
@flexiondotorg
Copy link
Member

I've just tested this on an up to date Arch Linux install and mate-screenshot -a works as it should. Are you using the MATE packages repository?

Bring you system up to date and test again please.

@infirit
Copy link
Contributor

infirit commented Nov 8, 2013

I have this as well on Gentoo. gnome-screenshot also appears to suffer from this. https://bugs.launchpad.net/ubuntu/+source/gnome-utils/+bug/549935

@silviucc
Copy link
Author

silviucc commented Nov 8, 2013

MATE on Manjaro is pulled directly from the repo indicated on the page you linked to, so I'm up to date and I can still reproduce the bug :/

@nivoc
Copy link

nivoc commented Sep 25, 2014

have the bug too - mate 1.8

@N0rbert
Copy link

N0rbert commented Nov 26, 2014

I can reproduce the bug in Ubuntu 12.04.5 with MATE PPAs - the mate-screenshot version is from package mate-utils 1.8.0+dfsg1-4~ppa1~precise1.
mate-screenshot -a works as expected from terminal, but does not work if I set custom shortcut (Ctrl+PrintScreen) to that command.
When launched from terminal mate-screenshot -a makes screenshot with light-blue selection rectangle. It is incorrect.

It seems that the shortcut problem is caused by wrong focus. I can't determine how to get expected behaviour.

The custom shortcut (Alt+PrintScreen) for screenshot of a window (with mate-screenshot -w) works as expected, but sometimes takes screenshot of "Save Screenshot" window (I can open another issue for this).

@monsta
Copy link
Contributor

monsta commented Aug 21, 2015

Does it still happen in 1.10?

@martin-bts
Copy link

@monsta: yes, it does

Package: mate-utils
Version: 1.10.3-1

in Ubuntu Wily

@martin-bts
Copy link

It's a timing issue!
I created a /usr/local/bin/mate-screenshot which looks like this:

#!/bin/bash
sleep 1
exec /usr/bin/mate-screenshot $@

If I point my shortcut towards this script instead of the binary, it works. Notice that I still provide the -a parameter as part of the shortcut definition.

@monsta monsta changed the title Taking screenshots of an area works onli from CLI Taking screenshots of an area doesn't work via keyboard shortcut Nov 11, 2015
@monsta
Copy link
Contributor

monsta commented Nov 11, 2015

Ok, confirmed. Interesting that a panel launcher with mate-screenshot -a works just fine.

@augnustin
Copy link

Thanks @martin-bts for workaround. Works very well, even with sleep 0.1, which feels like nothing.

A fix would be great though!

@monsta
Copy link
Contributor

monsta commented Mar 22, 2016

We'll try to fix it of course, I just can't make any promises about the date... our team is quite small and our issues list is growing every day. Pull requests with fixes are welcome, as usual.

@augnustin
Copy link

I guess, no criticism in my comment of course.

I wish I could help, but C kind of scares me...

Any tip on where to look at in the code? I checked https://github.com/mate-desktop/mate-utils/blob/master/mate-screenshot/src/mate-screenshot.c but it is such a long file I got easily lost.

Finally, if this is a fork from gnome-screenshot, does the fix needs to be accepted in both repositories to be released?

@monsta
Copy link
Contributor

monsta commented Mar 22, 2016

I'm not sure where to look yet... and maybe it's already fixed in gnome, not sure about this as well.

@davidforgianni
Copy link

I installed krita and shutter first. Then to Shutter preferences>Actions: open with Krita (for editing). Then set the dconf keybinding-command to 'shutter -s'. Works pretty good, although i would like to not have the Shutter application window open after capturing, just open in Krita. If i find how to do that I will update this post, I hope this helps, thank you!

sudo add-apt-repository ppa:kubuntu-ppa/backports; sudo apt-get update; sudo apt-get install krita

sudo add-apt-repository ppa:shutter/ppasudo add-apt-repository ppa:shutter/ppa; sudo apt-get update; sudo apt-get install shutter

selection_004

@huangjj27
Copy link

Nowaday the bug still exists with mate-utils 1.12 on ubuntu-mate 16.04. Please fix it soon!

@RadW2020
Copy link

RadW2020 commented Aug 1, 2016

screenshot at 2016-08-01 13 06 15

Still happening.

@N0rbert
Copy link

N0rbert commented Aug 22, 2016

I reported this to launchpad as bug 1615748 on Ubuntu 16.04.

@bitshark
Copy link

bitshark commented Oct 6, 2016

This continues to happen on Void Linux latest with Mate 1.14.1. Interestingly, it also happens (identical problem) with gnome-screenshot.

Keyboard shortcuts to either 'mate-screenshot --interactive' or 'mate-screenshot --window' work fine, but mate-screenshot --area does not work.

@bitshark
Copy link

bitshark commented Oct 6, 2016

I just did some analysis of the problem -- here's what I found.

  • I was able to use the workaround (wrapper script with a sleep call) suggested by martin-bts. I created the following script, and called this script instead of calling mate-screenshot from the keyboard shortcut.

I noticed that the timing issue is subtle... If I sleep for 30ms prior to calling mate-screenshot, the command will not work. If I sleep for 40ms prior to calling mate-screenshot, the command WILL work.

[user@dolphin ~]$ cat /usr/local/bin/my-screenshot 
#!/bin/bash
sleep 0.04  # this works... 40ms is long enough
#0.01 - no  # this does not, 10ms is not long enough
#0.03 - no  # this does not work, 30ms is not long enough
#0.04 - yes # etc
#0.05 - yes
/usr/bin/mate-screenshot --area
  • Strace indicates differences between working and non-working mate-screenshot call. I was curious as to what was going on with this, so I conducted an strace of the process call (mate-screenshot --area) under a condition where the screenshot --area call succeeded (sleep 40ms) vs where it failed (sleep 10ms).

What I found were the following differences:

  • The success vs failed runs resulted in mate-screenshot reading and writing different bytes to seperate two files
  • One of these files is ~/.Xauthority (fd = 4) in the strace.
  • The other file is ~/.config/dconf/user (fd = 7) in the strace.
  • The straces themselves had differences in two sections (see below), but were otherwise identical.

I'm not that familiar with dconf so I can't really take this further, but I hope this helps resolve the problem.

This screenshot shows that the fd=4 file descriptor is ~/.Xauthority
mate-screenshot-xauthority

This screenshot shows the first difference between the straces, in regard to read/write of both ~/.Xauthority and ~/.config/dconf/user

matescreenshot_strace_diff1

This is the second difference between the straces. They are identical besides what is displayed in these images.
mate-screenshot-strace-diff2

I also did a diff of the ~/.config/dconf/user file under both success and failure conditions (since mate-screenshot is read/writing this file). I found some differences , but I don't know how to interpret them and whether they are material.

First difference between working ~/.config/dconf/user and non-working
mate-screenshot-dconf-diff1

Second difference between working ~/.config/dconf/user and non-working
mate-screenshot-dconf-diff2

Anyway I hope this helps. In the meantime, you can use the workaround detailed above and create a wrapper script that sleeps for 50 to 100ms prior to calling mate-screenshot --area

@ghost
Copy link

ghost commented Jun 24, 2017

Still an issue in Mate Desktop Environment 1.16 on Ubuntu Mate 16.10, but @martin-bts' solution is a good workaround.

@N0rbert
Copy link

N0rbert commented Aug 9, 2017

Got this bug again on fresh installation of Ubuntu MATE 16.04.3 LTS.
I reported this bug 1615748 on Launchpad previously, now I linking it here.
What is interesting: if I add -i to mate-screenshot -a it works as expected (but opens interactive window).

@raveit65
Copy link
Member

raveit65 commented Aug 9, 2017

Surprise surprise.
With 1.18.2 (un patched) in fedora25/26 and using mod4 + a i have to press the a several times than it works with 'mate-screenshot -a' :-)
.... mod4= super key

@raveit65
Copy link
Member

raveit65 commented Aug 9, 2017

It works also if i hold the a key a bit longer, but than it is possible that abrt (bug reporting tool) pops up and i have a stacktrace.
But the stacktrace starts with malloc.c and nvidia.
So this isn't helpful.

@andreamoro
Copy link

andreamoro commented Dec 30, 2017

I've been reading tons of post complaining about this all over the places. I'm a newbie myself on linux mint, but I've seen few hack suggesting a delay in the command line, so I thought .... and what if I hold the print screen for a bit longer?
Here it goes ... on linux mint 18.3 this seems enough to activate the arrow cursor to grab your area.

@grants
Copy link

grants commented Sep 3, 2018

The print screen key always bind to "Print Whole Screen", I even can't find where to change it... Anyone give me some hints, thx.

@augnustin
Copy link

You need to edit your shortcuts in your preferences.

@14v
Copy link

14v commented Dec 15, 2018

  1. Tired of default shift-printscreen behaviour with mate-screenshot --area --interactive popup. Developers please take a look at Xfce's screenhot app which simply starts with selecting area after shift-printscreen
  2. I can see no mapping for shift-printscreen in settings but it works by default!
    default
    They are shown in CCSM but still work when disabled!
    default

Any comments?

@14v
Copy link

14v commented Dec 18, 2018

Flameshot seems to be good alternative for taking area screenshots. Available in the repo. I did sudo apt install flameshot dconf-editor. Then I replaced /org/mate/marco/keybinding-commands/command-2 value with flameshot gui in dconf.

@jeffmcneill
Copy link

No need for an extra file, just add a custom shortcut in keyboard shortcuts, found in control center:

/bin/sh -c 'sleep .1;mate-screenshot -a'

@N0rbert
Copy link

N0rbert commented Dec 8, 2021

Still happens on MATE 1.26 in Ubuntu MATE 21.10. Downstream bug report is at https://pad.lv/1615748 for 5 years (OMG!).
Fix is possible by adding sleep 0.1 as was suggested above:

cat <<EOF | dconf load /
[org/mate/desktop/keybindings/custom0]
action="/bin/sh -c 'sleep .1;mate-screenshot -a'"
binding='<Shift><Mod4>Print'
name='MATE Screenshot of area non-interactively'
EOF

Hope this bug will not happen in Ubuntu MATE 22.04 LTS.

@kkonevets
Copy link

No need for an extra file, just add a custom shortcut in keyboard shortcuts, found in control center:

/bin/sh -c 'sleep .1;mate-screenshot -a'

@jeffmcneill That's the best solution, thanks!

@coldReactive
Copy link

coldReactive commented Jul 8, 2024

Still exists to this day, and using the sleep method does nothing:

MATEScreenshot_CannotCopy.mp4

For this, I am instead using mate-screenshot -c as I need to copy it to the clipboard. It was working fine hours ago, but now it won't. If I copy to clipboard via the dialogue box with just mate-screenshot it copies fine. However, as you can see from the included video, the command DOES try to work, so it is trying to take a screenshot.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.