Computers: June 2003 Archives

Perl Idioms From Beyond

| | Comments (0)

You may or may not know about this little (hopefully largely unused) idiom:

perl -le '$FILE = ".bashrc"; open(FILE); print <FILE>'

Since we don't use global variables anymore (right?), this is no longer useful. But wouldn't it be cool if that could work with lexicals? I offer no solution. Just the thought. use.perl.org

What's Happening Now!

| | Comments (0)
I updated happening to also show what the current window is in the frontmost app (if you have a glue created for it), and special-cased it for Terminal and ircle to show what process is running or what channel I am in (though the ircle one is disabled ... gotta have some privacy :-). One might also want to special-case iChat for similar reason, or any other app, just by making an additional subroutine for it.

I also fixed some little bugs and cleaned it up a little. Thanks to gnat for some ideas etc. use.perl.org

Mac-OSA-Simple-1.06 Released

| | Comments (0)
Mac-OSA-Simple-1.06 has been released. Download it from the CPAN or SF.net.

(Note: it may take time for the release to propagate to the various download mirrors.)
Changes:

* v1.06, Wednesday, June 25, 2003
 
   Fix PREREQ.

Posted using release by brian d foy. use.perl.org

What's Happening

| | Comments (0)
So I've put together a script to update my iChat status, and it has evolved over time. It used to work with iChatStatus, but now iChat AV is scriptable, so I can update the status message from Mac::Glue.

The script I use now is called happening, and it forks itself into the background (startup of Mac::Carbon stuff is still pretty slow and processor-intensive in dyld, so it stays running all the time ... besides, I set it to run every 15 seconds anyway), and then runs through a series of checks on each loop.

It first looks to see if I am watching EyeTV locally, then looks to see if I am listening to an MP3 in iTunes. Then it calls another machine, executing a similar script, to see if that machine is running EyeTV or iTunes (right now this is done via ssh, but I am going to rewrite that remote script to also be a daemon, and have it write out a file I can check via HTTP; much more efficient).

If all those fail, it shows the current app, and if somehow that fails, it puts up something from fortune(6).

It makes heavy use of Mac::Glue to talk to iChat, iTunes, EyeTV, and System Events. It's super sweet! Note how it caches objects it is going to reuse ... makes it super fast and efficient, too. There are a bunch of me-specific things hardcoded in it ... sorry if that gets in your way. :-)
Here are the key lines for talking to iChat:

$status  = $ichat->prop('status');
return unless $status->get eq 'available';
 
$message = $ichat->prop('status message');
$message->set(to => $output);

use.perl.org

Mac-OSA-Simple-1.05 Released

| | Comments (0)
Mac-OSA-Simple-1.05 has been released. Download it from the CPAN or SF.net.

(Note: it may take time for the release to propagate to the various download mirrors.)
Changes:

* v1.04, Monday, April 21, 2003
 
   Add support for saving/loading compiled AppleScripts as data in data fork
   instead of resource in resource fork on Mac OS X, for compatability with
   the Mac OS X Script Editor.

Posted using release by brian d foy. use.perl.org

Mac-Carbon-0.53 Released

| | Comments (0)
Mac-Carbon-0.53 has been released. Download it from the CPAN or SF.net.

(Note: it may take time for the release to propagate to the various download mirrors.)
Changes:

* v0.53, 24 June 2003
 
   OSADoEvent fixed
 
   Fix some Files tests
 
   Add Mac::Path::Util 0.09 to prereqs for Mac OS X

Posted using release by brian d foy. use.perl.org
Mac-AppleEvents-Simple-1.06 has been released. Download it from the CPAN or SF.net.

(Note: it may take time for the release to propagate to the various download mirrors.)
Changes:

* v1.06, Tuesday, June 24, 2003
 
   Check that $ENUMREC is defined.

Posted using release by brian d foy. use.perl.org

iChat

| | Comments (0)
New iChat is scriptable. I have my "status message" setting script now bypassing iChatStatus altogether, and setting the status directly with Mac::Glue.

