LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   grab - Simply a useless bash script to take a screen shot; Required command: import (https://www.linuxquestions.org/questions/programming-9/grab-simply-a-useless-bash-script-to-take-a-screen-shot%3B-required-command-import-101534/)

micxz 10-08-2003 03:06 AM

grab - Simply a useless bash script to take a screen shot; Required command: import
 
It's my first bash script and felt I should share to someone, since my girlfriend does not seem to care at all about it. It's a usesless /bin/sh script to take a screen shot of your desktop and put the *.jpg in your home directory named grab-year,month & nanosecond. It supports the full screen or manually via drawing a box with your mouse. I only wrote this script to take screens faster, useless otherwise.

Create a file called "grab" insert this code into it:

Code:

#!/bin/sh
# grab
# description:
# A simple program to take a quick screen shot
#
# Required: import (Part of the image magic library)
#
# By Micxz

mygrab=`which import | tr -d ''`

if [ $mygrab == '' ] ; then
echo ""
echo "I'm Sorry I can't find: /usr/bin/import "
echo "Open this script and change \$mygrab at the top."
echo ""
exit 0
fi

case "$1" in

-f)
  echo ""
  RANDTIME=`/bin/date +%Y%m%N | tr -d ' '`
  $mygrab -window root ~/grab-$RANDTIME.jpg
  echo "Full grab done. Look in ~/"
  echo ""
  ;;


-m)
  echo ""
  RANDTIME=`/bin/date +%Y%m%N | tr -d ' '`
  $mygrab ~/grab-manual-$RANDTIME.jpg
  echo "Manual grab done. Look in ~/"
  echo ""
  ;;


*)

  echo ""
  echo "  USAGE:  grab [command] "
  echo ""
  echo "  COMMANDS:"
  echo "        -f      Grab the entire X server screen."
  echo "        -m      Manually grab the screen with your mouse."
  echo "        -help    Displays this list of options."
  echo ""
  exit 1 ;;

esac
exit 0

chmod 755 grab

Done;

jinksys 10-08-2003 05:18 PM

Your script deleted all my mp3s... Just kidding,

Although its task is small, this is a very clean, professional script.
Nice work.

micxz 10-08-2003 07:59 PM

Thanks' I'm proud of it.


All times are GMT -5. The time now is 08:38 AM.