I have a script which takes a screenshot using import from imagemagick. It's able to shot whole root window or currently focused window. That depends on the only one argument
it takes.
screen.sh root
screen.sh active
At the top of the script there are to variables which control its behaviour. The SCREEN_DIR is a directory where you want to save your screenshots. And the SCREEN_PROMPT defines whether you want to be prompted for name of screenshot by i3-input. If you don't then this variable must not be set at all.
You can export these variables from your startup scripts to have settings separated from script itself.
The screenshot is saved in SCREEN_DIR under name in format NAME-YEAR-MONTH-DAY_HOUR-MIN-SEC.png where NAME is string typed in to the i3-input. If prompt is disabled or empty string is given then WM_CLASS of window is used or just "window" if WM_CLASS is not set. In case of root window screenshot NAME is "root".
And finally symlink named 'last' pointing to last taken screenshot is created for easier lookup.
#!/bin/bash
SCREEN_DIR=~/screenshots/
SCREEN_PROMPT=1
window='root'
case $1 in
root)
window='root';;
active)
window=`xprop -root | grep "_NET_ACTIVE_WINDOW(WINDOW)" | cut -d' ' -f5`;;
esac
[ ! -z "$SCREEN_PROMPT" ] && \
name=`i3-input -P 'screen-name: ' | sed -n '/command = /s/command = //p'`
if [ -z "$name" ];then
if [ $window == "root" ];then
name='root'
else
name=`xprop -id $window | sed -n '/WM_CLASS/s/.* = "\([^\"]*\)".*/\1\n/p'`
[ -z "$name" ] && name='window'
fi
fi
filename="$name-`date +%Y-%m-%d_%H-%M-%S`.png"
import -border -window $window "$SCREEN_DIR/$filename"
ln -sf "$filename" $SCREEN_DIR/last
exit
In i3 config just create simple binding.
bindsym Print exec screen.sh root
bindsym Mod1+Print exec screen.sh active
Note that if you take second screenshot during single second the previous one taken in that same second gets overwritten since there is no check for this case. So if you like to use printscreen to make movies you should check for this.
I just set up shutter yesterday and it's working just fine for me. I am not sure how I can assign a keyboard shortcut. Other than shutter, I don't know of anything comparable. Post-editing screenshots in Picasa just grew too annoying. EDIT have to retract above. Shutter only works with Selection.
same for me! :-) I am trying to reach Shutter's developers for some help on this... https://bugs.launchpad.net/shutter/+bug/1021996
Note that "keyboard could not be grabbed" can be fixed by using `--release` in the i3 binding.
The `--release` switch does not seem to exist anymore in current versions (neither in 0.90.1 from offician nor in 0.93 from ppa). Or do I get something wrong? I tried `bindsym Print exec shutter --release`. EDIT: Okay, the `--release` has to be placed right after bindsym. But the error still occurs!