You are not logged in.

#1 2010-01-09 02:50:34

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

Xmodmap Reset after Suspend to RAM

Peace all!

Basically my xmodmap settings are all reset to default after waking up from suspend to RAM.

Anyone else having this issue?

Thinkpad X200

Thanks in advance!

Offline

#2 2010-01-09 04:46:03

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

Re: Xmodmap Reset after Suspend to RAM

I'm going to take a guess and say that hal is responsible for this.

A couple of suggestions for things to try:
1) remove anything pertaining to the keymap from /etc/hal/fdi/policy and set their equivalents in /etc/X11/xorg.conf.
2) add a hook in /etc/pm/sleep.d/ (assuming you're using pm-utils) which runs xmodmap on resume (you'll need to export DISPLAY before running xmodmap)

Offline

#3 2010-01-09 06:56:33

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

Re: Xmodmap Reset after Suspend to RAM

1) I don't have an xorg.conf. Thinkpad x200 intel graphic 4500HD.

/etc/pm/sleep.d/11suspend

#!/bin/sh
mixers="Master"
for mixer in $mixers ; do
  /usr/bin/amixer -q sset $mixer mute
  /usr/bin/amixer -q sset $mixer unmute
done

DISPLAY=localhost:0.0 ; export DISPLAY
/home/onguarde/.kde4/Autostart/afterx.sh

The last part is a script which calls xmodmap at startup.

Doesn't seem to be working though. Any suggestions?

Last edited by onguarde (2010-01-09 07:05:55)

Offline

#4 2010-01-09 07:59:25

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

Re: Xmodmap Reset after Suspend to RAM

That script seems fine.  If the script is only intended to be ran on resume, keep in mind pm-utils passes an argument to it which can be used to find the current action (see http://wiki.archlinux.org/index.php/Pm- … _own_hooks).

Ensure /etc/pm/sleep.d/11suspend is executable and try executing /etc/pm/sleep.d/11suspend manually a couple of times in succession to ensure xmodmap doesn't get into a state where it will fail on the second attempt.  If everything seems OK, it might be worth trying to stop hal on suspend, and starting it again on resume (http://wiki.archlinux.org/index.php/Pm- … _on_resume).

Offline

#5 2010-01-10 02:37:25

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

Re: Xmodmap Reset after Suspend to RAM

Hmm.. according to /var/log/pm-suspend.log or running 11suspend manually as root,

/etc/pm/sleep.d/11suspend suspend suspend: xmodmap:  unable to open display 'localhost:0.0'
xset:  unable to open display "localhost:0.0"
xset:  unable to open display "localhost:0.0"
Returned exit code 1.

I guess the export display thing is not working.

Here's the script that is being executed.

#!/bin/bash
DISPLAY=localhost:0.0 ; export DISPLAY

#    Run Xmodmap here (don't rely on arcane auto run by X)
su onguarde -c "xmodmap /home/onguarde/.modmap"

sleep 3
        # Set Autorepeat #
###     RShift Key(Mapped to backspace)
su onguarde -c "xset r 62"
###     RCtrl Key(Mapped to del)
su onguarde -c "xset r 105"

DISPLAY=localhost:0.0 ; export DISPLAY
I tried putting this line both here and in 11suspend itself.

Last edited by onguarde (2010-01-10 02:39:23)

Offline

#6 2010-03-03 18:26:00

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

Re: Xmodmap Reset after Suspend to RAM

I tried fiddling around some more with it.

If I add the following instead, the "inhibition found" error is gone. The hibernate goes on as per normal BUT the commands are still not executed.

DISPLAY=:0.0

#add stuff to execute

# comment this line out if you're manually running this script from a shell
unset DISPLAY

/var/log/pm-suspend.log

/etc/pm/sleep.d/11suspend hibernate hibernate: No protocol specified
xmodmap:  unable to open display ':0.0'
No protocol specified
xset:  unable to open display ":0.0"
No protocol specified
xset:  unable to open display ":0.0"
Returned exit code 1.
Thu Mar  4 02:19:18 SGT 2010: Inhibit found, will not perform hibernate
Thu Mar  4 02:19:18 SGT 2010: Running hooks for thaw

This export display thing is really puzzling me. Appreciate any resource. Googling doesn't seem to help.

Thanks in advance!

Offline

#7 2010-03-07 15:00:04

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

Re: Xmodmap Reset after Suspend to RAM

I adapted the pm-hook example in the wiki.

/etc/pm/sleep.d/11suspend

#!/bin/bash
case $1 in
    hibernate)
        echo "Hey guy, we are going to suspend to disk!"
        ;;
    suspend)
        echo "Oh, this time we're doing a suspend to RAM. Cool!"
        ;;
    thaw)
        echo "oh, suspend to disk is over, we are resuming..."
            # Set Display #
    DISPLAY=:0.0 ; export DISPLAY   
     
    /bin/su - onguarde -c "/usr/bin/xmodmap /home/onguarde/.modmap"
            # Set Autorepeat #
    ###     RShift Key(Mapped to backspace)
    /bin/su - onguarde -c "/usr/bin/xset r 62"
    ###     RCtrl Key(Mapped to del)
    /bin/su - onguarde -c "/usr/bin/xset r 105"

        ###     Test Run a KDE Program
    /bin/su - onguarde -c "/usr/bin/kjots"
       ;;

    resume)
        echo "hey, the suspend to RAM seems to be over..."
        ;;
    *)  echo "somebody is calling me totally wrong."
        ;;
