From 9b49b336426b9b2401fe9db945ddd958dfa5ec96 Mon Sep 17 00:00:00 2001 From: Lucas Date: Sun, 8 Dec 2019 18:20:59 +0000 Subject: [PATCH] Small refactor for screenshot --- bin/screenshot.sh | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/bin/screenshot.sh b/bin/screenshot.sh index b3764ab..b106a69 100644 --- a/bin/screenshot.sh +++ b/bin/screenshot.sh @@ -28,21 +28,17 @@ err() exit 1 } -save_screenshot() -{ - xwdtopnm | pnmtopng >~/media/ss/"$(date +%Y%m%d-%H%M%S)".png -} - case $# in -0) xwd -silent -root | save_screenshot +0) set -- -root ;; 1) [ "$1" = "-window" ] || err "Unknown option \"$1\"." - xwd -silent | save_screenshot + set -- ;; 2) [ "$1" = "-id" ] || [ "$1" = "-name" ] || err "Unknown option \"$1\"." [ -n "$2" ] || err "$1 expects a non-empty parameter." - xwd -silent "$1" "$2" | save_screenshot ;; *) usage ;; esac + +xwd -silent "$@" | xwdtopnm | pnmtopng >~/media/ss/"$(date +%Y%m%d-%H%M%S)".png