ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I need one, cause I know this is "So easy, a cave-man could do it" (and I can't) yikes.
I need a start up script to execute AFTER my desktop loads. It's for display resolution. I've added the same script in 3 places, and all will execute, but not until I do it manually. It's being over-written by another function...
1 script in /etc/gdm/Init/Default (as per Wiki page, which has a syntax error I found yesterday):
Quote:
#!/bin/sh
# Stolen from the debian kdm setup, aren't I sneaky
# Plus a lot of fun stuff added
# -George
PATH="/usr/bin:$PATH"
OLD_IFS=$IFS
if [ -x '/usr/bin/xsplash' ];
then
/usr/bin/xsplash --gdm-session --daemon
fi
gdmwhich () {
COMMAND="$1"
OUTPUT=
IFS=:
for dir in $PATH
(rest of file deleted for brevity)
another in /etc/init.d/display-init
(same 3 xrandr commands)
and another ON the desktop, thinking it would execute after the desktop loads
/home/chuckhtpc/Desktop/display-init
(don't laugh)
Can I create a run level 7, like rc7.d, that will execute after the desktop loads (and everything else)? I symlinked the second script to level 5 rd5.d, and it didn't go through. I haven't tried level 6.
Last edited by buccaneere; 10-22-2010 at 03:02 PM.
After googling some more, I find something that's unfortunate - threads with flaming, and stupid questions and stupid answers, get thousands of hits, and get the top return on google searches.
I see on this page, 2 or 3 threads that are on par with my question. All the rest are by far more difficult and involved.
Of the 44 who've viewed this thread, I bet 33+ know the answer.
Maybe I don't understand what you're trying to do completely, but I just put my xrandr command into my .xinitrc. Not sure how that works on your distro, but on my system I log in on the command line and then type "startx" to enter my window manager. The system runs .xinitrc to initialize your X session. Put whatever you want in there, and then put the command to start your desktop/window manager as the last command.
Maybe I don't understand what you're trying to do completely, but I just put my xrandr command into my .xinitrc. Not sure how that works on your distro, but on my system I log in on the command line and then type "startx" to enter my window manager. The system runs .xinitrc to initialize your X session. Put whatever you want in there, and then put the command to start your desktop/window manager as the last command.
message () {
# pretty-print messages of arbitrary length; use xmessage if it
# is available and $DISPLAY is set
MESSAGE="$PROGNAME: $*"
echo "$MESSAGE" | fold -s -w ${COLUMNS:-80} >&2
if [ -n "$DISPLAY" ] && which xmessage > /dev/null 2>&1; then
echo "$MESSAGE" | fold -s -w ${COLUMNS:-80} | xmessage -center -file -
fi
}
message_nonl () {
# pretty-print messages of arbitrary length (no trailing newline); use
# xmessage if it is available and $DISPLAY is set
MESSAGE="$PROGNAME: $*"
echo -n "$MESSAGE" | fold -s -w ${COLUMNS:-80} >&2;
if [ -n "$DISPLAY" ] && which xmessage > /dev/null 2>&1; then
echo -n "$MESSAGE" | fold -s -w ${COLUMNS:-80} | xmessage -center -file -
fi
}
internal_errormsg () {
# exit script with error; essentially a "THIS SHOULD NEVER HAPPEN" message
# One big call to message() for the sake of xmessage; if we had two then
# the user would have dismissed the error we want reported before seeing the
# request to report it.
errormsg "$*" \
"Please report the installed version of the \"x11-common\"" \
"package and the complete text of this error message to" \
"<debian-x@lists.debian.org>."
}
# initialize variables for use by all session scripts
# attempt to create an error file; abort if we cannot
if (umask 077 && touch "$ERRFILE") 2> /dev/null && [ -w "$ERRFILE" ] &&
[ ! -L "$ERRFILE" ]; then
chmod 600 "$ERRFILE"
elif ERRFILE=$(tempfile 2> /dev/null); then
if ! ln -sf "$ERRFILE" "${TMPDIR:=/tmp}/xsession-$USER"; then
message "warning: unable to symlink \"$TMPDIR/xsession-$USER\" to" \
"\"$ERRFILE\"; look for session log/errors in" \
"\"$TMPDIR/xsession-$USER\"."
fi
else
errormsg "unable to create X session log/error file; aborting."
fi
# truncate ERRFILE if it is too big to avoid disk usage DoS
if [ "`stat -c%s \"$ERRFILE\"`" -gt 500000 ]; then
T=`mktemp -p "$HOME"`
tail -c 500000 "$ERRFILE" > "$T" && mv -f "$T" "$ERRFILE" || rm -f "$T"
fi
exec >>"$ERRFILE" 2>&1
echo "$PROGNAME: X session started for $LOGNAME at $(date)"
# sanity check; is our session script directory present?
if [ ! -d "$SYSSESSIONDIR" ]; then
errormsg "no \"$SYSSESSIONDIR\" directory found; aborting."
fi
# Attempt to create a file of non-zero length in /tmp; a full filesystem can
# cause mysterious X session failures. We do not use touch, :, or test -w
# because they won't actually create a file with contents. We also let standard
# error from tempfile and echo go to the error file to aid the user in
# determining what went wrong.
WRITE_TEST=$(tempfile)
if ! echo "*" >>"$WRITE_TEST"; then
message "warning: unable to write to ${WRITE_TEST%/*}; X session may exit" \
"with an error"
fi
rm -f "$WRITE_TEST"
# use run-parts to source every file in the session directory; we source
# instead of executing so that the variables and functions defined above
# are available to the scripts, and so that they can pass variables to each
# other
SESSIONFILES=$(run-parts --list $SYSSESSIONDIR)
if [ -n "$SESSIONFILES" ]; then
set +e
for SESSIONFILE in $SESSIONFILES; do
. $SESSIONFILE
done
set -e
fi
This is a good example of why I think the "old fashioned way" is simpler. If my computer tries to do too much for me, it makes it difficult to control, or even figure out what it's doing, and where it's doing it. Too many cooks in the kitchen.
It sounds like your system is loading a separate xinit file when your desktop loads. If you can find that file, you can probably just add your xrandr commands to that file. I'm not sure where it would be, but I'd probably start looking in /usr/share. You can also do
Code:
locate xinitrc
to see if there is a global .xinitrc file.
Also, by the way, you'll get much more helpful responses if you change the title of the thread to something a bit more descriptive. Also, this is not a programming issue so much as one of configuration. You are not writing a script, you are configuring your X session (notice my xinitrc did not have #!/bin/bash). You also might get more helpful replies if you ask a mod to move the thread to a more appropriate forum.
Yes - thread titles can make or break the help responses, but often, I see thread responses with an answer to the title, and it's obvious that the details in the description weren't read.
In this case, I got good responses - thanks. (except for the 'other' reply)...
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.