Workspace Control

Forum rules
Before you post read how to get help. Topics in this forum are automatically closed 6 months after creation.
Locked
Caltrop

Workspace Control

Post by Caltrop »

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
Last edited by LockBot on Wed Dec 28, 2022 7:16 am, edited 1 time in total.
Reason: Topic automatically closed 6 months after creation. New replies are no longer allowed.
gm10

Re: Workspace Control

Post by gm10 »

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

Re: Workspace Control

Post by Caltrop »

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 18
Level 18
Posts: 8501
Joined: Fri Sep 05, 2014 12:18 am
Location: Irish Brit in Portugal
Contact:

Re: Workspace Control

Post by smurphos »

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
For custom Nemo actions, useful scripts for the Cinnamon desktop, and Cinnamox themes visit my Github pages.
Locked

Return to “MATE”