esac

/var/log/pm-suspend.log

/usr/lib/pm-utils/sleep.d/11netcfg hibernate hibernate: :: HOME down    [BUSY]    [DONE]
success.
/etc/pm/sleep.d/11suspend hibernate hibernate: Hey guy, we are going to suspend to disk!
success.

/usr/lib/pm-utils/sleep.d/49bluetooth hibernate hibernate: success.
/usr/lib/pm-utils/sleep.d/98smart-kernel-video hibernate hibernate: success.
/usr/lib/pm-utils/sleep.d/99video hibernate hibernate: success.
Sun Mar  7 22:26:27 SGT 2010: performing hibernate
Sun Mar  7 22:27:30 SGT 2010: Awake.
Sun Mar  7 22:27:30 SGT 2010: Running hooks for thaw
/usr/lib/pm-utils/sleep.d/99video thaw hibernate: success.
/usr/lib/pm-utils/sleep.d/98smart-kernel-video thaw hibernate: success.
/usr/lib/pm-utils/sleep.d/49bluetooth thaw hibernate: success.
/etc/pm/sleep.d/11suspend thaw hibernate: oh, suspend to disk is over, we are resuming...
success.

/usr/lib/pm-utils/sleep.d/11netcfg thaw hibernate: :: HOME up    [BUSY]    [DONE]
success.

The above export display works because the kjots KDE application runs after resuming. BUT the xmodmap parts still refuses to work.

As before, it works fine when I execute the same script from konsole.

Appreaciate any advice! Seriously stumped.

Last edited by onguarde (2010-03-07 15:04:19)

Offline

#8 2010-03-09 07:28:19

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

Re: Xmodmap Reset after Suspend to RAM

Can you determine whether xmodmap fails or whether it succeeds and the keymap is then reverted?

In the latter case, I'd be tempted to remove hal which I'm fairly confident is the source of the problem anyway.  The removal of hal is not trivial and will require at least rebuilding a few packages with hal support disabled and reconfiguring xorg.conf.  I've removed hal from my system and can say the whole process isn't too painful and took only an hour or two to complete.

Offline

#9 2010-03-09 13:48:59

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

Re: Xmodmap Reset after Suspend to RAM

Thanks for the reply!

I'm not sure how to determine if it is even executed. As shown above, the script itself is executed. Only the xmodmap parts doesn't seem to have an effect.

Isn't HAL required for basic stuff like automounting of usb and such? Is there any workaround?

