Posted by & filed under computación, linux.

980593_10151895858560782_1902462203_o

Depending on which GNU/Linux distribution or graphic environment we are using, we will have available multiple desktops (or workspaces) to distribute open windows in a more organized way. As the number of tasks we are running in parallel increases, so does the need to keep everything organized as to gain productivity.

Ther’s a motto that I linke which says ‘Work smart, not hard’ and a smart way to work is to automatize  (or shorten) tasks we often do manually. This might be as simple as creating a shortcut to a folder we regularly use or as useful as making a script that runs a serie of tasks that otherwise would be awfully tedious to do.

For several reasons I often need to use Windows and as to not having to make other partition (and not to loose time and be able to make parallel tasks in various OS’s); I use a virtual machine. The fact that leads to this post, is that every time I run the vm I then move it to other desktop, to have it full-screen and only a keyboard shortcut move from the windows vm to whatever I’m doing in Ubuntu. The matter is how to avoid doing “Right Click > Move to other desktop > Desktop #”. Searching I found this:

wmctrl

wmctrl is an app which allows us to interact with the windows manager by prompt, in a simple way we can list the open windows, available desktops, change the ammount of desktops, move windows, etc; yo can refer to the man to see the full capabilities of the ap.

In order to move a windows from one desktop to another we only type

wmctrl -r -t

for example

wmctrl -r fire -t 1
#Moves firefox to desktop 1, note that the full name is not required

This if we want to move an already existent windows, but how do we do to a window automatically initiate on other desktop? Unfortunately I haven’t found out how, so If a reader did, leave the hint in the comments, so the solution was in writing a script that initiates the program and then moves the window.

For example this is the little script I did for my virtual machine

#!/bin/bash
/usr/lib/virtualbox/VirtualBox --comment "Windows 7" --startvm "6494c2b9-1f56-47ac-949b-184f505717bd" &
 sleep 1
 wmctrl -r Windows -t 1

Notice the need of a slight sleep, I don’t know why but if both commands are executed immediately one after another it doesn’t move the windows, I assume there is a little delay until the windows manager takes control of the process.

Now only by adding a shortcut pointing to the script, the vm opens and almost instantly it moves to other desktop. This can be extended to multiple windows and features, making the desktop fully customizable.

2 Responses to “LinuxTip: Organizing workspaces”

Leave a Reply

Your email address will not be published. Required fields are marked *