====== Setup of LIRC on a mac with IO USB dongle and Creative Infra serial receiver/remote ====== ===== Needs update ===== * osascript is terribly slow, may need to move to scripting bridge or "appscript" at [[http://appscript.sourceforge.net/objc-appscript/install.html]] * TARball uploaded {{:lirc_on_mac.tgz| here }}with current script sources ==== Etc. ==== With prolific usb to serial adapter, download Prolific driver for GUC32 [[http://www.prolific.com.tw/support/files//IO%20Cable/PL-2303/Drivers%20-%20Generic/MacOS/MacOS%2010.x/md_pl2303H_HX_X_dmg_v1.2.1r2.zip|prolific usb driver]] and change /System/Library/Extensions/ProlificUsbSerial.kext/Contents/Info.plist product and vendor ids to 8200 and 1367 respectively. Reload driver via sudo kextload /System/Library/Extensions/ProlificUsbSerial.kext Download & extract [[http://lirc.sourceforge.net|lirc-0.8.2]]. Edit setup.sh, change all references to ttyS0 to tty.usbserial. Edit configure and change ac_default_prefix to /opt/local (since this is what macports already uses). Edit configure and change default dev path (variable devdir) for darwin to /opt/local/lirc/dev (with no ending /). run ./setup.sh choose creative infrablahblah Save and Configure. make make install if make install fails rm /dev/lirc and ln /dev/lirc /opt/local/lirc/dev/lirc Make directory /var/lock Run irw, not lircd yet, and see if you get response on teh remote. done. * not sure why, but had a hard time on the powerpc 12", specifying -d with lircd, THEN running irw works: lircd -d /dev/tty.usbserial;irw set perms on the lircd dev to 666 for normal user access. done. What a fucking pain... LIRC cannot just send a keystroke to a Mac application (wouldn't expect it to be high on their list of to-do's), so it seems the best way is to write another AppleScript wrapper as I did for the iChat widget... FUN! An example is like so for 0.scpt: tell application "System Events" tell application "SlingPlayer" to activate keystroke "0" end tell and in /etc/lircrc file: begin prog = irexec button = 0 config = osascript /Users/catherinezeidler/src/0.scpt end Need to have either a .scpt file for every possible action, or a wrapper app that takes two args- one the application to send to, and two the key to send. Maybe something like "numbers.scpt" which can send 0-9 to any application. Now- after a long spell of troubleshooting, I found a work around to an issue where one cannot pass the application name for a "tell" in applescript via a variable- it can be done, but not inside another Tell... Here's the basic working example of a wrapper: on run argv set argv1 to (item 1 of argv) set argv2 to (item 2 of argv) tell application argv1 to activate tell application "System Events" --tell application argv1 to activate -- THIS ONE DOES NOT WORK keystroke argv2 end tell return argv1 & argv2 end run Encountered more problems when trying to Mute or change system volume, get errors like: "execution error: No user interaction allowed. (-1713)" Too lazy to find a serious fix, there are many suggestions out there. Someone else's volume up/down/mute applescripts are here: http://forum.maccast.com/index.php?showtopic=16462 property currentVol : output volume of (get volume settings) if (output volume of (get volume settings) is 0) then set volume output volume currentVol else set currentVol to output volume of (get volume settings) set volume output volume 0 end if property currentVol : output volume of (get volume settings) if (output volume of (get volume settings) is 0) then set volume output volume currentVol else set tVolume to output volume of (get volume settings) set newVol to round (tVolume - 100 / 15) set volume output volume newVol set currentVol to output volume of (get volume settings) end if property currentVol : output volume of (get volume settings) if (output volume of (get volume settings) is 0) then set volume output volume currentVol else set tVolume to output volume of (get volume settings) set newVol to round (tVolume + 100 / 15) set volume output volume newVol set currentVol to output volume of (get volume settings) end if And finally, leaving this alone for a bit, my lircrc file looks like: begin prog = irexec button = stop config = osascript /Users/catherinezeidler/src/keywrap.scpt SlingPlayer s end begin prog = irexec button = start config = open "/Applications/SlingPlayer.app" end begin prog = irexec button = eject config = ps ax |grep Sling |cut -b1-6 |xargs kill -15 end begin prog = irexec button = 0 config = osascript /Users/catherinezeidler/src/keywrap.scpt SlingPlayer 0 end begin prog = irexec button = 1 config = osascript /Users/catherinezeidler/src/keywrap.scpt SlingPlayer 1 end begin prog = irexec button = 2 config = osascript /Users/catherinezeidler/src/keywrap.scpt SlingPlayer 2 end begin prog = irexec button = 3 config = osascript /Users/catherinezeidler/src/keywrap.scpt SlingPlayer 3 end begin prog = irexec button = 4 config = osascript /Users/catherinezeidler/src/keywrap.scpt SlingPlayer 4 end begin prog = irexec button = 5 config = osascript /Users/catherinezeidler/src/keywrap.scpt SlingPlayer 5 end begin prog = irexec button = 6 config = osascript /Users/catherinezeidler/src/keywrap.scpt SlingPlayer 6 end begin prog = irexec button = 7 config = osascript /Users/catherinezeidler/src/keywrap.scpt SlingPlayer 7 end begin prog = irexec button = 8 config = osascript /Users/catherinezeidler/src/keywrap.scpt SlingPlayer 8 end begin prog = irexec button = 9 config = osascript /Users/catherinezeidler/src/keywrap.scpt SlingPlayer 9 end begin prog = irexec button = pause config = osascript /Users/catherinezeidler/src/keywrap.scpt SlingPlayer u end begin prog = irexec button = play config = osascript /Users/catherinezeidler/src/keywrap.scpt SlingPlayer p end begin prog = irexec button = next config = osascript /Users/catherinezeidler/src/keywrap.scpt SlingPlayer l end begin prog = irexec button = ffwd config = osascript /Users/catherinezeidler/src/keywrap.scpt SlingPlayer f end begin prog = irexec button = rrev config = osascript /Users/catherinezeidler/src/keywrap.scpt SlingPlayer r end begin prog = irexec button = shift config = osascript /Users/catherinezeidler/src/keywrap.scpt SlingPlayer = end begin prog = irexec button = mouse config = osascript /Users/catherinezeidler/src/keywrap.scpt SlingPlayer - end begin prog = irexec button = mute config = osascript /Users/catherinezeidler/src/keywrap.scpt Volume m end begin prog = irexec button = vol+ config = osascript /Users/catherinezeidler/src/keywrap.scpt Volume u end begin prog = irexec button = vol- config = osascript /Users/catherinezeidler/src/keywrap.scpt Volume d end And the wrapper now looks like: property currentVol : output volume of (get volume settings) on run argv set argv1 to (item 1 of argv) set argv2 to (item 2 of argv) if argv1 is not "Volume" then tell application argv1 to activate tell application "System Events" --tell application argv1 to activate --if argv2 = "1" then keystroke argv2 --else --keystroke "2" --end if end tell --get id of application "SlingPlayer" return argv1 & argv2 end if if argv1 = "Volume" then if argv2 = "m" then --MUTE if (output volume of (get volume settings) is 0) then tell application "System Events" set volume output volume currentVol return "Un-Muted" end tell else tell application "System Events" set currentVol to output volume of (get volume settings) set volume output volume 0 return "Muted" end tell end if end if --Vol Up if argv2 = "u" then if (output volume of (get volume settings) is 0) then tell application "System Events" set volume output volume currentVol end tell else tell application "System Events" set tVolume to output volume of (get volume settings) set newVol to round (tVolume + 100 / 15) set volume output volume newVol set currentVol to output volume of (get volume settings) end tell end if end if --Vol Down if argv2 = "d" then if (output volume of (get volume settings) is 0) then tell application "System Events" set volume output volume currentVol end tell else tell application "System Events" set tVolume to output volume of (get volume settings) set newVol to round (tVolume - 100 / 15) set volume output volume newVol set currentVol to output volume of (get volume settings) end tell end if end if end if end run ---- To-do: setup actions for iTunes and VLC, setup start button to rotate between apps iTunes, Sling, and VLC.