Ok, fizemos isso com netcat
, mas esperamos que alguém publique uma solução melhor:
#!/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
maxnum=0;
for ix in ~/Desktop/Screenshot*.png; do
tnum=$(echo $ix | egrep -o '[[:digit:]]*');
#echo $tnum ;
if [ -z "$tnum" ]; then
tnum=0;
fi;
if (($tnum>$maxnum)); then
maxnum=$tnum;
fi;
done;
#echo $maxnum # have it here
newnum=$((maxnum+1))
set -x
gnome-screenshot -d 1 -f ~/Desktop/Screenshot-${newnum}.png
set +x
fi;
done;
done