App-Specific Window Switching

MacOS isn’t great at providing window-level app switching. Apps like Witch and Contexts make this somewhat better, but don’t really provide anything in the way of app-specific switching. In particular, regardless of which app is currently focused, I want to switch to a specific Firefox window by name. I couldn’t find a way to do this with these apps, so I cobbled together this thing using Alfred and Keyboard Maestro, which lets me switch to a particular Firefox window by name, in conjunction with the Window Titler extension:

  • This (terrible) script allows Alfred to display a list of open windows of a given app:
#!/usr/bin/env ruby


command = <<EOF
osascript <<XYZ
tell application "Firefox Developer Edition"
	set ids to the id of (every window whose visible is true)
	set names to the name of (every window whose visible is true)
end tell

set {TID, text item delimiters} to {text item delimiters, "#{DELIMITER}"}
set ids to ids as text
set names to names as text
set text item delimiters to TID

ids & "#{TOP_LEVEL_DELIMITER}" & names

input = `#{command}`
ids, names = input.split(TOP_LEVEL_DELIMITER).map { |x| x.split(DELIMITER).map(&:strip) }
windows =

require 'json'

data = do |id, name|
    type: 'default',
    title: name,
    subtitle: "Window ##{id}",
    arg: name,
    uid: id,
    match: name.gsub(/[\[\]]/, '')

puts ({"items" => data}).to_json
  • On it’s own, Alfred can’t focus a specific Firefox window (and Firefox’s AppleScript support is fairly minimal and doesn’t allow this either). The best workaround I found is to pipe the window title into Keyboard Maestro using the system clipboard and a hotkey. The entire workflow on both ends looks like: