aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Ryder <tom@sanctum.geek.nz>2022-05-07 02:41:38 +1200
committerTom Ryder <tom@sanctum.geek.nz>2022-05-07 03:34:22 +1200
commita16ad7b710fb2e4085f7d790e699830083d4e102 (patch)
tree5c3e5b1888249ecfc26897fc502ba54a26e22569
parentRemove daft quotes from vimrc (diff)
downloaddotfiles-a16ad7b710fb2e4085f7d790e699830083d4e102.tar.gz
dotfiles-a16ad7b710fb2e4085f7d790e699830083d4e102.zip
Overhaul screenshot behavior
* Move burdensome logic to new script xsnap(1df) * Switch to otherwise-disused Print/PrtScr key * Add binds for full display and single-window screenshots
-rw-r--r--.gitignore1
-rw-r--r--Makefile3
-rw-r--r--bin/xsnap.sh24
-rw-r--r--man/man1/xsnap.1df16
-rw-r--r--sxhkd/sxhkdrc16
5 files changed, 51 insertions, 9 deletions
diff --git a/.gitignore b/.gitignore
index 4ebbf548..b4596e61 100644
--- a/.gitignore
+++ b/.gitignore
@@ -156,6 +156,7 @@
/bin/xgoc
/bin/xrbg
/bin/xrq
+/bin/xsnap
/dillo/dillorc
/dillo/dillorc.m4
/emacs/bin/emacsm
diff --git a/Makefile b/Makefile
index c3baca27..376a7954 100644
--- a/Makefile
+++ b/Makefile
@@ -227,7 +227,8 @@ BINS = bin/ap \
bin/xgo \
bin/xgoc \
bin/xrbg \
- bin/xrq
+ bin/xrq \
+ bin/xsnap
BINS_M4 = bin/chn.m4 \
bin/dfv.m4 \
diff --git a/bin/xsnap.sh b/bin/xsnap.sh
new file mode 100644
index 00000000..c4b2a9ea
--- /dev/null
+++ b/bin/xsnap.sh
@@ -0,0 +1,24 @@
+# Wrapper for scrot(1) for use in recording screenshots
+date=$(date +%Y/%m/%d) || exit
+dir=$HOME/screenshots/scrot/$date
+mkdir -p -- "$dir" || exit
+cd -- "$dir" || exit
+for ent in * ; do
+ [ -e "$ent" ] || continue
+ case $ent in
+ *.png) ;;
+ *) continue ;;
+ esac
+ basename=${ent%.png}
+ case $basename in
+ *[!0-9]*) continue ;;
+ esac
+ last=$basename
+done
+number=$(printf '%s' "$last" | sed 's/^0*//') # Avoid octal
+id=$((number + 1))
+name=$(printf '%05d' "$id").png
+path=$dir/$name
+scrot --file="$path" --overwrite "$@" || exit
+xclip -selection clipboard -target image/png "$path" || exit
+notify-send "Saved: $date/$name"
diff --git a/man/man1/xsnap.1df b/man/man1/xsnap.1df
new file mode 100644
index 00000000..ff177754
--- /dev/null
+++ b/man/man1/xsnap.1df
@@ -0,0 +1,16 @@
+.TH XSNAP 1df "May 2022" "Manual page for xsnap"
+.SH NAME
+.B xsnap
+\- wrapper around scrot(1) for serialized recorded screenshots
+.SH SYNOPSIS
+.B xsnap
+.br
+.B xsnap
+\--select
+.SH DESCRIPTION
+.B xsnap
+takes a PNG screenshot with scrot(1), passing any options thereto, saving the
+image into a date-stamped path ~/screenshots/scrot/YYYY-MM-DD, with increasing
+integer filenames for that day.
+.SH AUTHOR
+Tom Ryder <tom@sanctum.geek.nz>
diff --git a/sxhkd/sxhkdrc b/sxhkd/sxhkdrc
index 028b73d7..4322c5ff 100644
--- a/sxhkd/sxhkdrc
+++ b/sxhkd/sxhkdrc
@@ -31,14 +31,14 @@ super + p
super + v
x-terminal-emulator -e "$VISUAL"
-super + shift + s
- sleep 0.25 && scrot --freeze --select \
- --exec 'xclip -selection clipboard -target image/png $f && \
- dir=$$HOME/screenshots/%Y-%m-%d && \
- mkdir --parents -- "$$dir" && \
- convert -- $f -define webp:lossless=true \
- "$$dir"/%Y-%m-%d_%H%M%S_$wx$h.webp && \
- rm -- $f'
+Print
+ xsnap
+
+control + Print
+ xsnap --freeze --select
+
+super + Print
+ xsnap --focused
super + slash
i3lock --color=#000000 --image "$HOME"/.local/share/i3/lock.png --nofork