You are not logged in.

#1 2009-11-28 03:28:48

Gumper
Member
From: U.S.A.
Registered: 2009-10-26
Posts: 132

[Solved]Can't get commands in .xinitrc to start

I'm trying to run several commands by including them in my .xinitrc file and for some reason they don't want to work.

Is there something wrong with my .xinitrc file?

#!/bin/sh
#
# ~/.xinitrc
#
# Executed by startx (run your window manager from here)

setkeycodes e02f 120 &
xmodmap ~/.Xmodmaprc &
xbindkeys &


# exec gnome-session
exec startkde
# exec startxfce4
# ...or the Window Manager of your choice
# exec xterm

Last edited by Gumper (2009-11-28 19:23:45)


Ready yourselves, ready yourselves
Let us shine the light of Jesus in the darkest night
Ready yourselves, ready yourselves
May the powers of darkness tremble as our praises rise .... Casting Crowns-Until The Whole World Hears.

Offline

#2 2009-11-28 07:37:47

Ekimino
Member
From: Maldonado, Uruguay
Registered: 2008-02-26
Posts: 69
Website

Re: [Solved]Can't get commands in .xinitrc to start

Think there is nothing wrong with it. You could try sleeping those 3 commands for a few seconds and wait before KDE starts, maybe kde overrides those whe it initiates.

sleep 5;setkeycodes blah blah ; xbind keys.

Or you could choose for KDE to run those when it initiates.

Cheers.

Offline

#3 2009-11-28 08:00:00

hBd
Member
From: Romania - Cluj Napoca
Registered: 2008-06-08
Posts: 241
Website

Re: [Solved]Can't get commands in .xinitrc to start

try to put the whole path of the commands ex. /usr/bin/xbindkeys

Offline

#4 2009-11-28 09:37:28

Berseker
Member
From: Near Lecco, Italy
Registered: 2008-04-24
Posts: 258

Re: [Solved]Can't get commands in .xinitrc to start

in my opinion you have to put "exec" before every line. Like is done with "gnome-session" and the other commands. .xinitrc is not a normal bash file.

or better, as I see you use KDE, i think you should put xbindkeys in the start programs list of KDE. The others commands, you can put them into your .bashrc

Offline

#5 2009-11-28 09:57:37

Runiq
Member
From: Germany
Registered: 2008-10-29
Posts: 1,053

Re: [Solved]Can't get commands in .xinitrc to start

No, exec just has to be put in front of the last command IIRC. Doesn't your .xinitrc actually work at all, e.g. does it start KDE? Is it executable? If not, try

$ chmod +x .xinitrc

Offline

#6 2009-11-28 11:44:47

pseup
Member
Registered: 2008-06-06
Posts: 103

Re: [Solved]Can't get commands in .xinitrc to start

.xinitrc doesn't need to be executable, and no you don't need `exec` before every command. `exec` gets used to essentially link that process to the X server, when that process exit so does the server. (man exec for a real explanation) So in most cases the WM is the most logical case to use exec.

I'm assuming those commands are not producing errors when you run them after you are in X. Try Ekimino's solution and sleep them for a few seconds or add them to KDE's autostart.

Offline

#7 2009-11-28 14:11:55

Gumper
Member
From: U.S.A.
Registered: 2009-10-26
Posts: 132

Re: [Solved]Can't get commands in .xinitrc to start

I tried the suggestion to try a "sleep". Now my file looks like this.

#!/bin/sh
#
# ~/.xinitrc
#
# Executed by startx (run your window manager from here)

sleep 5
setkeycodes e02f 120 & 
xmodmap ~/.Xmodmaprc &
xbindkeys &


# exec gnome-session
exec startkde
# exec startxfce4
# ...or the Window Manager of your choice
# exec xterm

It still doesn't work. xbindkeys is not starting and the setkeycodes isn't doing anything either. I still get the message "unknown key pressed" in the kernel log. I'm not sure if xmodmap is doing anything either. Would a sleep before "exec startkde" work?

Prior to this I was running "xbindkeys" from kde's autostart folder and that was working, but I'm not sure how to add the other commands there. I guess I could just put those commands on a bash script and link that script in the autostart folder. It just seems cleaner to me to have them all start here in xinitrc.


Ready yourselves, ready yourselves
Let us shine the light of Jesus in the darkest night
Ready yourselves, ready yourselves
May the powers of darkness tremble as our praises rise .... Casting Crowns-Until The Whole World Hears.

Offline

#8 2009-11-28 14:18:09

Ashren
Member
From: Denmark
Registered: 2007-06-13
Posts: 1,229
Website

Re: [Solved]Can't get commands in .xinitrc to start

Are you starting X with the "startx" command?

Offline

#9 2009-11-28 14:24:44

Gumper
Member
From: U.S.A.
Registered: 2009-10-26
Posts: 132

Re: [Solved]Can't get commands in .xinitrc to start

Ashren wrote:

Are you starting X with the "startx" command?

No, I'm not using the "startx" command. It starts by it's self.


Ready yourselves, ready yourselves
Let us shine the light of Jesus in the darkest night
Ready yourselves, ready yourselves
May the powers of darkness tremble as our praises rise .... Casting Crowns-Until The Whole World Hears.

Offline

#10 2009-11-28 14:30:55

Ashren
Member
From: Denmark
Registered: 2007-06-13
Posts: 1,229
Website

Re: [Solved]Can't get commands in .xinitrc to start

If you're using a login manager like gdm and kdm your .xinitrc will not get read. If you're not using a login manager please post some more details on your pre-X setup.

Offline

#11 2009-11-28 14:32:53

pseup
Member
Registered: 2008-06-06
Posts: 103

Re: [Solved]Can't get commands in .xinitrc to start

Appears we all overlooked the simplest solution by making assumptions :P

Offline

#12 2009-11-28 14:38:35

Gumper
Member
From: U.S.A.
Registered: 2009-10-26
Posts: 132

Re: [Solved]Can't get commands in .xinitrc to start

Ashren wrote:

If you're using a login manager like gdm and kdm your .xinitrc will not get read. If you're not using a login manager please post some more details on your pre-X setup.

I'm confused. Isn't "kdm" my login manager and doesn't that start from .xinitrc?


Ready yourselves, ready yourselves
Let us shine the light of Jesus in the darkest night
Ready yourselves, ready yourselves
May the powers of darkness tremble as our praises rise .... Casting Crowns-Until The Whole World Hears.

Offline

#13 2009-11-28 14:50:06

Ashren
Member
From: Denmark
Registered: 2007-06-13
Posts: 1,229
Website

Re: [Solved]Can't get commands in .xinitrc to start

If you are using kdm it explains why your .xinitrc does nothing. As I stated above gdm and kdm does not utilize .xinitrc. I am not well versed with kdm configuration, but I think you can place a script with what you wish to autostart in ~/.kde/env/ folder. Read up on it here: http://docs.kde.org/stable/en/kdebase-runtime/faq/configure.html#id2535781'

Edit: No kdm does not start from .xinitrc. It either starts as daemon in /etc/rc.conf or from /etc/inittab.

Last edited by Ashren (2009-11-28 14:57:27)

Offline

#14 2009-11-28 15:18:16

Gumper
Member
From: U.S.A.
Registered: 2009-10-26
Posts: 132

Re: [Solved]Can't get commands in .xinitrc to start

Ashren wrote:

If you are using kdm it explains why your .xinitrc does nothing. As I stated above gdm and kdm does not utilize .xinitrc. I am not well versed with kdm configuration, but I think you can place a script with what you wish to autostart in ~/.kde/env/ folder. Read up on it here: http://docs.kde.org/stable/en/kdebase-runtime/faq/configure.html#id2535781'

Edit: No kdm does not start from .xinitrc. It either starts as daemon in /etc/rc.conf or from /etc/inittab.

Thanks alot for the explanation. I do have "kdm" in my rc.conf (daemons). I believe that I put "kdm" in the .xinitrc file because the beginners guide instructed me to.

I was able to place a script in the autostart of kde, but it appears that the command "setkeycodes" needs to have root permissions. How do I do that in my script file. Here's what I have so far:

#!/bin/sh


setkeycodes e02f 120 
xmodmap ~/.Xmodmaprc 
xbindkeys

One other quick question. Instead of including this in the autostart folder of Kde, would it also work to put these commands in /etc/rc.local? Is one better than the other?


Ready yourselves, ready yourselves
Let us shine the light of Jesus in the darkest night
Ready yourselves, ready yourselves
May the powers of darkness tremble as our praises rise .... Casting Crowns-Until The Whole World Hears.

Offline

#15 2009-11-28 15:31:05

Ashren
Member
From: Denmark
Registered: 2007-06-13
Posts: 1,229
Website

Re: [Solved]Can't get commands in .xinitrc to start

If you place your script in /etc/rc.local it applies for all users. If you place it in ~/.kde ... it only applies for your user.

Use sudo for setkeycodes. Install sudo if you do not have it installed and add your user to the sudoers file. If you are uncertain how to do this check the wiki.

I believe that I put "kdm" in the .xinitrc file because the beginners guide instructed me to.

Are you REALLY sure about that? wink

Offline

#16 2009-11-28 15:44:11

Gumper
Member
From: U.S.A.
Registered: 2009-10-26
Posts: 132

Re: [Solved]Can't get commands in .xinitrc to start

Ashren wrote:

If you place your script in /etc/rc.local it applies for all users. If you place it in ~/.kde ... it only applies for your user.

Use sudo for setkeycodes. Install sudo if you do not have it installed and add your user to the sudoers file. If you are uncertain how to do this check the wiki.

I believe that I put "kdm" in the .xinitrc file because the beginners guide instructed me to.

Are you REALLY sure about that? wink

Sorry but I'm a goober big_smile I don't have "kdm" in .xinitrc, I have "startkde". You're correct, the wiki didn't tell me to put "kdm" there. It told me to place "startkde" there. roll

I'll try the sudo part. Thanks for the help!


Ready yourselves, ready yourselves
Let us shine the light of Jesus in the darkest night
Ready yourselves, ready yourselves
May the powers of darkness tremble as our praises rise .... Casting Crowns-Until The Whole World Hears.

Offline

Board footer

Powered by FluxBB