2

i create a script that is supposed to create a new workspace and that workspace launch four terminal each in given position with a command ran in it.

this is the script.sh

#!/usr/bin/env bash

WS='9:Dashboard'

# Switch to the workspace
i3-msg "workspace $WS"

# Launch terminals and immediately move them to the workspace
gnome-terminal --title=MATRIX -- bash -lc 'cmatrix -C green; exec bash' &
gnome-terminal --title=CLOCK -- bash -lc 'tty-clock -c -C 4; exec bash' &
gnome-terminal --title=SPOTIFY -- bash -lc 'spotify_player; exec bash' &
gnome-terminal --title=ASCII -- bash -lc 'cat ~/.config/dashbord_art.txt; exec bash' &

# Additional wait for all windows to be ready
sleep 0.3

# Position and resize windows
i3-msg '[title="^MATRIX$"] floating enable, border none, move position 105 131, resize set 80>
i3-msg '[title="^CLOCK$"] floating enable, border none, move position 1304 374, resize set 49>
i3-msg '[title="^SPOTIFY$"] floating enable, border none, move position 931 132, resize set 8>
i3-msg '[title="^ASCII$"] floating enable, border none, move position 933 373, resize set 354>

the problem is that when i run it, a new workspace does get created but the terminals open in the current workspace instead.

how to solve that.

2
  • 1
    as a curious fly on the wall ... if you execute this exact set of commands, one at a time, from the command line ... do you get the desired results? Commented Nov 13 at 17:35
  • Does it help to sleep before creating all the terminals? Commented Nov 13 at 18:28

1 Answer 1

2

the solution i found was to use the command for_window in my i3 config file.

basically this command sends windows with a given title, to given workspace.

for_window [title="^MATRIX$"] move to workspace 9:Dashboard, floating enable, border none, mo>
for_window [title="^CLOCK$"] move to workspace 9:Dashboard, floating enable, border none, mov>
for_window [title="^SPOTIFY$"] move to workspace 9:Dashboard, floating enable, border none, m>
for_window [title="^ASCII$"] move to workspace 9:Dashboard, floating enable, border none, mov>
for_window [title="^TYPESPEED$"] move to workspace 9:Dashboard, floating enable, border none,>

the titles are set in the script.sh when i opened the terminal window and so is the workspace.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.