LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   bash; automatically run user script after startx has completed (https://www.linuxquestions.org/questions/programming-9/bash%3B-automatically-run-user-script-after-startx-has-completed-4175452813/)

porphyry5 03-05-2013 12:00 PM

bash; automatically run user script after startx has completed
 
How can I run some of my own scripts automatically after startx has run? The following 3 commands work fine if I enter them in a terminal after startx has completed, but produce no result if I put them in ~/.xinitrc or ~/.fluxbox/startup.
Code:

fsa=($(date))
fsb=${fsa[3]:0:2}
if [[ "$fsb" > "19" || "$fsb" < "06" ]]; then x0; else x100; fi

x0 and x100 are aliases in ~/.bashrc for two of my scripts.

Soderlund 03-05-2013 12:15 PM

Does it work if you put this in your .xinitrc?

Code:

(sleep 3 && <dostuff>) &
exec <window manager or whatever>

Of course it assumes that whatever you exec takes less than 3 seconds to start.

evo2 03-05-2013 12:15 PM

Hi,

did you check your ~/.xsession-errors for hints?

Evo2.

PS. Instead of playing with arrays and substrings you might do better with
Code:

fsb=$(date +%H)

porphyry5 03-05-2013 12:33 PM

Quote:

Originally Posted by Soderlund (Post 4905267)
Does it work if you put this in your .xinitrc?

Code:

(sleep 3 && <dostuff>) &
exec <window manager or whatever>

Of course it assumes that whatever you exec takes less than 3 seconds to start.

Thank you, that did the trick, at least in ~/.fluxbox/startup. Didn't try it in .xinitrc, but assume it would work there too.

porphyry5 03-05-2013 12:50 PM

Quote:

Originally Posted by evo2 (Post 4905268)
Hi,

did you check your ~/.xsession-errors for hints?

Evo2.

PS. Instead of playing with arrays and substrings you might do better with
Code:

fsb=$(date +%H)

Thanks for the hint on date +%H, I always tend to write code to get what I want, rather than read the manual (at least, if its not much trouble).

Code:

~ $ less ~/.xsession-errors~ $ less ~/.xsession-errors
/home/g/.xsession-errors: No such file or directory


evo2 03-05-2013 12:55 PM

Hi,

Quote:

Originally Posted by porphyry5 (Post 4905296)
Thanks for the hint on date +%H, I always tend to write code to get what I want, rather than read the manual (at least, if its not much trouble).

Some years ago I got into the habit of avoiding parsing output whenever possible: I've found it greatly reduces the number of possible bugs.
Quote:

Code:

~ $ less ~/.xsession-errors~ $ less ~/.xsession-errors
/home/g/.xsession-errors: No such file or directory


Hmm, I wonder where you x session logs your errors to.

Cheers,

Evo2.


All times are GMT -5. The time now is 07:57 PM.