How to open a gnome-terminal in specific workspace and run script within it automatically upon login

OK this is a bit messy.

I run Fedora with gnome on a compiz desktop, I have a script (userstart) that opens my 'standard' environment for all my machines when I login. userstart flips to a specific workspace and then opens the required applications in that workspace then flips to the next workspace....

I'm trying to enhance userstart as occasionally compiz won't kick in in time or the first workspace doesn't get flipped to properly.

So I've added to userstart commands that it detects which workspace it's in before it starts opening the apps on that workspace, however this requires that userstart is called from a 'hand off' script that's active on any desktop workspace.

So how do I automatically after login open a gnome-terminal session on a workspace that automatically calls the userstart script?

Thanks in advance

---------- Post updated at 10:34 AM ---------- Previous update was at 02:56 AM ----------

OK I worked out a way to do this.......

Can you post your solution? I too use Compiz, and I'm trying to find a way to start Xchat on Workspace 4.

OK This took a while for me to get right but.....

Firstly you have to install wmctrl

I then hacked together a script based on some stuff I found online and called it compizwmctrl.

#!/bin/bash

function rotate() {
  # The target face number (begins with 0)
  TVPN=$(( $1 % ${NF} ))

  # The X coordinate of the target viewport
  TVPX=$(( ${TVPN} * ${WW} ))

  # Change to the target viewport
  wmctrl -o ${TVPX},0
}

function usage() {
  echo -e "$(basename $0) v${VER}\n"
  echo -e "Usage:\n"
  echo -e "\t$(basename $0) {left|right|#}\n"
  echo -e "\tWhere:\n"
  echo -e "\t\tleft - rotate the cube to the left"
  echo -e "\t\tright - rotate the cube to the right"
  echo -e "\t\t# - rotate to #th face (begins with 0)\n\n"
}

# The action to be performed. $ACT could be 'left' or 'right' to rotate
# left or right, accordingly. $ACT could also be the number of the face
# to rotate into.
ACT=$(echo $1 |tr '[A-Z]' '[a-z]')

[ "x$ACT" == "x" ] && { usage; exit 1; } || {
  case $ACT in
    left|right|[0-9]|[0-9][0-9])
      ;;
    *)
      usage
      exit 1
      ;;
  esac
}


# The informations about the desktop
INFO=$(wmctrl -d)
# The width of the desktop
DW=$(echo "${INFO}"| awk '{sub(/x[0-9]+/, "", $4); print $4}')
# The width of the workarea
WW=$(echo "${INFO}"| awk '{sub(/x[0-9]+/, "", $9); print $9}')
# The number of faces on the cube
NF=$(($DW/$WW))
# The X coordinate of the viewport
CVPX=$(echo "${INFO}" |awk '{sub(/,[0-9]+/, "", $6); print $6}')
# Current number of the face in all faces (begins with 0)
CVPN=$(( ${CVPX} / ${WW} ))

[ "$ACT" == "right" ] && {
  ACT=$(( ${CVPN} + 1 ))
} || {
  [ "$ACT" == "left" ] && {
    ACT=$(( ${CVPN} - 1 ))
  }
}

rotate ${ACT}


Now I can choose which compiz workspace I want I by simple command for example:-

compizwmctrl 2

(don't forget workspaces start at 0)

then put together a startup script that starts all my sessions the way I want.

I create a profile for a specific gnome terminal session to give me transparency, keep the window title etc.... my profile is called AutoTS

So you might want something like this.....

#!/bin/bash

compizwmctrl 3

gnome-terminal --window-with-profile=AutoTS --geometry=95x26+20+40 --working-directory=~/x-chat --title='X-Chat' &

You may need to put a sleep in before the first compizwmctrl to make sure your compiz session is fully started before you start running the second script, for example I put in a sleep 15 just to give the environment enough time to start properly and settle down before firing all my autostart scripts.

And hopefully that should do it for ya.....

good luck