use IO::Socket; my $sock = new IO::Socket::INET ( LocalHost => '192.168.0.4', LocalPort => '8080', Proto => 'tcp', Listen => 1, Reuse => 1); die "Could not create socket: $!\n" unless $sock; while(1) { my $new_sock = $sock->accept(); $command = <$new_sock>; if ($command=~/skip/){ `osascript -e 'tell application \"iTunes\" to next track'`; } elsif ($command =~/stop/){ `osascript -e 'tell application \"iTunes\" to pause'`; } elsif ($command =~/play/){ `osascript -e 'tell application \"iTunes\" to playpause'`; } elsif ($command =~/plus/){ `osascript -e 'tell application \"iTunes\" to set sound volume to sound volume + 5'`; } elsif ($command =~/minus/){ `osascript -e 'tell application \"iTunes\" to set sound volume to sound volume - 5'`; }elsif ($command =~/repeat/){ `osascript -e 'tell application "QuickTime Player" to step backward movie 1 by 200'`; `osascript -e 'tell application "QuickTime Player" to play movie 1'`; }elsif ($command =~/mpforw/){ `osascript -e 'tell application "system events"' -e 'key code 126' -e 'end tell'`; }elsif ($command =~/mpback/){ `osascript -e 'tell application "system events"' -e 'key code 125' -e 'end tell'`; }elsif($command =~/dvdrep/){ `osascript -e 'tell application "DVD Player" to rewind dvd'`; sleep(2); `osascript -e 'tell application "DVD Player" to play dvd'`; }elsif($command =~/dvdppp/){ `osascript -e 'tell application "DVD Player" to play dvd'`; }elsif($command =~/dvdpse/){ `osascript -e 'tell application "DVD Player" to pause dvd'`; } $curTrack = `osascript -e 'tell application "iTunes" to get name of current track'`; print $new_sock < Mac Control
Wellcome to MacMini
iTunes
$curTrack
Skip Stop Play + - [Replay]
MPlayer
< >
DVD Player
" > Replay
ENDHTML # $lists = `osascript -e 'tell application "iTunes" to get name of playlists'`; $lists =~s/,/
/g; print $new_sock $lists; print $new_sock <
ENDHTML close($new_sock); } close($sock);