Ok, this is my problem: I have an application I want to screenshot; but because gnome-screenshot and mate-screenshot hide toolbars or whatnot each time they take a screenshot when started from the interactive applet window, they mess up the window of the application I'm screenshotting, which then crashes. The only thing I can do is start gnome-screenshot directly with a file name and a delay, which makes this process rather tedious.

So, this is what I'm thinking of doing - I can set up a global keypress listener via System/Keyboard Shortcuts":


This could trigger some program, which sends some sort of a global "signal" if you will (possibly a TCP/IP packet or something).

Then, I could have a "listener" script in an open terminal, which reacts to the signal (in a sense, netcat could be set up as a listening server, reacting to an incoming TCP/IP data, and then filter the reaction via grep or something), and in response, runs gnome-screenshot -d 10 -f ~/Desktop/test.png. As a simple example with netcat:

nc -l -p 1234 | while read l; do \
  if [ "$l" == "d" ]; then \
    echo "GOT IT"; \
  else \
    echo $l; \
  fi; \

The question is - are there any applications that I could use for sending this event globally, and listening and filtering for it in a terminal? I'd like to know if there is something like this avoiding network, before I try to develop my own custom netcat based scripting solution...

  • 1
    Why don't you just assign that command to the shortcut directly? – dadexix86 Mar 31 '16 at 9:32
  • Good point @dadexix86 - I guess now that I do this to avoid crashes, I'd like the extra logging to terminal this kind of a setup would provide... – sdaau Mar 31 '16 at 9:34
  • 1
    Ok, so I do not know how to answer your question, but to the extent of my capabilities, I would not call for an external listener. I would create a script (sh, maybe?) that does directly all the logging that you want (maybe on a hidden log file in your home) and launches gnome-screenshot with those parameters. – dadexix86 Mar 31 '16 at 9:37

Ok, made this with netcat, but hoping someone will post a better solution:

#!/usr/bin/env bash

# let the signal be the letter "d"
# set up a netcat listener, and run gnome-screenshot without prompt on incoming signal

# in System/Keyboard shortcuts:
# Name: trignetshot
# Cmd: bash -c "echo d | nc localhost 1234"
# Shortcut: whatever...

# then run this script in a terminal - and then press the shortcut key

while [ 1 ]; do # else it exits at each received line with TCP
  echo "Starting listener...";
  nc -l -p 1234 | while read l; do
    if [ "$l" == "d" ]; then
      echo "GOT IT";
      # calculate screenshot name
      for ix in ~/Desktop/Screenshot*.png; do
        tnum=$(echo $ix | egrep -o '[[:digit:]]*');
        #echo $tnum ;
        if [ -z "$tnum" ]; then
        if (($tnum>$maxnum)); then
      #echo $maxnum # have it here
      set -x
      gnome-screenshot -d 1 -f ~/Desktop/Screenshot-${newnum}.png
      set +x
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.