Small refactor for screenshot
This commit is contained in:
parent
c84c0e3a99
commit
9b49b33642
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user