commit 062902d7d06731160ab3e78aab346d5683570aa2 from: Omar Polo date: Mon Feb 21 15:05:56 2022 UTC add -c to sshot for clipboard support commit - 1ac9fd6066e16404a374134a96f275c5013d10b7 commit + 062902d7d06731160ab3e78aab346d5683570aa2 blob - 3fade9045b5523171cd6092c53660582493d61bf blob + e9c6c1bff7826f2b32863df38d5e58469abd909c --- bin/sshot.lp +++ bin/sshot.lp @@ -5,20 +5,23 @@ sshot is a simple script to make a screenshot! #!/bin/sh select= + clip= Did you know that getopts is a built-in? The first version of this script used getopt, but it was ugly and required some shell features which I'm not sure are POSIX. getopts is easier to handle: - while getopts s name; do + while getopts cs name; do case $name in + c) clip=1 ;; s) select=1 ;; ?) echo "Usage: $0 [-s]" >&2; exit 1 ;; esac done -The usage is simple, it just accepts a -s flag to select a window -instead of grabbing the whole screen. +The usage is simple, it just accepts a -c flag to copy the image in the +clipboard and a -s flag to select a window instead of grabbing the whole +screen. The image is saved in /tmp/YYYYMMDDHHMMSS.png @@ -40,6 +43,13 @@ case exit 1 fi +Optionally save the image in the clipboard: (not the path, the whole +image!) + + if [ -n "$clip" ]; then + xclip -selection clipboard -t image/png -i "$file" + fi + Then send a notification to give a feedback of the success notify-send "sshot: done" "$file"