Now that iChat can stream audio/video from a DV camera, I could hook my DVD player up to my DV camera, play it back through the camera, and stream it over iChat. HA.

Now Playing: Old Enough To Know - Michael W. Smith (The Big Picture)

use.perl.org

Back

| | Comments (0)
I am returned from "vacation," all moved into my new place in sunny northwest Washington. OK, not so sunny. I'll post more about it later when I am not so busy with being busy.

Now Playing: Don't Drink the Water - Dave Matthews Band (Before These Crowded Streets)

use.perl.org

Moving, Day 1

| | Comments (0)
My house in Massachusetts is empty except for me, my dogs, and my computer. And some salami.

The cats are in the car, beginning to be miserable.

I plan to get to Ohio today before finding a nice rest area to sleep in.

See you in Washington. use.perl.org

Part of the Problem

| | Comments (0)
I get hundreds of spams per day, a large percentage of which are "virus spams," the Microsoft worms/viruses that try to infect my Mac. And a significant number of those are bounce messages telling me that the mail that "I sent" contained a virus. Except, of course, that I never sent that mail.

Can someone clue these people in, the ones that run these "helpful" systems, that it is likely that none of the virus spams they are getting actually come from the user in the From: address? They are contributing to the problem. They are not helping. use.perl.org
This works now (in my local code, I won't release it for a couple of weeks probably):

use Mac::OSA::Simple;
 
my $script = compile_applescript(<<"EOS");
on \xC7event abcd1234\xC8 (trackname, foo)
    tell application "iTunes"
        play (first track of library playlist 1 whose name is trackname)
        return [artist of current track, foo]
    end tell
end \xC7event abcd1234\xC8
EOS
 
print join "|", $script->call('abcd', '1234', ["I Hung My Head", "garble!"]);

Of course, you could load a compiled AppleScript from disk instead of compiling one in memory, but it is easier to demonstrate it like this. use.perl.org

Mac::Stuff

| | Comments (0)
I've had several requests before to make OSA scripts accept arguments. For example, in Mac::OSA::Simple, you can do, for a saved script:

tell application "iTunes"
    play
end tell

This:

my $play = load_osa_script('itunes_play');
$play->execute;

But what if you want to play a specific track? You don't want to recompile your script, because that is inefficient (it can take awhile to compile an AppleScript, plus you don't want little AppleScripts all over the place).

So I mostly have it worked out that you will be able to pass arguments to your compiled AppleScript. What the code will look like, with the AppleScript:

on &#194;&#171;event abcd1234&#194;&#187; (trackname)
    tell application "iTunes"
        play (first track of library playlist 1 whose name is trackname)
    end tell
end &#194;&#171;event abcd1234&#194;&#187;

and the Perl code:

my $play = load_osa_script('itunes_play');
$play->call('abcd ', '1234', 'Pearls Before Swine');

And on the command line or whatever, you could have simply:

% iplay "Pearls Before Swine"

That's the plan, anyway. I have it working (the low-level stuff). I found a bug in Mac::OSA::OSADoEvent where the reply event was not getting filled out, so it was failing, so it will require a newer Mac::Carbon. I'll do it sometime this summer.

And yes, I know, Mac::Carbon is still slow when loading the extensions, in some cases. I'll work on that this summer, too. :-)

Now Playing: Most Likely You Go Your Way And I'll Go Mine - Bob Dylan (Biograph)

use.perl.org
<pudge/*> (pronounced "PudgeGlob") is thousands of posts over many years by Pudge.

"It is the common fate of the indolent to see their rights become a prey to the active. The condition upon which God hath given liberty to man is eternal vigilance; which condition if he break, servitude is at once the consequence of his crime and the punishment of his guilt."

About this Archive

This page is a archive of entries in the Computers category from June 2003.

Computers: May 2003 is the previous archive.

Computers: July 2003 is the next archive.

Find recent content on the main index or look in the archives to find all content.