1

I would like to know how to open a script in a different workspace while working in another workspace. The script opens different webpages every 2 seconds and it lasts 2 minutes to open all the webpages. It is irritating having to wait finishing all the process. While the process is working I can't do anything because every two seconds another webpage is opened and the screen focuses on that new webpage.

This is an example of the script:

#!/bin/bash

# Defining the screen size
a="$(xrandr | fgrep '*' | awk -F ' ' '{print $1}' | awk -F 'x' '{print $1}')"
b="$(xrandr | fgrep '*' | awk -F ' ' '{print $1}' | awk -F 'x' '{print $2}')"

# First tab
opera --new-window
sleep 1;
wmctrl -r :ACTIVE: -e 1,$((0)),$((0)),$((a)),$((b)) ; 
sleep 2;

# Second tab
opera --new-window
sleep 2;

# Third tab
opera --new-window
sleep 2;

...

# n tab
opera --new-window

I have tried to use wmctrl command sending each new opera tab to second workspace...

wmctrl -s 1 #Switches to workspace 1
opera --new-window &
sleep 2;

... but the screen put the focus in that workspace and I can't work in the program I am using at that moment. So the idea is to work in other program while the script is executing in other workspace.

Other ineffective solution is to keep my workspace in the workspace 1 and to open the new tab in the workspace 2 in a very small time period. I mean:

wmctrl -s 0; # The workspace I am working in.
wmctrl -s 1; opera --new-window & sleep 0.01; #Change to workspace 2 and open the new tab in a short time.
wmctrl -s 0; # Change to workspace 1.
sleep 2; 
wmctrl -s 1; opera --new-window & sleep 0.01; 
wmctrl -s 0 #... and so on. 

This is not effective. I notice the change between workspaces.

I am using: Xubuntu 14.04. Desktop environment Xfce. Window manager Xfwm4.

Any ideas?

andrew.46
  • 38,003
  • 27
  • 156
  • 232
joshsoj
  • 115
  • What desktop environment are you using? Does it still happen as you describe if you have another window maximized? – terdon Aug 04 '17 at 10:52
  • xubuntu 14.04 | xfce | Xfwm4. It still happens when I have another window maximized. – joshsoj Aug 04 '17 at 12:25
  • I don't understand. Why don't you open the program in workspace 1 and then go do whatever you want in workspace 2? I mean, why don't you move to another workspace instead of trying to get the script to open in another one? – terdon Aug 04 '17 at 12:38
  • Each time a new window opens (every 2 seconds), it opens in the second workspace, which makes the second workspace as actived and places the "new tab" on the foreground. The rest of the apps (including the app I am working on) are placed on the background. Every two seconds happens in this way. So no matter which workspace I am working on, each time the second workspace is active with the new tab of the script. – joshsoj Aug 04 '17 at 13:07
  • I see. Does this help? – terdon Aug 04 '17 at 13:16
  • I tried a solution with that command keeping the active workspace in the workspace 1 (wmctrl -s 0) and each time the new tab of the script has to be loaded, it runs in the second workspace. I mean: wmctrl -s 0; wmctrl -s 1; opera --new-window & sleep 0.01; wmctrl -s 0; sleep 2; wmctrl -s 1; opera --new-window & sleep 0.01; wmctrl -s 0 ... and so on. However it doesn't work because I can see the changes between workspaces. – joshsoj Aug 04 '17 at 13:54
  • Please [edit] your question and include all these extra details you added in the comments. Both the details of your system and the commands you tried. Comments are hard to read, easy to miss and can be deleted without warning. – terdon Aug 04 '17 at 14:18

0 Answers0