From f7b6ef1a4c3cc4d3eca2173fb4c651594490c5b8 Mon Sep 17 00:00:00 2001 From: Lucien Cartier-Tilet Date: Wed, 3 Apr 2024 06:00:48 +0200 Subject: [PATCH] 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. --- docs/hyprland.org | 16 ++++++++-------- docs/scripts.org | 31 ++++++++++++++----------------- 2 files changed, 22 insertions(+), 25 deletions(-) diff --git a/docs/hyprland.org b/docs/hyprland.org index 2d04dd3..b95a516 100644 --- a/docs/hyprland.org +++ b/docs/hyprland.org @@ -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 diff --git a/docs/scripts.org b/docs/scripts.org index 36ba0a7..806e093 100644 --- a/docs/scripts.org +++ b/docs/scripts.org @@ -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