docs(hyprland, scripts): better screenshot script

This commit adds the possibility of using swappy to edit screenshots.
It also changes the behaviour of the delay by first allowing the user
to select the area they want to capture, and then only does it wait
for the indicated amount of time before it takes the screen capture.
This commit is contained in:
Lucien Cartier-Tilet 2024-04-03 06:00:48 +02:00
parent 8ec4e4ad43
commit f7b6ef1a4c
Signed by: phundrak
GPG Key ID: BD7789E705CB8DCA
2 changed files with 22 additions and 25 deletions

View File

@ -420,14 +420,14 @@ what most of these do.
*** Screenshots
Here are the keybinding for the screenshot submap
#+name: screenshot-submap
| Modifiers | Key | Action | Argument | Submap |
|-----------+-------+--------+-----------------+--------|
| | Print | exec | =screenshot= | reset |
| | c | exec | =screenshot -c= | reset |
| | s | exec | =screenshot -s= | reset |
| | g | exec | =screenshot -g= | reset |
| | d | exec | =screenshot -d 3= | reset |
| Shift | s | exec | =screenshot -sc= | reset |
| Modifiers | Key | Action | Argument | Submap |
|-----------+-------+--------+--------------------+--------|
| | Print | exec | =screenshot= | reset |
| | d | exec | =screenshot -d 3= | reset |
| Shift | d | exec | =screenshot -sced 3= | reset |
| | e | exec | =screenshot -sec= | reset |
| | s | exec | =screenshot -s= | reset |
| Shift | s | exec | =screenshot -sc= | reset |
*** Windows
#+name: windows-submap

View File

@ -234,20 +234,6 @@ UNREAD=$(mu find "flag:unread AND (maildir:/Inbox OR maildir:/Junk)" | wc -l)
printf "^f2^f0%s" "$UNREAD"
#+end_src
*** Post scrot script
:PROPERTIES:
:HEADER-ARGS: :shebang "#!/usr/bin/env sh" :tangle ~/.local/bin/post-scrot
:END:
It is possible to call a script on the resulting image of a ~scrot~
command. Not only do I want to move them to a specific directory, I
also want to be able to see them in ~nsxiv~ (a replacement for ~sxiv~) in
case I want to edit the image, copy it or simply delete it (sometimes
I take screenshots by accident).
#+begin_src sh
mv "$@" ~/Pictures/Screenshots/
nsxiv -abfs f "$HOME/Pictures/Screenshots/$*"
#+end_src
*** screenshot
:PROPERTIES:
:HEADER-ARGS: :shebang "#!/usr/bin/env sh" :mkdirp yes :tangle ~/.local/bin/screenshot
@ -269,7 +255,7 @@ OUTFILE_BASE="$HOME/Pictures/Screenshots/Screenshot_$(date +%Y%m%d)_$(date +%H%M
OUTFILE="$OUTFILE_BASE.png"
SUFFIX=0
while getopts ':cd:gs' OPTION; do
while getopts ':cd:egs' OPTION; do
case "$OPTION" in
c )
COPY="yes"
@ -277,6 +263,9 @@ while getopts ':cd:gs' OPTION; do
d )
DELAY="$OPTARG"
;;
e )
EDIT="yes"
;;
g )
GIMP="yes"
;;
@ -284,21 +273,29 @@ while getopts ':cd:gs' OPTION; do
SELECT="yes"
;;
? )
echo "Usage: $(basename "$0") [-c] [-d DELAY] [-g] [-s]"
echo "Usage: $(basename "$0") [-c] [-d DELAY] [-e] [-g] [-s]"
exit 1
;;
esac
done
if [ "$SELECT" = "yes" ]
then AREA="$(slurp)"
fi
if [ -n "$DELAY" ]
then sleep "$DELAY"
fi
if [ "$SELECT" = "yes" ]
then grim -g "$(slurp)" "$OUTFILE"
then grim -g "$AREA" "$OUTFILE"
else grim "$OUTFILE"
fi
if [ "$EDIT" = "yes" ]
then swappy -f "$OUTFILE" -o "$OUTFILE"
fi
if [ "$GIMP" = "yes" ]
then gimp "$OUTFILE"
fi