awesome: bind Print Screen key to take screenshots
Create a directory called ~/bin
where the script will live:
~$ mkdir bin
Create a file with the script to take screenshots, capscr
#!/bin/bash
timestamp="$(date +%d.%m.%Y"_shot_"%H:%M:%S)"
targetbase="$HOME/Pictures/screenshots"
mkdir -p $targetbase
[ -d $targetbase ] || exit 1
import -window root -quality 98 $targetbase/$timestamp.png
Credit: nixkid.
The script will create ~/Picture/screenshots
.
You should have something like this:
~/bin$ ls capscr
capscr
Make the script executable:
~/bin$ chmod +x capscr
Now you need to tell awesome to bind the key PrtSc
to the script capscr
.
$ cd ~/.config/awesome
where rc.lua
, awesome’s configuration file, is.
You can skip these setps if you want.
These are precautionary steps you can take so you can restore rc.lua
if you mess things up.
Initiate a repository and commit.
$ git init
$ git add .
$ git commit -m "First commit"
Now, if you mess up your rc.lua
file you can run $ git checkout .
to restore the file to where it was when you ran $ git commit -m “First commit”
.
Download the patch in ~/.config/awesome
:
$ sudo apt install wget # to install wget first
$ wget https://yctct.com/_bind_PrtSc_capture_screen.patch
Apply the patch to your rc.lua
config file:
$ patch -i _bind_PrtSc_capture_screen.patch
The patch should be applied; if you use git you can run $ git diff
to see.
Once you’ve applied the patch you can restart awesome:
$ echo 'awesome.restart()' | awesome-client
Press the key PrtSc
.
A screenshot should be saved in ~/Pictures/screenshots
.
Now that rc.lua
is patched, you can remove the file containing the patch:
~/.config/awesome$ rm -i _bind_PrtSc_capture_screen.patch
If you use git:
$ git add rc.lua
$ git commit -m "Apply prtsc patch"
You can remove the patch by deleting the commit.
personal computing command-line interface (cli) gnu linux trisquel shell literacy wiki awesome