sispmctl on macos (aka tale of a ikea lamp)

Nikolaus Gradwohl2009-04-19T10:32:00+02:00

i just installed a little ikea lamp on my wife's desk. no problem so far, the only thing that's really wierd is that the switch of the lamp is next to the power supply. to use it she would have to crawl under the desk and use the switch :-( - NSF


therefore i installed a sis-pm silvershield from gembird (which has 4 sockets that are switchabel via usb) and sispmctl and wrote a simple applescript program. now she can simply click on the script in the menu to turn the litght on/off :-)

read more ...

using Applescript to switch working environments

Nikolaus Gradwohl2007-09-16T17:40:00+02:00

Halve of my time i'm working at a costomers office, everyone has a different network environment, some usuale proxies some don't. in some environments i can use my mailclient, in some i have to use my webmail account.

so i usualy spent the first 5 to 10 minutes of my workday switching network profiles, configuring proxies, changing my subversion configurations, stopping and starting various propgramms, etc

doing repetitive stupid work is something i dont like. im a computer programmer and these are exactly the ones that sould be automated in my oppinion.

so i startet to create a little applescipt for every environment im in. it switches to the correct network profile stops my mailclient where nessesery and changes my current subversion profile, if a proxy is required.

changing the subversion config was the easiest part. i just fired up iterm and changed the config by setting a symlink using a shellscript so i have two copies of my .subversion/servers file one for using the proxy and one for direct connections, and the 'servers' file is a symlink to one of those

well at least i thought it woult be easy ...

the tricky part starts when iTerm is running but has no open windows. then i have to start a Termintal before i can call the shellscript so this is what the shellscript-starting part looks like

tell application "iTerm"
    delay 1
    if (count of windows) is 1 then
        set myterm to (current terminal)
        set myterm to (make terminal)
    end if
    tell myterm
        set mysession to (launch session "Default Session")
        tell the last session
            write text "/Users/nikki/tools/switchsvn2 default"
        end tell
    end tell
end tell

and the corresponding shell script is

cd ~/.subversion
rm servers
ln -s servers.$1 servers

to switch the current network profile applescript UI events need to be activated. Then applescript can be told to click on various menu items like this

tell application "Finder"
end tell

tell application "System Events"
    click menu item "networkprofilename" of menu "Location" 
                  of menu item "Location" of menu "Apple" of menu bar 1 of process "Finder"
end tell    

to start the applescript files i use quicksilver. So all i have to do now when starting my working day in a different environment is fire up quicksilver using - and entering the name of the environment

thats how i like it :-)

read more ...