Offline

#10 2010-03-09 22:02:11

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

Re: Xmodmap Reset after Suspend to RAM

To my knowledge, xmodmap will always provide output if it fails.  So it is sufficient to check by directing any output to disk.

...
/bin/su - onguarde -c "/usr/bin/xmodmap /home/onguarde/.modmap &> /home/onguarde/xmodmap-output"
...

As for automounting, devicekit has been proposed to replace hal in the future, though I'm not sure how well it will currently integrate with your environment.  I recall that Ubuntu has successfully transitioned away from hal, so I suspect it's already possible to integrate devicekit with most environments.

Offline

#11 2010-03-10 12:02:35

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

Re: Xmodmap Reset after Suspend to RAM

Hmm , adding that only proces a 0 byte file. i.e there's no output/errors when the command is run.

Then, why isn't it working? It seems I'm the only one using xmodmap with suspend....

Offline

#12 2010-03-10 12:21:55

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

Re: Xmodmap Reset after Suspend to RAM

From this you can assume that xmodmap is running successfully.  I believe hal is then coming in and applying a vanilla layout for that keyboard.  I see two options: prevent hal from modifying the layout (I don't know how to do this) or try to have xmodmap run after hal makes its changes (e.g., sleep for a couple of seconds in your script before invoking xmodmap).

Last edited by chpln (2010-03-10 12:23:24)

Offline

#13 2010-05-21 15:18:02

jrouquie
Member
Registered: 2010-05-21
Posts: 1

Re: Xmodmap Reset after Suspend to RAM

chpln wrote:

try to have xmodmap run after hal makes its changes (e.g., sleep for a couple of seconds in your script before invoking xmodmap).

Indeed, the following script works for me. Notice the "sleep 3" and the "&".
I'm using Ubuntu 10.4 Lucid Lynx intead of Archlinux, but thanks, your suggestion solved the problem!

#!/bin/bash
case $1 in
    hibernate)
        echo "Hey guy, we are going to suspend to disk!"
        ;;
    suspend)
        echo "Oh, this time we're doing a suspend to RAM. Cool!"
        ;;
    thaw|resume)
        echo "oh, suspend is over, we are in $1 phase..."
            # Set Display #
    DISPLAY=:0.0 ; export DISPLAY
    /bin/su - me -c "sleep 3; /usr/bin/xmodmap /home/me/.xmodmaprc" &
        ;;
    *)  echo "somebody is calling me totally wrong."
        ;;
esac

Offline

#14 2012-01-31 13:45:56

koikahin
Member
Registered: 2012-01-31
Posts: 1

Re: Xmodmap Reset after Suspend to RAM

I know this is an old thread, but since I faced this problem today I guess this is still relevant.
Onguarde, jrouquie: doing

su - <user>

will not carry the environment. DISPLAY will not be carried to the subshell if you do su followed with a hypen.

E.g:

sri@srikanths-lt:~$ export test=a
sri@srikanths-lt:~$ su - sri
Password: 
sri@srikanths-lt:~$ echo $test

sri@srikanths-lt:~$ exit
logout
sri@srikanths-lt:~$ su sri
Password:
sri@srikanths-lt:~$ echo $test
a
sri@srikanths-lt:~$

Going by that, the following worked for me (notice that I've removed hyphen from the su line):

#!/bin/bash
case $1 in
    hibernate)
        echo "Hey guy, we are going to suspend to disk!"
        ;;
    suspend)
        echo "Oh, this time we're doing a suspend to RAM. Cool!"
        ;;
    thaw|resume)
        echo "oh, suspend is over, we are in $1 phase..."
            # Set Display #
    DISPLAY=:0.0 ; export DISPLAY
    /bin/su me -c "sleep 3; /usr/bin/xmodmap /home/me/.xmodmaprc" &
        ;;
    *)  echo "somebody is calling me totally wrong."
        ;;
esac

Hope this help.

Offline

Board footer

Powered by FluxBB