Auto switch workspaces
Solution 1:
This can also be achieved using wmctrl:
sudo apt-get install wmctrl
Script for wmctrl:
#!/bin/sh
while true
do wmctrl -s 0
sleep 5
wmctrl -s 1
sleep 5
wmctrl -s 2
sleep 5
wmctrl -s 3
sleep 5
done
wmctrl is a more elegant solution; it sends messages to the window manager and can do other things like move windows to a specific workspace or raise them which may also be useful to you. However, the window manager is free to ignore these messages so it is perhaps not the most portable solution.
wmctrl's -a option is the most suitable for your use: it will switch to the correct workspace and then raise the window. This avoids having to keep the windows on the correct workspaces, not minimized, and not obscured by other windows etc.
Solution 2:
This can be achieved using xdotool:
sudo apt-get install xdotool
Use a script something like this to send the workspace switching keyboard shortcuts, assuming Unity workspace layout:
#!/bin/sh
while true
do xdotool key ctrl+alt+Right
sleep 5
xdotool key ctrl+alt+Down
sleep 5
xdotool key ctrl+alt+Left
sleep 5
xdotool key ctrl+alt+Up
sleep 5
done