Stupid Mac::Glue Tricks: Safari Slideshow

| | Comments (0)
Safari 3 has greater scripting abilities. This script will allow a user to use the frontmost window, full of tabs, as a basic slideshow. It will start at the current tab (unless the current tab is the last tab, in which case it will start with the first tab) and pause 7 seconds on each before moving on to the next. If you switch the tabs in between, the script will pick up from where you are now, not where you left off.

Of course, requires updating your glue file to Safari 3, if you've not done so. Just re-run sudo gluemac /Applications/Safari.app.

I put an alias to the script in my Safari scripts folder so I can access it through Script Menu.

#!/usr/bin/perl
use warnings;
use strict;
 
our $sleep_time = 7;
 
use Mac::Glue;
 
my $safari = new Mac::Glue 'Safari';
$safari->activate;
 
my $window    = $safari->obj(window => 1);
my $tab_count = $window->count(each => 'tabs');
 
my $current = $window->prop('current tab');
my $index   = $current->prop('index');
 
sleep $sleep_time;
 
my $i = 0;
until ($i >= $tab_count) {
    $i = $index->get;
    $i = 0 if $i >= $tab_count;
    $current->set(to => $window->obj(tab => ++$i));
    sleep $sleep_time;
}

use.perl.org

Leave a comment

<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 Entry

This page contains a single entry by pudge published on September 11, 2007 9:34 AM.

KVI's The Commentators, September 11, 2007 was the previous entry in this site.

KVI 570 Rips On Me For an Hour is the next entry in this site.

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