aboutsummaryrefslogtreecommitdiff
path: root/bin
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 /bin
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
Diffstat (limited to 'bin')
-rw-r--r--bin/xsnap.sh24
1 files changed, 24 insertions, 0 deletions
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"