dotfiles

Configuration for the software I use.
git clone https://git.sr.ht/~jbauer/dotfiles
Log | Files | Refs | README | LICENSE

commit 0b0548925e09dc773ea62d42193dba7eb620ecc5
parent f6adfff90dd0426b1d73ef7059b4b3dd95490b61
Author: Jake Bauer <jbauer@paritybit.ca>
Date:   Thu,  4 Feb 2021 21:09:34 -0500

Improve screenshot script

Diffstat:
M.local/bin/screenshot | 43+++++++++++++++++++++++++------------------
1 file changed, 25 insertions(+), 18 deletions(-)

diff --git a/.local/bin/screenshot b/.local/bin/screenshot @@ -1,22 +1,29 @@ #!/bin/sh +filename="$HOME/media/pics/$(date "+%F-%H-%M-%S").png" + case $1 in - "-d") - maim -u > ~/media/pics/$(date "+%F-%H-%M-%S").png \ - && notify-send -i camera-photo-symbolic "Screenshot Captured" \ - "Full desktop; saved to file." - ;; - "-w") - maim -u -i $(xdotool getactivewindow) > ~/media/pics/$(date "+%F-%H-%M-%S").png \ - && notify-send -i camera-photo-symbolic "Screenshot Captured" \ - "Current window only; saved to file." - ;; - "-s") - maim -u -s > ~/media/pics/$(date "+%F-%H-%M-%S").png \ - && notify-send -i camera-photo-symbolic "Screenshot Captured" \ - "Selected region; saved to file." - ;; - *) - echo "Invalid option, use -d, -w, or -s." - ;; + "-d") + maim -u > "$filename" \ + && notify-send -i camera-photo-symbolic "Screenshot Captured" \ + "Full desktop; saved to file." + ;; + "-w") + maim -u -i $(xdotool getactivewindow) > "$filename" \ + && notify-send -i camera-photo-symbolic "Screenshot Captured" \ + "Current window only; saved to file." + ;; + "-s") + maim -u -s > "$filename" \ + && notify-send -i camera-photo-symbolic "Screenshot Captured" \ + "Selected region; saved to file." + ;; + *) + echo "Invalid option, use -d, -w, or -s." + ;; esac + +filesize="$(stat -c %s $filename)" +if [ "$filesize" -eq 0 ]; then + rm "$filename" +fi