Skip to content

Instantly share code, notes, and snippets.

@sdsykes
Created October 12, 2015 10:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sdsykes/37b9657a565b63cefad2 to your computer and use it in GitHub Desktop.
Save sdsykes/37b9657a565b63cefad2 to your computer and use it in GitHub Desktop.
Uses TotalSpaces2 to swap all windows to the other screen
#!/usr/bin/env ruby
require 'totalspaces2'
displays = TotalSpaces2.display_list
if displays.count != 2
puts "Must have 2 displays attached"
exit 1
end
display_ids = displays.map {|display| display[:display_id]}
number_of_spaces = display_ids.map {|display_id| TotalSpaces2.number_of_spaces_on_display(display_id)}
if number_of_spaces[0] != number_of_spaces[1]
puts "Displays must have the same number of spaces"
exit 1
end
windows = TotalSpaces2.window_list
windows.each do |window|
other_display_id = window[:display_id] == display_ids[0] ? display_ids[1] : display_ids[0]
TotalSpaces2.move_window_to_space_on_display(window[:window_id], window[:space_number], other_display_id)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment