docs: def _osx_skype_status(status, message):
      """ Updates status and message for Skype IM application on Mac OSX.
  
          `status`
              Status type.
          `message`
              Status message.
          """
  
      # XXX: Skype has a bug with it's applescript support on Snow Leopard
      # where it will ignore the "not exists process" expression when
      # combined with "tell application Skype" and thus launches Skype if
      # it's not running. Obviously, this is what we're trying to avoid.
      #
      # The workaround here is to scan the user process list for Skype and
      # bail if we don't find it.
  
      uid = os.getuid()
  
      for proc in psutil.process_iter():
          try:
              if proc.uids.real == uid and proc.name == 'Skype':
                  skype_running = True
                  break
          except (psutil.AccessDenied, psutil.NoSuchProcess):
              pass
      else:
          skype_running = False
  
      if skype_running:
          code = SKYPE_CODE_MAP[status]  # map status code
          message = message.replace('"', '\\"')  # escape message
  
          # build applescript
          #   auto-approve skype security dialog
          #   * hide dialog by setting app hidden
          #   * select allow radio button and click OK on dialog
          #   * restore original app visibility
  
          #   main loop
          #   * while security dialog is shown or app is loading
          #   ** fetch user status to determine if in pending state
          #   ** run auto-approve if still in pending state
  
          #   set status command
          #   set status message (mood)
  
          script = """
           on approve()
            tell application "System Events"
              set vis to the visible of process "Skype"
              set visible of process "Skype" to false
              tell process "Skype"
                set winName to "Skype API Security"
                set rdoBtn to "Allow this application to use Skype"
                if exists (radio button rdoBtn of radio group 1 of window {LC}
                winName) then
                  click radio button rdoBtn of radio group 1 of window winName
                  delay 0.5
                  click button "OK" of window winName
                end if
              end tell
              set visible of process "Skype" to vis
            end tell
           end approve
  
           tell application "Skype"
            set stat to "COMMAND_PENDING"
            repeat until stat is not equal to "COMMAND_PENDING"
             set stat to send command "GET USERSTATUS" script name "focus"
             if stat is equal to "COMMAND_PENDING" then my approve()
             delay 0.5
            end repeat
  
            send command "SET USERSTATUS {code}" script name "focus"
            send command "SET PROFILE MOOD_TEXT {mood}" script name "focus"
           end tell""".format(**{
              'code': code,
              'mood': message,
              'LC': "\xc2\xac"
          })
  
          # run it
          common.shell_process(['osascript', '-e', script])