4

I have a computer hooked up to a television that I am using to show different data. I would like to setup some different programs on different workspaces and have it rotate the workspaces automatically on a timed basis. How would I make this happen?

2 Answers 2

4

Yes, and it is very easy. You just need a tool to press the keys you would press to change the workspace. One of such tools is xdotool. To install it:

 $ sudo apt-get install xdotool

Then you just need to create a script like this one (here I assume you only have 2 workspaces, and you use Ctrl+Alt+Left/Right to change between them, but you can easily extend it to match your needs):

!/bin/bash

TIME=10 # shifts workspace after 10 sec.

while [ 1 ]; do
        sleep $TIME
        xdotool key ctrl+alt+Right
        sleep $TIME
        xdotool key ctrl+alt+Left
done

Don't forget to make it executable. If you create it in /usr/local/bin/workspace_switcher you can do that using

 $ sudo chmod +x /usr/local/bin/workspace_switcher

Then to start it you just have to press Alt+F2 and type workspace_switcher. To stop it, you can use killall workspace_switcher

3

If you use 4 workspaces as default in Ubuntu (and I suspect that this is your case because you said rotate the workspaces), you can use the following script:

#!/bin/bash

#check if xdotool is installed
if [ ! -n "$(dpkg -s xdotool 2>/dev/null | grep 'Status: install ok installed')" ]; then
    echo -e "The package 'xdotool' must to be installed before to run $(basename $0)\nUse 'sudo apt-get install xdotool' command in terminal to install it."
    exit
fi

delay=5 #change as you wish

echo "Press Ctrl+C to finish"

#start with workspace 0 (top left)
xdotool key Ctrl+Alt+Left
xdotool key Ctrl+Alt+Up

#switch workspaces 
while : ; do
    workspace_nr=0
    until [ $workspace_nr = 4 ]; do
        sleep $delay
        case $workspace_nr in 
            0) xdotool key Ctrl+Alt+Right ;;
            1) xdotool key Ctrl+Alt+Down ;;
            2) xdotool key Ctrl+Alt+Left ;;
            3) xdotool key Ctrl+Alt+Up ;;
        esac
        ((workspace_nr++))
    done
done
1
  • This is exactly what I was looking for. This worked perfectly.
    – justingrif
    Oct 29, 2013 at 22:20

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .