LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 05-28-2011, 01:11 PM   #1
Weapon S
Member
 
Registered: May 2011
Location: Netherlands
Distribution: Debian, Archlinux
Posts: 262
Blog Entries: 2

Rep: Reputation: 49
Question Creating .xsession makes startx go black


I want to put:
xmodmap -e "pointer =3 2 1"
somewhere in the startup. It seems creating an .xsession is the solution.
But after I create a .xsession file in my home folder, the next time I run startx the screen just turns black. (And only for a short while can I switch to another virtual terminal, before that too becomes impossible). After deleting the file it runs OK again.
I'm not using any login/desktop manager. I use IceWM on Debian Squeeze.
Is there some script/import that has to be present in the .xsession file, or is something else going on?
Also I'd like to know what I should do when I get a black screen. Turning off the PC is such a crude method
Thanks for reading.
 
Old 05-28-2011, 03:59 PM   #2
roygbiiv
LQ Newbie
 
Registered: May 2011
Distribution: Arch Linux
Posts: 25

Rep: Reputation: 13
Quote:
Originally Posted by Weapon S View Post
I want to put:
xmodmap -e "pointer =3 2 1"
somewhere in the startup. It seems creating an .xsession is the solution.
But after I create a .xsession file in my home folder, the next time I run startx the screen just turns black. (And only for a short while can I switch to another virtual terminal, before that too becomes impossible). After deleting the file it runs OK again.
I'm not using any login/desktop manager. I use IceWM on Debian Squeeze.
Is there some script/import that has to be present in the .xsession file, or is something else going on?
Also I'd like to know what I should do when I get a black screen. Turning off the PC is such a crude method
Thanks for reading.
Are you using a .xinitrc to start icewm? In that case, you can use that file instead like this:
Code:
xmodmap -e "pointer =3 2 1"
exec icewm
Whenever you get a blank screen in X, switch to a virtual terminal with ctrl-alt-f1 -> f6 and either issue a shutdown command or restart/kill the X server.

Last edited by roygbiiv; 05-28-2011 at 04:27 PM.
 
1 members found this post helpful.
Old 05-29-2011, 05:16 AM   #3
Weapon S
Member
 
Registered: May 2011
Location: Netherlands
Distribution: Debian, Archlinux
Posts: 262

Original Poster
Blog Entries: 2

Rep: Reputation: 49
Quote:
Originally Posted by roygbiiv View Post
Are you using a .xinitrc to start icewm? In that case,
I'm not sure how xinit knows to start icewm, so I'm reluctant to do what you suggested.
/etc/X11/Xsession and /etc/X11/xinitrc neither contain the word icewm. The files .xsession and .xinitrc don't exist yet either.
To me it's kind of magical icewm even started after I installed it. Thanks for the reply, I'll have to look up how to stop the Xserver from a console.
 
Old 05-30-2011, 02:54 AM   #4
roygbiiv
LQ Newbie
 
Registered: May 2011
Distribution: Arch Linux
Posts: 25

Rep: Reputation: 13
But after boot, do you login to a virtual terminal and start X manually? If so, how do you start X?
 
Old 05-30-2011, 03:30 AM   #5
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983
Quote:
Originally Posted by Weapon S View Post
I want to put:
xmodmap -e "pointer =3 2 1"
somewhere in the startup. It seems creating an .xsession is the solution.
I don't have a .xsession file in my HOME directory. I think the right place is a ~/.Xmodmap file whose content will be simply:
Code:
pointer = 3 2 1
This file is passed as argument to the xmodmap command from /etc/X11/xinit/xinitrc-common file. Here is the relevant code from my CentOS machine:
Code:
usermodmap=$HOME/.Xmodmap

[ -r "$usermodmap" ] && xmodmap "$usermodmap"
Hope this helps.
 
Old 05-30-2011, 09:08 AM   #6
Weapon S
Member
 
Registered: May 2011
Location: Netherlands
Distribution: Debian, Archlinux
Posts: 262

Original Poster
Blog Entries: 2

Rep: Reputation: 49
Arrow

Thanks, this looks promising.
By the way I type "startx" to start up. Hope that is the right command.

Didn't work, colucix. I have the .Xmodmap file in my home folder. Doesn't work.
Code:
#!/bin/sh

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

# This is what I added
usermodmap=$HOME/.Xmodmap
[ -r "$usermodmap" ] && xmodmap -e "$usermodmap"

# The following two lines were the only ones present, except for the header
# invoke global X session script
. /etc/X11/Xsession

# I also tried putting it after that line
 
Old 05-30-2011, 09:58 AM   #7
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983
This is not what I meant. In the $HOME/.Xmodmap file you have to put only the following line
Code:
pointer = 3 2 1
and remove the rest (the first line #!/bin/sh included, since this is not a shell script). The line I cited above were taken from /etc/X11/xinit/xinitrc-common (just check if you have this file and if it contains the proper xmodmap command). Note that in this case the statement
Code:
[ -r "$usermodmap" ] && xmodmap "$usermodmap"
hasn't got the -e option, since it reads the expression from the specified file instead of the command line.
 
Old 05-31-2011, 04:52 PM   #8
Weapon S
Member
 
Registered: May 2011
Location: Netherlands
Distribution: Debian, Archlinux
Posts: 262

Original Poster
Blog Entries: 2

Rep: Reputation: 49
Ha, I missed that "-e". But I already had that pointer = line in .Xmodmap. At this point I don't have a xinitrc-common. Instead, I put it in xinitrc. It didn't work. I tried making a xinitrc-common: didn't work.
I suspect this method isn't going to work exactly like that for Debian, but thanks for trying.
 
Old 05-31-2011, 07:07 PM   #9
segmentation_fault
Member
 
Registered: Sep 2008
Location: Ioannina, Greece
Distribution: Gentoo
Posts: 332

Rep: Reputation: 55
I can't really help you with xinitrc, but if your keyboard is not responding after starting X, you can try the "Magic SysRq Key". Press Alt-SysRq-R and this might give your keyboard back, so you can either kill X server or switch to a VT.
 
1 members found this post helpful.
Old 06-02-2011, 12:11 PM   #10
Weapon S
Member
 
Registered: May 2011
Location: Netherlands
Distribution: Debian, Archlinux
Posts: 262

Original Poster
Blog Entries: 2

Rep: Reputation: 49
That's a nice trick to know. Thanks. I think I'll try reposting this question under Debian.
 
Old 06-02-2011, 01:21 PM   #11
roygbiiv
LQ Newbie
 
Registered: May 2011
Distribution: Arch Linux
Posts: 25

Rep: Reputation: 13
do you have an /etc/X11/config or an /etc/X11/Xsession.options file? you have to enable/uncomment
Code:
allow-user-xsession
in one of these files in order to get your ~/.xsession file to work correctly. please post your /etc/X11/Xsession and your /etc/X11/xinit/xinitrc here.

read about it on this page.

Last edited by roygbiiv; 06-02-2011 at 01:35 PM.
 
1 members found this post helpful.
Old 06-06-2011, 11:19 AM   #12
Weapon S
Member
 
Registered: May 2011
Location: Netherlands
Distribution: Debian, Archlinux
Posts: 262

Original Poster
Blog Entries: 2

Rep: Reputation: 49
Thumbs up It's working now

I don't think there is much to see. But here are the files anyway.
Code:
#!/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

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

exit 0

# vim:set ai et sts=2 sw=2 tw=80:</code>
<code>
Code:
#!/bin/sh
# /etc/X11/xinit/xinitrc
#
# global xinitrc file, used by all X sessions started by xinit (startx)

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

usermodmap = $HOME/.Xmodmap
[ -r "$usermodmap" ] && xmodmap "$usermodmap"
Note: that usermodmap line wasn't working.
Eventually I changed my ~/.xsession file to what roygbiiv said. It works.
...............
Now I discovered .xsessionrc : slightly different file name, but it gets called in addition to what is standard. That is usually exactly the behaviour you want.

Last edited by Weapon S; 04-28-2012 at 07:33 AM.
 
  


Reply

Tags
debian, icewm, startx, xinit, xmodmap, xsession



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
[SOLVED] [startx problem] - startx goes to black/grey screen and comes back to command prompt! iNUKE Ubuntu 13 01-07-2011 01:32 PM
black screen after startx? Manish87 Linux - Hardware 21 11-03-2010 11:22 PM
Switch user makes screen go black glenn69 Linux - Newbie 1 02-23-2007 04:06 PM
startx....black screen. bumjubeo Linux - Newbie 8 01-27-2005 10:13 PM
My scanner only makes black images johnmart Linux - Newbie 6 08-15-2004 12:12 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 09:01 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