LinuxQuestions.org
Help answer threads with 0 replies.
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 10-22-2010, 02:38 PM   #1
buccaneere
Member
 
Registered: Nov 2007
Posts: 213

Rep: Reputation: 16
Where's a cave-man when you need one?


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

xrandr --newmode "1280x1024" 109.00 1280 1368 1496 1712 1024 1027 1034 1063 -hsync +vsync

xrandr --addmode VGA-0 1280x1024

xrandr --output VGA-0 --mode 1280x1024


initctl -q emit login-session-start DISPLAY_MANAGER=gdm

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.
 
Old 10-22-2010, 09:39 PM   #2
buccaneere
Member
 
Registered: Nov 2007
Posts: 213

Original Poster
Rep: Reputation: 16
Thumbs down

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.

Thanks tho'...
http://static.linuxquestions.org/que..._lq/icon13.gif
 
Old 10-22-2010, 09:52 PM   #3
mattca
Member
 
Registered: Jan 2009
Distribution: Slackware 14.1
Posts: 333

Rep: Reputation: 56
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.

Here is my .xinitrc:

Code:
feh --bg-tile /home/matt/media/images/wallpapers/island-2960x1280.jpg
setxkbmap -option "ctrl:nocaps"
xscreensaver -nosplash &
xrandr --output VGA --mode 1680x1050 --output LVDS --mode 1280x800  --pos 1680x470
ratpoison

Last edited by mattca; 10-22-2010 at 09:56 PM.
 
1 members found this post helpful.
Old 10-23-2010, 02:23 AM   #4
buccaneere
Member
 
Registered: Nov 2007
Posts: 213

Original Poster
Rep: Reputation: 16
Quote:
Originally Posted by mattca View Post
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.

Here is my .xinitrc:

Code:
feh --bg-tile /home/matt/media/images/wallpapers/island-2960x1280.jpg
setxkbmap -option "ctrl:nocaps"
xscreensaver -nosplash &
xrandr --output VGA --mode 1680x1050 --output LVDS --mode 1280x800  --pos 1680x470
ratpoison
Thanks! Your explanation seems to be my solution, provided Karmic starts X the same way.

My desired resolution is not detected, so I had to xrandr --newmode, --addmode, then test (good), and make permanent.

Something however is over-writing the resolution setting, BETWEEN the login screen, and desktop load. The desktop loads at the UN-desired resolution.

The Wiki page script mod for gdm is not working as desired, and I've made no mistakes - I'm certain.

So I'm trying to figure a new place in the load sequence to put in the xrandr script.

I'll try your solution when I get back on that machine.

Thanks again there...
 
Old 10-23-2010, 03:01 AM   #5
buccaneere
Member
 
Registered: Nov 2007
Posts: 213

Original Poster
Rep: Reputation: 16
Ugh.Grr..........

I entered the script like you said there:
Quote:
#!/bin/bash
# $Xorg: xinitrc.cpp,v 1.3 2000/08/17 19:54:30 cpqbld Exp $

# /etc/X11/xinit/xinitrc
#
# global xinitrc file, used by all X sessions started by xinit (startx)

# invoke global X session script
. /etc/X11/Xsession


xrandr --newmode "1280x1024" 109.00 1280 1368 1496 1712 1024 1027 1034 1063 -hsync +vsync

xrandr --addmode VGA-0 1280x1024

xrandr --output VGA-0 --mode 1280x1024
and booted, and it loaded, as usual, only the login screen at the desired resolution. Desktop loaded at a lower res.

---------------------------------------------------

So I added the script to the .xsession file also, at the end:
Quote:
#!/bin/sh
#
# /etc/X11/Xsession
#
# global Xsession file -- used by display managers and xinit (startx)

# $Id: Xsession 967 2005-12-27 07:20:55Z dnusinow $

set -e

PROGNAME=Xsession

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
}

errormsg () {
# exit script with error
message "$*"
exit 1
}

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

OPTIONFILE=/etc/X11/Xsession.options

SYSRESOURCES=/etc/X11/Xresources
USRRESOURCES=$HOME/.Xresources

SYSSESSIONDIR=/etc/X11/Xsession.d
USERXSESSION=$HOME/.xsession
USERXSESSIONRC=$HOME/.xsessionrc
ALTUSERXSESSION=$HOME/.Xsession
ERRFILE=$HOME/.xsession-errors

# 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

xrandr --newmode "1280x1024" 109.00 1280 1368 1496 1712 1024 1027 1034 1063 -hsync +vsync

xrandr --addmode VGA-0 1280x1024

xrandr --output VGA-0 --mode 1280x1024


exit 0

# vim:set ai et sts=2 sw=2 tw=80:
And that did the same thing - login screen at the correct resolution, desktop at the lower resolution.

Where can I put the script, that it executes AFTER the desktop loads?

OR

Can I execute it on a delay, like the Update notification applet???
update-notifier --startup-delay=60
How would that work???

Thanks again...

Last edited by buccaneere; 10-23-2010 at 03:03 AM.
 
Old 10-23-2010, 11:36 AM   #6
mattca
Member
 
Registered: Jan 2009
Distribution: Slackware 14.1
Posts: 333

Rep: Reputation: 56
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.
 
1 members found this post helpful.
Old 10-23-2010, 06:08 PM   #7
wje_lq
Member
 
Registered: Sep 2007
Location: Mariposa
Distribution: FreeBSD,Debian wheezy
Posts: 811

Rep: Reputation: 179Reputation: 179
Quote:
Originally Posted by mattca View Post
you'll get much more helpful responses if you change the title of the thread to something a bit more descriptive.
This.
 
Old 10-24-2010, 08:15 PM   #8
buccaneere
Member
 
Registered: Nov 2007
Posts: 213

Original Poster
Rep: Reputation: 16
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)...
 
  


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
LXer: Ubuntu Spelunkers Return to Redmond Cave LXer Syndicated Linux News 0 12-03-2009 02:50 PM
LXer: Cave Dwellers Give Ubuntu Two Thumbs Up LXer Syndicated Linux News 0 09-15-2009 07:40 AM
did Colossal Cave invent IF sarcasm? newbiesforever General 3 07-31-2009 10:47 PM
Hello, been a lurking, crawling outta my cave. DJ_Barney LinuxQuestions.org Member Intro 2 03-02-2008 04:16 PM
waht file have paths for man? man.conf? where? xcore_on Linux - Newbie 4 05-23-2006 09:38 AM

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

All times are GMT -5. The time now is 02:16 PM.

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