diff options
-rwxr-xr-x | screenshot.sh | 25 |
1 files changed, 18 insertions, 7 deletions
diff --git a/screenshot.sh b/screenshot.sh index e3b638d..02dca78 100755 --- a/screenshot.sh +++ b/screenshot.sh @@ -3,20 +3,31 @@ # A simple screenshot script. Very handy for calling a specific from a window # manager using custom hotkeys (eg: i3) # -# Requirements: +# Requirements (X11): # imagemagick # -savePath=~/Pictures/screenshots/ +# Requirements (Wayland): +# slurp (for getting screenshot geometry) +# grim (for taking the actual screenshot) +# +savepath=~/Pictures/screenshots/ -if [[ ! -d $savePath ]]; then - mkdir -p $savePath +if [ ! -d "${savepath}" ]; then + mkdir -p "${savepath}" fi # Wait two seconds -sleep 2; +sleep 2 # Get our file suffix -date=`date '+%Y%m%d-%H%M%S'` +date="$(date '+%Y%m%d-%H%M%S')" # And action! -import $savePath/screen.$date.jpg +if [ -n "${WAYLAND_DISPLAY}" ]; then + grim -g "$(slurp -w 4)" "${savepath}/screen.${date}.jpg" +elif [ -n "${DISPLAY}" ]; then + import "${savepath}/screen.${date}.jpg" +else + printf 'ERROR: Could not detect display manager\n' + exit 1 +fi |