Created
October 12, 2015 10:17
-
-
Save sdsykes/37b9657a565b63cefad2 to your computer and use it in GitHub Desktop.
Uses TotalSpaces2 to swap all windows to the other screen
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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