Blog
Welcome to the Trioro Tech Blog.
On this blog we post some of the technical challenges and solutions that we've come across. From time to time we also post comments on new technology that we've come across.

Sunday, May 03, 2009

Skype AppleScript: Switching Audio

I fiddled around today trying to figure out how to get Skype on the Mac to effectively switch from using the buit-in mic and speakers to using my bluetooth headset (and then back again).

I'm using a MacBook Pro and a Jabra BT530 bluetooth headset.

After starting Skype, through trial and error I figured out the right sequence of events to connect my bluetooth headset to the computer and then change both the Mac system preferences and the Skype preferences to make this work:
  • Establish the bluetooth connection to the headset
  • Open the system preferences and change the audio input and output to use the bluetooth headset
  • Open the Skype preferences and change the audio input and output to use the bluetooth headset
It took awhile to realize that going into the system preferences was necessary. Without doing this, the bluetooth headset connection would work, but the audio wouldn't flip over to the headset.

Once this sequence was established, the AppleScript could be written:
Audio%20-%20Bluetooth.scpt

tell application "System Preferences"

activate

set current pane to pane "com.apple.preference.sound"

end tell

tell application "System Events"

if UI elements enabled then

try

tell application process "System Preferences"

tell tab group 1 of window "Sound"

click radio button "Output"

set selected of row 2 of table 1 of scroll area 1 to true

set deviceselected to "Jabra Headset"

set verbal_description to "Bluetooth Headset Now Active"

tell application "Finder"

set volume 7

end tell

end tell

end tell

tell application "System Preferences" to quit

on error

tell me to activate

display dialog "Please plug in the headset." buttons {"Whoops!"} default button 1

end try

else --GUI scripting is disabled

tell application "System Preferences"

activate

set current pane to pane "com.apple.preference.universalaccess"

end tell

display dialog "Please check the box called \"Enable access for assistive devices.\"" buttons {"Okay"} with icon 1 default button 1

end if

end tell


tell application "Skype"

activate

send command "SET AUDIO_OUT IOBluetoothSCOAudioEngine_new:00-1d-82-18-ec-e6" script name "something"

send command "SET AUDIO_IN IOBluetoothSCOAudioEngine_new:00-1d-82-18-ec-e6" script name "something"

end tell

Here is the script to change back to using the built in audio: Audio%20-%20Mac.scpt

tell application "System Preferences"

activate

set current pane to pane "com.apple.preference.sound"

end tell

tell application "System Events"

if UI elements enabled then

try

tell application process "System Preferences"

tell tab group 1 of window "Sound"

click radio button "Output"

set selected of row 1 of table 1 of scroll area 1 to true

set deviceselected to "Built-in Output"

set verbal_description to "Built-in Output Now Active"

tell application "Finder"

set volume 7

end tell

end tell

end tell

tell application "System Preferences" to quit

on error

tell me to activate

display dialog "Please plug in the headset." buttons {"Whoops!"} default button 1

end try

else --GUI scripting is disabled

tell application "System Preferences"

activate

set current pane to pane "com.apple.preference.universalaccess"

end tell

display dialog "Please check the box called \"Enable access for assistive devices.\"" buttons {"Okay"} with icon 1 default button 1

end if

end tell

tell application "Skype"

activate

send command "SET AUDIO_OUT AppleHDAEngineOutput:0" script name "something"

send command "SET AUDIO_IN AppleHDAEngineInput:1" script name "something"

end tell

These scripts were adapted from: http://www.oreillynet.com/mac/blog/2006/07/applescript_audio_output_switc.html

The one trick in modifying this for your own use is to use the "get" script to find out the name of the audio device you want to switch to in Skype.

tell application "Skype"

activate

send command "GET AUDIO_IN" script name "something"

--send command "GET AUDIO_OUT" script name "something"

end tell

As you switch settings in Skype and run this script, change the commented lines to switch between reading the audio input and output settings. Take the output from this script and replace the similar lines in the earlier scripts.

Additionally, when you're in the System preferences you may need to pay attention to which rows in the table on the output screen your devices are listed on. That part of the above script is also highlighted in red.

Labels: , ,

Monday, April 07, 2008

vCard Splitter

I recently wanted to export a group of contacts from Address Book on the Mac to Outlook in Windows.vCard Splitter

The only way to export contacts from the Mac is to "Export Group as vCard". This creates one vCard file that has multiple contacts in it. It's a pretty straight-forward and easy process. The resulting file can be easily attached to an email and sent to someone else.

The tricky part is that Outlook doesn't recognize that there are multiple contacts in the one vCard.

Enter vCard Splitter. vCard Splitter is a Mac utility that will take the single vCard and split it into individual vCards which you can then drag and drop into Outlook.

Note: I found a Windows utility by the same name, but it crashed when I launched it.
Blogged with the Flock Browser

Labels: , ,

Friday, April 04, 2008

Wrong Computer Name (Host) in Terminal

terminal.jpg
File this under "quick fix"...

For awhile now I've been noticing that the host name for my computer has been wrong when I open a new Terminal window in Mac OS X 10.5 (Leopard).

Figuring this had something to do with DNS, I logged into the Windows 2003 Small Business Server that runs our network. The forward zone had my ipaddress and computer name correct, but the reverse zone had the wrong computer name for my ipaddress. The computer name that was listed was in fact the name that I saw in my Terminal window.

I modified the PTR record in the reverse zone for my ip address and gave it my NETBIOS name.

Closed my Terminal window back on the mac.
Problem solved.

I'm not sure what caused this issue to start with, but if it happens again I'll dig deeper into that.
Blogged with the Flock Browser

Labels: ,

Tuesday, February 26, 2008

Safari inline PDF files (Part 2)


I originally blogged about this about 6 months ago. 

Since then I've discovered a few things have changed.

This tag now works in Safari for displaying an inline PDF.
<object data="pdffile.pdf" type="application/pdf"></object>


If you care... here's the background:

I was using this code:
<object classid="clsid:CA8A9780-280D-11CF-A24D-444553540000">
<param name="src" value="pdffilename.pdf">
<embed src="pdffilename.pdf" width="200" height="300"></embed>
<noembed>PDFs are not supported by your browser.</noembed>
</object>
This was working almost across the board - provided that you had the Adobe PDF Viewer plugin installed on your Mac.
This was not working for Firefox on the Mac.

Recent tests show that this code doesn't work any more and the snippit I gave at the beginning of this post solves the problem.

Firefox on the Mac is still unhappy with trying to pull of inline PDF files.

Apparently this plugin will solve that issue. However, I haven't tested that myself.

My solution was to do some browser detection and give people a link to download the pdf if they are using Firefox on the Mac.

Labels: , ,

Saturday, February 23, 2008

Printing on NSLU2 Unslung


Using a Linksys NSLU2, I've got it unslung using v6.10.

Originally I got the NSLU2 because it seemed like a good, cheap way of getting a big networked data drive on my home network.
I quickly realized that the factory firmware from Linux was rather limited.

You get A LOT more functionality when you use Unslung.

The real bonus was that I was also going to get a home print server AND a more powerful shared network drive.

I started by carefully following the instructions to get the NSLU2 working with Unslung.
I chose to use a 250GB external USB drive connected to Port 1 for my Unslung install.
Once Unslung was installed, I was able to use the drive as an networked storage device.

The next step was to install CUPS and get the NSLU2 working as a print server.
I have an HP Photosmart 7350 that I wanted to use with the NSLU2.
All the instructions to add CUPS are available here
.

The actual CUPS installation when pretty smoothly - according to plan.

However, I got stuck once CUPS was installed, trying to get the printer to do anything.
I connected the usb cable to port 2. The port 2 light on the NSLU2 never lights up.
The CUPS instructions say that you should "just try printing" once you get CUPS installed.
I did this by trying to click the "Print Test Page" button for the default hp990c printer.
I got garbage out on my page.

DON'T TRY CHANGING ANY SETTINGS ON THE NSLU2 AT THIS POINT.
  • I tried permissions changes, more software installs on the NSLU2... totally wrong approach.
  • Just leave the base CUPS install and config alone.
The hp990c should be setup as a RAW printer in CUPS on the NSLU2 at this point. If it isn't (because you messed with it) - click "modifiy printer" and change the driver to RAW.


From either a Mac or Windows machine on your network you now setup an Internet Printer.
Windows
  1. Add Printer
  2. Networked Printer
  3. URL - the address should be the entire link to the CUPS address on your NSLU2
    • http://192.168.0.110:631/printers/hp990c
    • make sure to include the "http://"
    • also make sure to include the port ":631"
  4. When prompted, select the print driver that matches your printer
    • In my case for the Photosmart 7350 I had to click "Have Disk"
    • This also required having ALREADY INSTALLED the printer as a local usb connected printer so that the drivers were installed by the HP software in the directory c:\program files\HP Photosmart 11\enu\drivers
  5. Finish the Add Printer install and give it a try by printing a test page!
Mac
  1. DO NOT USE THE SYSTEM PREFERENCES PANEL TO DO THIS
  2. Open a web browser and go to http://localhost:631/admin
    • This is the local admin control panel for the CUPS system that is built in to your Mac
  3. Use the Add Printer wizard
  4. Install using Internet Printing (HTTP)
  5. when you're asked for the printer location, use the entire CUPS address on your NSLU2
    • http://192.168.0.110:631/printers/hp990c
    • make sure to include the "http://"
    • also make sure to include the port ":631"
  6. Finish the wizard and give it a try by clicking "print test page"

Labels: , , , , , , ,

Monday, January 07, 2008

Connecting a Mac to Active Directory

I'm using Leopard (OS X 10.5)...


The follwing outlines a few obstacles that I ran into while connecting my MacBook Pro to a Windows Small Business Server 2003. The obstacles were:

1. The Mac cannot find the Windows Server by name after connecting the Mac to the same network

2. Setting up Active Directory properly proved to be tricky

3. My existing local Mac admin account had the same username as my windows account which really messed things up without warning.

4. Network shares did not appear on the desktop.



Obstacle 1: Windows computer names are not resolving.

I'm not able to use a computer name access any windows resources when I start doing the Active Directory configuration. Ping tests from the terminal do not work when using computer names, but using IP Addresses is fine.

Solution: You need to add a "Search Domain" to your DNS settings

- Open System Preferences -> Network

- Click the Advanced... button

- go to the DNS tab and add a new Search Domain - use your Active Directory domain (ie: 
mydomain.local) -- .local in our case because our AD server is not available on the Internet

- click OK

- don't for get to click "Apply" before you close the Network preferences window


Obstacle 2: Connect the Mac to Active Directory.
The main issue here is that the settings have to be very specific.

Solution: Open Directory Utility (Utilities folder).

- start by clicking on Services

- Select Active Directory and click the pencil icon to edit the settings (you probably have to unlock the settings first by clicking the lock icon)

- the Active Directory Domain needs to be the fully qualified domain name for your active directory server. This was tricky for me because we don't have a domain name pointing at this server. This is an AD server on our internal network. In this case you use the Active Directory domain name followed by .local (ie: mydomain.local)

- I changed the Computer ID to something shorter and easier than what was provided by default

- click the Bind... button - at this point you might be prompted for your Mac admin account information to authenticate - this window looks like the standard authentication window you get any time you need admin permissions. This has nothing to do with connecting to Active Directory yet.

- the next window that opens asks for your Active Directory credentials. The important thing here is the username. You have to include your Windows domain information with your username. In this case using the standard \ character to separate domain and username doesn't work! Use the format username@mydomain.local - again - .local - use the fully qualified name.

- See if this works - you'll be shown status - 5 steps in total as it connects to AD server. I had to retry this about 5 times - an unknown error kept happening at Step 5. I tried a few times without changing any of my info. Came back after lunch and tried it one more time and it worked! Go figure.

- check out the settings under the advanced options - some of them are useful options - especially if you're working on a laptop (create a mobile account). It's probably also a good idea to allow domain admins permission to login as administrators on your mac.


Obstacle 3: After logging in to the Mac with Active Directory credentials things ran really slowly and I got error messages about user folders that couldn't be created.

Solution: Well, to be honest I didn't solve this problem.  My theory is that there was a conflict between the fact that I already had a local account with the name "scott" and that was the same as my active directory account name.  I'm guessing there was some conflict or confusion when the Mac tried to create user settings with the same account name.

I tried deleting various cache files.  I tried deleting my local account with the same name.  I tried changing the username for my active directory account -- this should have worked, but I think there was some serious corruption that happened at the start of this obstacle.  Googling and googling and googling provided various options, none which fixed this issue.

I reinstalled OS X at this point and started over.  Made sure to create my local account with a different name than my windows account.

I'm now able to login to my Mac with my Active Directory account!


Obstacle 4: Network shares did not appear on the desktop

Solution: When I login with my Active Directory user everything works perfectly - including having my networked home directory available automatically.  However, the share to this location was not showing up as an icon on my desktop.  Looks like this is a new Finder feature (sorry, I'm not sure how new since I've just jumped a few OS version numbers here).  The trick is to open the Finder Preferences and check off the option to show network drives on the desktop!

Labels: , , ,