Commands in custom shortcuts

When I went from Ubuntu 20.04 to 22.04, I lost the ability to do screen shots the way I’m used to. I want a keyboard combo that lets me select a section of screen and have it saved as a file. So I created a custom shortcut. But since it’s a screen shot, I want each file to have a unique name. From the terminal, I can

gnome-screenshot -a -f Pictures/Screenshots/"Screenshot from $(date "+%Y-%m-%d %H-%M-%S").png"

However, if I do that in the custom shortcut, the ‘date’ command is never executed.

How do I wind up with a file name that’s unique>

Asked By: John Oliver

||

Shell expansions and variable expansions do not work when launching a command from a hotkey. Instead run your command as follows, i.e., explicitly starting a shell to run it in:

sh -c 'gnome-screenshot -a -f Pictures/Screenshots/"Screenshot from $(date "+%Y-%m-%d %H-%M-%S").png'
Answered By: vanadium