You are not logged in.

#1 2009-12-15 07:20:16

onguarde
Member
Registered: 2008-09-14
Posts: 144

Why Xmodmap in rc.local doesn't work?

Peace all!

I've been finding for a centralised place to put all system-wide startup commands and thought of using rc.local.

However, it doesn't seem to work for xmodmap or xset commands.

http://ubuntuforums.org/showthread.php?t=806582
The link above simply says it doesn't work but it never tells why.

Why wouldn't it work? According to the arch wiki,

keep in mind that it is run after your basic setup (modules/daemons), as the root user, and whether or not X starts.

http://wiki.archlinux.org/index.php/The … 2Frc.local

Since I start my kde via kdm in rc.conf, the xmodmap stuff should be executed after all the kde stuff has loaded. Which means, it would be the same as if I executed the commands via konsole in kde. Am I missing something?

Btw, here's my rc.local,

#!/bin/bash
#
# /etc/rc.local: Local multi-user startup script.

#touch /tmp/itworked

#        Allow root access to X server from onguarde(during su)
export XAUTHORITY=/home/onguarde/.Xauthority

#       Thinkpad Trackpoint Settings - Learnt from configure-trackpoint
#       sysfs.conf doesn't stick on Arch boot scripts
/bin/echo -n 235 > /sys/devices/platform/i8042/serio1/sensitivity
/bin/echo -n 182 > /sys/devices/platform/i8042/serio1/speed
/bin/echo -n 0 > /sys/devices/platform/i8042/serio1/inertia

#       Xmodmap Settings
/usr/bin/xmodmap /home/onguarde/.Xmodmap

touch /tmp/itworked
# Set Autorepeat #
###     RShift Key(Mapped to backspace)
/usr/bin/xset r 62
###     RCtrl Key(Mapped to del)
/usr/bin/xset r 105
###     PageDown Key(Mapped to del) - Deprecated (Different keyboard)
#xset r 117

Btw, i don't think the export command worked either.

If this doesn't work, I thought of storing them in .xinitrc. But the settings won't apply in console mode(no X). Also, I have to sync the same file in other users' home directories.

Thanks in advance!

Last edited by onguarde (2009-12-15 07:24:20)

Offline

#2 2009-12-15 08:41:57

PirateJonno
Forum Fellow
From: New Zealand
Registered: 2009-04-13
Posts: 372

Re: Why Xmodmap in rc.local doesn't work?

i think you have to do it after you've logged in. if you want to remap keys for console too i think there's a lower-level way of doing it (obviously rebinding X keys won't affect the ttys). maybe try http://wiki.archlinux.org/index.php/Extra_Keyboard_Keys or http://wiki.archlinux.org/index.php/Map … o_keycodes?


"You can watch for your administrator to install the latest kernel with watch uname -r" - From the watch man page

Offline

#3 2009-12-15 09:17:01

Mineo
Member
From: Germany
Registered: 2009-12-13
Posts: 24
Website

Re: Why Xmodmap in rc.local doesn't work?

onguarde wrote:

But the settings won't apply in console mode(no X)

Like 'man xmodmap' says, xmodmap can only be used to change keys in X. For the console you have to change the KEYMAP in /etc/rc.conf.

I don't think you should use rc.local to change your X keymap (wiki says so, too).

Last edited by Mineo (2009-12-15 09:17:50)

Offline

#4 2009-12-15 10:01:04

onguarde
Member
Registered: 2008-09-14
Posts: 144

Re: Why Xmodmap in rc.local doesn't work?

Ah, thanks for clearing my misconception about xmodmap.

But still, this doesn't tell why it doesn't work. If it's true that rc.local is run after all the daemons(including kdm), then the command should be executed while I am in X.

Also, is there a global .xinitrc for all users?

Or maybe I'll use inittab...

Last edited by onguarde (2009-12-15 10:07:06)

Offline

#5 2009-12-15 11:44:28

Mr.Elendig
#archlinux@freenode channel op
From: The intertubes
Registered: 2004-11-07
Posts: 4,092

Re: Why Xmodmap in rc.local doesn't work?

onguarde wrote:

Ah, thanks for clearing my misconception about xmodmap.

But still, this doesn't tell why it doesn't work. If it's true that rc.local is run after all the daemons(including kdm), then the command should be executed while I am in X.

Also, is there a global .xinitrc for all users?

Or maybe I'll use inittab...

xmodmap must be run as the user that logs into the X server. rc.local is run as root, also it's run in a different shell than the one the X server runs in. All this prevents it from working.


Evil #archlinux@libera.chat channel op and general support dude.
. files on github, Screenshots, Random pics and the rest

Offline

#6 2009-12-17 21:20:50

onguarde
Member
Registered: 2008-09-14
Posts: 144

Re: Why Xmodmap in rc.local doesn't work?

Here's my .xinitrc,

for some reason, it never seems to be executed at all! I tried putting the full paths to no avail. Any ideas?

#!/bin/sh
# /bin/bash # Try? - Put back the !
# ~/.xinitrc
#
# Executed by startx (run your window manager from here)

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

#       Maybe it's a PATH problem
#PATH="/bin:/usr/bin:/sbin:/usr/sbin"
#export PATH

#       Test if .xinitrc is even executed
/bin/touch /home/onguarde/.xinitworkS

#       Xmodmap Settings
/usr/bin/xmodmap /home/onguarde/.Xmodmap

        # Set Autorepeat #
###     RShift Key(Mapped to backspace)
/usr/bin/xset r 62
###     RCtrl Key(Mapped to del)
/usr/bin/xset r 105

Offline

#7 2009-12-17 22:41:24

chpln
Member
From: Australia
Registered: 2009-09-17
Posts: 361

Re: Why Xmodmap in rc.local doesn't work?

If you are using a login manager, .xinitrc is unlikely to be executed.  The way in which to run a script will depend on your login manager; I don't believe there is a standard method between them.  I've looked into this briefly, KDM appears to be a relatively difficult case.

Alternatively, if you wish to instead use a tty to act as a 'login manager', you can add something like:

if [ "$(tty)" == "/dev/tty1" ]; then
    # Attempt to initialise X on login to tty1.
    /usr/bin/xinit &> .xinit.log
fi

to your ~/.bashrc, ~/.zshrc, or any other shell you might happen to use.  Then add the command to start your WM/DE to .xinitrc.  .xinitrc will be sourced on login as part of 'xinit', bringing up your WM/DE along with it.

EDIT:
KDM appears to execute ~/.xsession under some circumstances.

Last edited by chpln (2009-12-17 22:49:08)

Offline

#8 2009-12-19 02:36:37

onguarde
Member
Registered: 2008-09-14
Posts: 144

Re: Why Xmodmap in rc.local doesn't work?

The code above executes xinit if you login on the first terminal right?
What about when you open an terminal instance inside X? It will try to execute again?

Btw, I think I've had it messing with xsession and what nots. Decided to go the "noob" way via kde4 autostart.

Offline

#9 2009-12-19 04:14:26

chpln
Member
From: Australia
Registered: 2009-09-17
Posts: 361

Re: Why Xmodmap in rc.local doesn't work?

onguarde wrote:

The code above executes xinit if you login on the first terminal right?
What about when you open an terminal instance inside X? It will try to execute again?

It will only attempt xinit when being evaluated directly within tty1.  Try running the 'tty' command under different ttys and in X and you'll see how it works.

Offline

#10 2009-12-23 02:29:42

onguarde
Member
Registered: 2008-09-14
Posts: 144

Re: Why Xmodmap in rc.local doesn't work?

I've decided to settle with the moRe intuitive kde4 autostart method.

The problem now is the "xset" portion below xmodmap doesn't seem to be executed. The rest of it is ok. Sleeping a bit doesn't work either.

The command executes fine in a manually opened konsole or by simply clicking it in dolphin. Basically the xset part sets the autorepeat function for the new keys mapped by xmodmap.

#!/bin/bash

#       Maybe it's a PATH problem
#PATH="/bin:/usr/bin:/sbin:/usr/sbin"
#export PATH

#    Test if .xinitrc is even executed
#touch /home/onguarde/.xinitworkS

#       Xmodmap Settings
xmodmap /home/onguarde/.Xmodmap

#    Sleep a while to allow kde to load first
#/bin/sleep 5

        # Set Autorepeat #
###     RShift Key(Mapped to backspace)
xset r 62
###     RCtrl Key(Mapped to del)
xset r 105
###     PageDown Key(Mapped to del) - Deprecated (Different keyboard)
#xset r 117

Is there any way to debug this? Some logfile perhaps?

Offline

#11 2009-12-28 11:01:26

onguarde
Member
Registered: 2008-09-14
Posts: 144

Re: Why Xmodmap in rc.local doesn't work?

Still not working here... I'm stumped!

The weird thing is it works when I double click the *.sh file in dolphin after kde starts.

Offline

Board footer

Powered by FluxBB