Scripts

I've written a few

I can code, but mostly I write quick scripts for various purposes. I’ve become pretty infamous at work for the horrendous one-off one-line pipelines I create! I try and make actual scripts a little more readable…

  • denon_demon
    My Denon receiver has a serial port. This serial port can be used to control and report on what the receiver is doing. So if I send it "PW?" then it will report on the power state. This daemon (written for MacOS) will listen for commands on a pipe and communicate with the receiver and write out status entries so it is easy for a program to see what is going on. It also writes out a log file.
    Wed Feb 22 21:21:27 2012 status.Volume = 47 -33.0dB
    Wed Feb 22 21:21:30 2012 status.Volume = 465 -33.5dB
    Wed Feb 22 21:21:59 2012 status.MainSurround = STEREO
    Wed Feb 22 21:22:00 2012 status.MainSurround = STEREO
    Wed Feb 22 21:23:58 2012 status.MainSurround = STEREO
    Wed Feb 22 21:24:02 2012 status.Power = STANDBY
    Wed Feb 22 21:24:02 2012 status.MainZone = OFF

  • denon
    A simple command client to talk to the pipe above, and report on the status of the receiver
    % denon volume -25
              Input: TIVO
       MainSurround: DOLBY PL2 C
           MainZone: ON
               Mute: OFF
              Power: ON
             Volume: 55 -25.0dB
             Z2Mute: OFF
           Z2Volume: 99 ---.-dB
              Zone2: OFF
         Zone2Input: SOURCE

  • phone
    Pulling data from Google contacts using LWP::Simple and XML::XPath rather than WWW::Google::Contacts, which has a horrendous dependency path. Since we're only reading data here we can do things more easily.

  • phone_droid3
    I had a Droid 3 phone. This script will scp the contacts.db and then use DBD::Sqlite to read the data and present it in text format. Why am I doing this? 'Cos I'm stupid :-)

  • movemouse.c
    OK, this is a C program and not a script, but it's small enough so... Basically moves the OS-X mouse cursor to a given co-ordinate. This is because my Mac Mini will reset the cursor to top-left frequently and when I play DVDs then this stops the application menu bar going away, so I use this to move the mouse first.

  • dvdplay
    This is a a bash script that creates applescript to start DVD Player playing a VIDEO_TS directory.

  • dvd
    A script that generates various small applescripts to report/control on DVD Player. Uses dvdplay to start a new DVD. So I can do "dvd pause" to pause playback.

  • play (iTunes 10 version)
    Shell script to create applescript to create an iTunes play list to play the mp3s listed on the command line

  • itunes (iTunes 10 version)
    A script that generates various small applescripts to report/control on iTunes. So I can do "itunes dj" to play the "iTunes DJ" playlist. Unfortunately the latest version of iTunes has broken a lot of functionality; the applescript calls don't work properly any more and a number of controls no longer have directly accessible function calls.

  • itunes
    play
    A version of the "play" and "itunes" scripts that work with Itunes 12. This includes some kludge workarounds for manipulating the shuffle and repeat settings.

  • airplay
    A craptastic script that tries to turn on/off airplay on iTunes so that I can listen to the music on a secondary receiver. Apple don't seem to expose the AirPlay interface so this pretends to click buttons and stuff. Ugh.

  • virsh_build
    A BUILD script for virsh to create VMs. It takes an OS template file, copies it into place, generates an XML file and then calls "virsh define" on the results. I can quickly build a new VM with "virsh_build newvm" using this. The XML is based on a TEMPLATE.xml file. Additional disks can be added to images using virsh_add_disk