-1

I'm trying to get Gnome Screenshot to take and save screenshots with one keystroke, but I've run into a problem. The command I'm using works perfectly in the terminal, but not when i bind it to a key. When I press the bound key (Print Screen in this case), nothing happens. No error, nothing.

gnome-screenshot -f "$HOME/Pictures/Screenshots/Test $(date '+%F %T').png"

I'm currently trying different tweaks to the command. Currently, I've gotten it to work by omitting the path, but the "$(date "+%F %T")" part doesn't work properly when I do that, which puts me back where I was before. Before, it would take them with the same name and in my Home folder, causing them to be overwritten.

muru
  • 207,228
Beth C
  • 1

2 Answers2

1

Keybinding commands don't execute in a shell context. Therefore command interpolation doesn't work.

You can create a script in, say, $HOME/.local/bin/screenshot, that contains:

#!/usr/bin/env bash
gnome-screenshot -f "$HOME/Pictures/Screenshots/Test $(date '+%F %T').png"

chmod +x it, then bind the key you want to it.

You can also use scrot instead of gnome-screenshot, whose default filenames include a timestamp.

dhasenan
  • 274
0

I've never used chmod. What does it do? I've also never made a script or bound it to a key.

chmod changes the permissions of a file. This setting determines who can read/write/execute a file. chmod +x allows the file to be executed directly. Further reading would be the manpage for chmod and this article exaplining shebangs.

Two other things worth nothing.

  1. Have you tried binding to a different key? Applications that have focus are generally able to decide how to handle input events. This means that steam could intercept the PrtSc, tell the OS that it handled the keypress, and then actually do nothing with it. This could be true for all keys leaving you out of luck.

  2. Full screen applications are generally rendered differently than windowed applications. Knowing that they are fullscreen allows the app to skip certain rendering steps which increases performance. I don't know enough to say for certain if this is actually the case, but its not unreasonable to think that the screenshot mechanism of the tool you are using isn't capable of capturing the screen of fullscreen apps. You could test this by running the game in windowed mode. Since it sounds like you can take screenshots of the game, albeit with a delay, this is probably not the issue.

Josh A.
  • 161