I want to take a screenshot with import
, and save it into a file whose name is current time.
Here is what I've tried:
sunqingyao:~$ date '+screenshot-%y%m%d-%H%M%S.png'
screenshot-170716-173336.png
# OK
sunqingyao:~$ import screenshot-170716-173336.png
sunqingyao:~$ ls -l screenshot-170716-173336.png
-rw-rw-r-- 1 sunqingyao sunqingyao 250556 Jul 16 17:35 screenshot-170716-173336.png
# OK
sunqingyao:~$ date '+screenshot-%y%m%d-%H%M%S.png' | import
import: missing an image filename `import' @ error/import.c/ImportImageCommand/1293.
# Not OK
For some reason, I want this command to be a one-liner.
Background info:
Actually I'm trying to bind a key to screenshot taking with i3. Here is the relevant part of my ~/.config/i3/config
:
# Take a screenshot upon pressing $mod+x (select an area)
# https://i3wm.org/docs/userguide.html#keybindings
bindsym --release $mod+x exec --no-startup-id date '+screenshot-%y%m%d-%H%M%S.png' | import
Seems that I can only bind a key to a command that can fit in only one line, which is why a one-liner is required.
import $(date '+screenshot-%y%m%d-%H%M%S.png' )
andbindsym --release $mod+x exec --no-startup-id import $(date '+screenshot-%y%m%d-%H%M%S.png')
. – jimmij Jul 16 '17 at 10:02