!/usr/bin/ruby
require 'totalspaces2'
current_space = TotalSpaces2.current_space
windows = TotalSpaces2.window_list
if current_space < 4
dest_space = current_space + 1
else
dest_space = 1
end
if !windows.empty?
current_space_windows = windows.select {
|window| window[:space_number] == current_space
}
if current_space_windows[0]
TotalSpaces2.move_window_to_space(
current_space_windows[0][:window_id], dest_space)
if current_space_windows[1]
TotalSpaces2.set_front_window(current_space_windows[1][:window_id])
end
end
end