execute script after desktop loaded?

Posted by Andre on Ask Ubuntu See other posts from Ask Ubuntu or by Andre
Published on 2011-02-10T00:42:27Z Indexed on 2011/02/11 7:33 UTC
Read the original article Hit count: 549

Filed under:
|
|
|
|

I want to execute bash script on startup that opens several terminals in different workspaces. Script works just fine if I call it from terminal, but it doesn't work if executed from crontab using @reboot:

#!/usr/bin/env bash

#1 make sure we have enough workspaces
gconftool-2 --set -t int /apps/metacity/general/num_workspaces 7

#2. Launch programs in these terminals
wmctrl -s 6
gnome-terminal --full-screen --execute bash -c "tmux attach; bash"
wmctrl -s 5
gnome-terminal --full-screen --execute bash -c "weechat-curses; bash"
wmctrl -s 4
gnome-terminal --full-screen --execute bash -c "export TERM=xterm-256color; mutt; bash"
wmctrl -s 3 
gnome-terminal --full-screen
wmctrl -s 2
gnome-terminal --full-screen
wmctrl -s 1
gnome-terminal --full-screen
wmctrl -s 0
google-chrome --start-maximized

I think it's because crontab job triggers before desktop environment is loaded...maybe...? How can I execute this script after desktop environment is loaded? thanks:)

Update 1:

i've started it from crontab initially like this:

@reboot $HOME/andreiscripts/startup.sh >> $HOME/andreiscripts/testlog.txt 2>&1

and was getting these errors:

Cannot open display.
Failed to parse arguments: Cannot open display: 
Cannot open display.
Failed to parse arguments: Cannot open display: 
Cannot open display.
.....

Update 2

I've tried to launch script from System > Preferences > Startup Applications

/home/andrei/andreiscripts/startup.sh >> /home/andrei/Desktop/out.txt 2>&1

but script only opened first gnome-terminal in workspace 6... and wouldn't continue executing the rest of the script until I close that gnome-terminal and so on....

© Ask Ubuntu or respective owner

Related posts about terminal

Related posts about bash