LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 03-05-2013, 12:00 PM   #1
porphyry5
Member
 
Registered: Jul 2010
Location: oregon usa
Distribution: Slackware 14.1, Arch, Lubuntu 18.04 OpenSUSE Leap 15.x
Posts: 518

Rep: Reputation: 24
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.
 
Old 03-05-2013, 12:15 PM   #2
Soderlund
Member
 
Registered: Aug 2012
Posts: 185

Rep: Reputation: 81
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.
 
1 members found this post helpful.
Old 03-05-2013, 12:15 PM   #3
evo2
LQ Guru
 
Registered: Jan 2009
Location: Japan
Distribution: Mostly Debian and CentOS
Posts: 6,724

Rep: Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705
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)
 
1 members found this post helpful.
Old 03-05-2013, 12:33 PM   #4
porphyry5
Member
 
Registered: Jul 2010
Location: oregon usa
Distribution: Slackware 14.1, Arch, Lubuntu 18.04 OpenSUSE Leap 15.x
Posts: 518

Original Poster
Rep: Reputation: 24
Quote:
Originally Posted by Soderlund View Post
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.
 
Old 03-05-2013, 12:50 PM   #5
porphyry5
Member
 
Registered: Jul 2010
Location: oregon usa
Distribution: Slackware 14.1, Arch, Lubuntu 18.04 OpenSUSE Leap 15.x
Posts: 518

Original Poster
Rep: Reputation: 24
Quote:
Originally Posted by evo2 View Post
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
 
Old 03-05-2013, 12:55 PM   #6
evo2
LQ Guru
 
Registered: Jan 2009
Location: Japan
Distribution: Mostly Debian and CentOS
Posts: 6,724

Rep: Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705
Hi,

Quote:
Originally Posted by porphyry5 View Post
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.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Shell script to add password to new user and run automatically. nevr2l899 Linux - Newbie 12 03-04-2013 06:45 AM
Run a script automatically upon user login? FastFeet Linux - General 3 05-21-2009 05:23 AM
printing my own message as each command in a bash script has completed successfully CoffeeKing!!! Linux - Newbie 9 01-26-2009 11:02 AM
Granting root permissions to a bash script than can be run by a user? SirTristan Linux - Newbie 4 06-14-2008 10:29 PM
Getting bash script files to run as root user helptonewbie Programming 5 04-13-2007 09:09 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 03:06 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration