pasithea: glowing girl (Default)
pasithea ([personal profile] pasithea) wrote2004-04-10 02:46 pm

Geekery

People keep asking what I'm doing when I'm idle and I realized that the screen for Maya actually looks pretty neat most of the time I'm working in it, so... I wrote a little desktop grabber thingy for MacOS. You'll have to find/download ncftp to get it to work and change the path to it accordingly. The rest is pretty straight-forward. SIPS comes free with OSX-10.3 but may not be in earlier OSX's. I copied it from 10.3 to 10.2.8 and it runs just fine. You could also replace it with ImageMagick. Other than that, here's the whole script.

#!/bin/sh

#Define some variables.
NCFTPDIR="$HOME/ical_synch/ncftp"
USER="user_name"
PASS="user_password"
SERVER="twu.net";                  #Where to put the file.
WEBDIR="public_html/photos/webcam"; #Directory on website to put file.
FILENAME="desktop";             #Image name without suffix. (includes path)
XSIZE=800;                            #Number of pixels across.
YSIZE=600;                            #Number of pixels down.

/usr/sbin/screencapture $FILENAME.pdf
/usr/bin/sips -s format jpeg $FILENAME.pdf -s formatOptions low -z $YSIZE $XSIZE -o $FILENAME.jpg
/bin/rm $FILENAME.pdf

$NCFTPDIR/ncftpput -u $USER -p $PASS $SERVER $WEBDIR $FILENAME.jpg
/bin/rm $FILENAME.jpg


And then of course, you also want a cronjob to run it every 5 minutes:

1,6,11,16,21,26,31,36,41,46,51,56 * * * * /Users/sammi/deskgrab/deskgrab.sh


You can go to http://circle.twu.net/photos/webcam/desktop.html and see it run. You can also hit 'view source' and get the script (It's just a meta refresh)

So... that's it. I love Macs! :) Next time someone asks, they can just look there instead. (Unless I'm doing physical animation in which case I'll have the webcam turned on, maybe. :)

(Okay, maybe I am an attention whore)

[identity profile] kibbles.livejournal.com 2004-04-10 11:05 pm (UTC)(link)
Did you see Snapperhead? Similar thing, and they have the code out there so you can peek and compare.

And all my PC friends wanna do it but can't figure out how!

[identity profile] dv-girl.livejournal.com 2004-04-11 12:30 am (UTC)(link)
That was the name of that program you use that I couldn't remember the name of! :)

I looked for you to ask what it was, didn't see you, got frustrated and wrote my own. :)

[identity profile] kibbles.livejournal.com 2004-04-11 12:35 am (UTC)(link)
I would imagine yours is less stress on the processor, wouldn't slow everything down like Snapperhead does?

I have to think. Thinking is reserved for some time in May, when Dan has vacation and I have 2 seconds to myself!

[identity profile] dv-girl.livejournal.com 2004-04-11 01:05 am (UTC)(link)
It doesn't slow down my machine but I have a dual-processor G4 tower with like 512M of ram and stuff. I don't know if it'd slow down a less powerful machine or not.
I don't _think_ it would but that's no garuntee. :)
zeeth_kyrah: A glowing white and blue anthropomorphic horse stands before a pink and blue sky. (Default)

[personal profile] zeeth_kyrah 2004-04-12 03:56 am (UTC)(link)
I believe Snapperhead takes a fresh snapshot each time the HTTP server recieves a hit, which would definitely slow things down if you got a lot of upstream traffic.

[identity profile] saberwind.livejournal.com 2004-04-11 01:28 am (UTC)(link)
Looking at that link. I like the squirrelgirl you seem to beworking with. :}

Hope your day will be happy!