18 juli 2006

PrtSc, the sequel

Omdat onze bash-goeroe, een aantal opmerkingen had, en de meeste waren terecht, bestaat er nu een nieuwe versie. De verschillen: - keuze van screenshot-programma (standaard is het import van Imagemagick) - geen eval meer in de code - als je het commando in een terminal gebruikt krijg je de url te zien waar de file geupload is. Het leuke aan import van Imagemagick is dat je kan kiezen waarvan je een screenshot wil nemen (thx Defv). De code: [code lang="Bash"] #! /bin/bash # this tool will upload a screenshot to the web #if the first parameter is empty the default name will be #the TIMESTAMP, and the image will be saved in png-format #default dir where the screenshot will be stored local LOCAL_DIR="/the/files/will/be/stored/localy/here/" #ftpserver FTP_SERVER="ftp.server.net/some/dir/" #login for ftp FTP_LOGIN="username" #password for ftp FTP_PASS="******" #url where the image are available, without the filename ofcourse URL_PREFIX="http://example.net/" #if TIMESTAMP is on a TIMESTAMP will be added in the FILE_NAME TIMESTAMP="off" #use this screenshot-program SCREENSHOT_PROGRAM="import" #checks if a command exists checkCommand() { which $1 >>/dev/null if (($?!=0)) ; then echo "Error: command $1 doesn't exists, try 'sudo apt-get install $1" exit 1 fi } #just checking if the required commands are present checkCommand which checkCommand ${SCREENSHOT_PROGRAM} checkCommand lftp #set the FILE_NAME depending on the config if [ "$1" ] ; then if [ "${TIMESTAMP}" = "on" ] ; then FILE_NAME="$(date +%d%m%Y-%H%M%S-)$1" else FILE_NAME="$1" fi else FILE_NAME="$(date +%d%m%Y-%H%M%S).png" fi #taking the screenshot ${SCREENSHOT_PROGRAM} ${LOCAL_DIR}${FILE_NAME} #uploading the screenshot (Defv++ eval--) lftp -e "put ${LOCAL_DIR}${FILE_NAME} && exit" ${FTP_LOGIN}:${FTP_PASS}@${FTP_SERVER} #say something nice echo "view the image at ${URL_PREFIX}${FILE_NAME}" [/code] De Howto: Download het script van: http://tys.crsolutions.be/gallery/file/projects/printscr/printscr2 [code lang="Bash"] sudo mv /hier/is/het/script/gedownload/printscr2 /usr/bin/printscr sudo chmod +x /usr/bin/printscr #install your screenshot-program if it isn't present (tip: imagemagick or scrot) sudo apt-get install imagemagick sudo apt-get install lftp sudo vim /usr/bin/printscr #config it [/code] Gratis tip van Defv: [code] PS: als je wilt dat je script ook wordt gelinked aan de PrtSc knop, is er een simpel (sed vuil) trukje: mv /usr/bin/gnome-screenshot /usr/bin/gnome-screenshot-old ln -s /usr/bin/printscr /usr/bin/gnome-screenshot [/code]

Dit artikel gaat over: , . PrtSc, the sequel werd geschreven door Tijs.
Er zijn nog geen reacties, reageer als eerste.

Reageer velden gemarkeerd met een sterretje zijn verplicht

*