Workspace Control

Forum rules
Before you post please read how to get help
Post Reply
Caltrop
Level 2
Level 2
Posts: 79
Joined: Mon Aug 07, 2017 12:00 pm

Workspace Control

Post by Caltrop » Wed Sep 19, 2018 3:05 pm

Is there any way to control what workspace a program starts in?

Can a program start visible in all workspaces?

I have things set so that programs are only visible in the workspace they start in.
I would like the file manager (caja) to be visible in all workspaces so I do not have to always right-click (left for some of us).

And if possible I would like to control what workspace a program starts in.
ws1 Chromium (left mon)
ws2 VirtualBox (left mon)
ws3 whatever, maybe geany (left mon)
ws4 Terminal (left mon)
all filemanager (right mon)

A bit off topic but can you also control what monitor a program is visible in?

On the left is the BIG external monitor, the right is the laptop.
Dual Monitor.jpg

gm10
Level 13
Level 13
Posts: 4629
Joined: Thu Jun 21, 2018 5:11 pm

Re: Workspace Control

Post by gm10 » Thu Sep 20, 2018 2:40 am

Caltrop wrote:
Wed Sep 19, 2018 3:05 pm
I would like the file manager (caja) to be visible in all workspaces so I do not have to always right-click (left for some of us).
You can right-click any running program on the task bar and check the box to make it active on all workspaces.
Caltrop wrote:
Wed Sep 19, 2018 3:05 pm
And if possible I would like to control what workspace a program starts in.
ws1 Chromium (left mon)
ws2 VirtualBox (left mon)
ws3 whatever, maybe geany (left mon)
ws4 Terminal (left mon)
all filemanager (right mon)

A bit off topic but can you also control what monitor a program is visible in?
Could be easily scripted using the tool wmctrl. The -t parameter moves the window to the specified workspace, the -e parameter lets you set window size and location. wmctrl can modify specific windows, groups or classes of windows but the lazy way is just specify -r :ACTIVE: to make it modify the currently active window. So take this example:

Code: Select all

caja & sleep 1; wmctrl -r :ACTIVE: -e 0,2000,100,1200,600; wmctrl -r :ACTIVE: -t 1
We start caja in the background, sleep for a second waiting for the window to get created (you may have to adjust the duration based on your system and the program you start), then use wmctrl -e to move it to coordinates 2000,100 (this is assuming your left screen is 1920 pixels wide) with a window size of 1200x600, finally we use wmctrl -t to move it to workspace 1, i.e. your second workspace (0 is your first).

To run multiple commands like above directly from a launcher you have to format the command line like this (sh -c "<commands>")

Code: Select all

sh -c "caja & sleep 1; wmctrl -r :ACTIVE: -e 0,2000,100,1200,600; wmctrl -r :ACTIVE: -t 1"
I'm sure you can figure the rest out based on that.

Caltrop
Level 2
Level 2
Posts: 79
Joined: Mon Aug 07, 2017 12:00 pm

Re: Workspace Control

Post by Caltrop » Thu Sep 20, 2018 9:36 pm

I will research wmctrl

as I asked...
but there is no way to automate visible in all workspaces?
I know about right-clicking
I want the program to start visible in all workspaces

well... :?

wmctrl issue

Code: Select all

user-name@system-name ~
$ wmctrl -l
0x00e00003 -1 system-name Bottom Panel
0x00e0001f -1 system-name Top Panel
0x00e00031 -1 system-name Right Panel
0x01c00006 -1 system-name x-caja-desktop
0x05400001  0 system-name scripts - Start every window on all workspaces, with a few exclusions - Ask Ubuntu - Chromium
0x04e00007  3 system-name user-name@system-name ~     <<<<< grabs this, terminal 
0x01c01004  3 system-name user-name                   <<<<< not this, file browser
user-name@system-name ~
$ wmctrl -r "user-name" -b add,sticky
user-name@system-name ~
$ 
the -r option grabs the first 'user-name' 'user-name@system-name ~' not 'user-name' :shock:
it is the later 'user-name' that I want to manipulate
I need to be able to reference the window by name since I do not know the ID
I am trying to automate visible in all workspaces for a single application

caja &; sleep 3; wmctrl -r "window-name" -b add,sticky
that way my file browser will be in all workspaces
if I have a terminal ope at the time the terminal will be modified not the file browser

terminals & browsers also have variable window names
this is a problem...

going to have to brush off the C compiler for this one...
something to launch caja then manipulate the x-win properties

another issue is I use dual monitors
that caused all kinds of headaches with the primary touchscreen
so I expect this to be a mess as well as it already is

why does everything in Linux have to be so complicated... :?:

User avatar
smurphos
Level 8
Level 8
Posts: 2246
Joined: Fri Sep 05, 2014 12:18 am
Location: Britisher...

Re: Workspace Control

Post by smurphos » Fri Sep 21, 2018 2:01 am

wmctrl -lx gives more useful output.

I used to use this script on startup to open a couple of applications and move them around - the awk extracts the WINDOW_ID from the WM_CLASS returned by wmctrl -lx

Code: Select all

#!/bin/bash
#Description: A script to set up applications is specific workspaces - run as start up task
cd
#open inbox
/opt/google/chrome/google-chrome --profile-directory=Default --app-id=pkclgpgponpjmpfokoepglboejdobkpl
#wait until the inbox window opens
until wmctrl -lx | awk '$3~/crx_pkclgpgponpjmpfokoepglboejdobkpl.Google-chrome/ {print $1}'; do
    sleep 0.1
done
#move inbox from workspace 0 to workspace 1
INBOX=$(wmctrl -lx | awk '$3~/crx_pkclgpgponpjmpfokoepglboejdobkpl.Google-chrome/ {print $1}')
wmctrl -i -r $INBOX -t 1
#open sync in held terminal
wake_sync_script_auto.sh
#wait until the sync window opens
until wmctrl -lx | awk '$3~/gnome-terminal-server.Gnome-terminal/ {print $1}'; do
    sleep 0.1
done
#move sync from workspace 0 to workspace 1
TERM=$(wmctrl -lx | awk '$3~/gnome-terminal-server.Gnome-terminal/ {print $1}')
wmctrl -i -r $TERM -t 2

Post Reply

Return to “MATE”