SEARCH

Enter your search query in the box above ^, or use the forum search tool.

You are not logged in.

#1 2011-08-24 07:32:36

boh
Member
Registered: 2011-07-25
Posts: 29

[Solved] Adding (xmodmap) script to autostart problem/not working.

Hello.

I would like to make it so that a "compose key", for inserting accented characters, is enabled by default when starting Openbox.

It appears that xmodmap is not loaded by default in Debian, and the approaches to getting it to start automatically, that i have tried, have not been successful.

So instead, i would simply like to run the following command at startup:

xmodmap -e "keysym Insert = Multi_key"

I know the command works as i have tried running it from terminal.

However, adding it to autostart.sh doesn't seem to execute it.

I have tried adding the command under "# Programs that will run after Openbox has started" and "# Programs to launch at startup", but no joy.

It says here:

http://crunchbanglinux.org/wiki/howto/a … ant_to_run

That:

Hmm, cool, can I just type in any script I want to run?

Yes you can, just see if you can execute it successfully from the terminal and everything is fine

So, what am i doing wrong.

Seen as an inelegant solution is better than none, i tried adding to autostart:

gnome-terminal xmodmap -e keysym Insert = Multi_key &

But, that gave the error:

There was an error creating the child process for this terminal

However, running:

gnome-terminal ~/Path/to/script.txt

..does work (where "script.txt" is a chmoded text file containing the command). And, whilst this is an acceptable solution, it is unnecessarily clunky, considering there must be so many more efficient ways of getting the desired result.

I am probably missing something really obvious.

So, any ideas?

Cheers.

Last edited by boh (2011-08-24 11:16:53)


OB4LiFE

Offline

Be excellent to each other!

#2 2011-08-24 08:04:18

luc
#! Die Hard
From: Munich, Germany
Registered: 2010-03-21
Posts: 561

Re: [Solved] Adding (xmodmap) script to autostart problem/not working.

you can not write

gnome-terminal some-command

b/c gnome-terminal is not an interpreter like bash or sh. But you can do

gnome-terminal --command="some-command"

But i have two more points to note here:
Do you really need the xmodmap to run in a terminal window (does it need user interaction)? If not you can just write the command into autostart.sh.
If the command must run in a terminal window I suggest you use xterm instead of some other terminal emulator as your chances are high that it will always be there (maybe some day you decide you don't want to use gnome-terminal anymore and uninstall it).
so i would wirte one of these into autostart.sh

xmodmap -e "keysym Insert = Multi_key" &
xterm -e "xmodmap -e 'keysym Insert = Multi_key'" &

luc

Last edited by luc (2011-08-24 08:05:01)

Offline

#3 2011-08-24 08:06:47

machinebacon
#! unstable
From: China
Registered: 2009-07-02
Posts: 6,631
Website

Re: [Solved] Adding (xmodmap) script to autostart problem/not working.

Hello, there are three (actually four) options:

- check if you have an .xinitrc file and add the command without ampersand (&) there (if .xinitrc doesn't exist, forget it)
- create a ~/.xsession or ~/.Xsession file and add the command there (best option)
- system-wide open /etc/X11/Xsession and add the line there before exit 0 (not recommended)
- there is an autostart folder (!) in .config/ somewhere, but that applies to XFCE

Offline

#4 2011-08-24 08:11:34

machinebacon
#! unstable
From: China
Registered: 2009-07-02
Posts: 6,631
Website

Re: [Solved] Adding (xmodmap) script to autostart problem/not working.

@luc

actually you are right - but I think that autostart.sh indeed doesn't open these commands with options/parameters. The same happens for certain bash scripts called in obmenu IIRC (those with terminator --command="X"), at least I remember that there were some topics about this problem.

If he wants to use the command in his terminal (and just after starting the terminal), OP could simply add the line to his .bashrc file. This is okay if a terminal is started in autostart anyway.

Offline

#5 2011-08-24 08:21:07

xaos52
The Good Doctor
From: Planet of the @s
Registered: 2011-06-24
Posts: 4,602

Re: [Solved] Adding (xmodmap) script to autostart problem/not working.

If you are using gdm, this should work:

sudo echo "keysym Insert = Multi_key" >> /etc/X11/Xmodmap

It will be picked up by this piece of script from /etc/gdm/Init/Default:

sysmodmap=/etc/X11/Xmodmap

XMODMAP=`gdmwhich xmodmap`
if [ "x$XMODMAP" != "x" ] ; then
  if [ "x$GDM_PARENT_DISPLAY" = "x" ]; then
    if [ -f $sysmodmap ]; then
      $XMODMAP $sysmodmap
    fi
  else
    ( DISPLAY=$GDM_PARENT_DISPLAY XAUTHORITY=$GDM_PARENT_XAUTHORITY $XMODMAP -pke ) | $XMODMAP -
  fi

Offline

#6 2011-08-24 10:39:24

boh
Member
Registered: 2011-07-25
Posts: 29

Re: [Solved] Adding (xmodmap) script to autostart problem/not working.

Sorry if i wasn't making myself clear, i have tried simply adding the command:

xmodmap -e "keysym Insert = Multi_key"

...to autostart.sh, and that did not work.

I do not want the terminal to launch and execute the script. It was just that that was the only thing i could make work.

I had tried the "sudo echo "keysym Insert = Multi_key" >> /etc/X11/Xmodmap" command, but it does not stick past a reboot. I had a look in /etc/gdm/Init/Default, and there is this passage:

sysmodmap=/etc/X11/Xmodmap

XMODMAP=`gdmwhich xmodmap`
if [ "x$XMODMAP" != "x" ] ; then
  if [ "x$GDM_PARENT_DISPLAY" = "x" ]; then
    if [ -f $sysmodmap ]; then
      $XMODMAP $sysmodmap
    fi
  else
    ( DISPLAY=$GDM_PARENT_DISPLAY XAUTHORITY=$GDM_PARENT_XAUTHORITY $XMODMAP -pke ) | $XMODMAP -
  fi

So it should be making a call on xmodmap, i suppose. I wonder, is /etc/gdm3/Init/Default even being run at boot?

Creating an .xesseion file (and making it executable) and adding the command to it, did not appear to work. Is there a step i am missing. And unfortunately, neither did adding it to etc/X11/Xsession, or xinitrc.

There has to be a simple method. Perhaps i should go back to trying to get xmodmap to start at boot. It was just causing me lots of hassle, and the idea of just adding the command to autosart.sh seemed so appealing.

Do any of you guys have xmodmap loading automatically?

Thanks for your replies.

And yes, i am using GDM (gdm3). So, make that /etc/gdm3/Init/Default.

Cheers.

Last edited by boh (2011-08-24 10:47:59)


OB4LiFE

Offline

#7 2011-08-24 10:56:37

xaos52
The Good Doctor
From: Planet of the @s
Registered: 2011-06-24
Posts: 4,602

Re: [Solved] Adding (xmodmap) script to autostart problem/not working.

@boh
I checked, and indeed, /etc/gdm/Init/Default is NOT executed when using the openbox session.
Try this:

echo "keysym Insert = Multi_key" >> $HOME/.Xmodmap

It should be picked up by /etc/gdm/Xsession, which IS executed, as this piece of code shows:

usermodmap="$HOME/.Xmodmap"
userxkbmap="$HOME/.Xkbmap"

if [ -f "$userxkbmap" ]; then
    setxkbmap `cat "$userxkbmap"`
    XKB_IN_USE=yes
fi

# xkb and xmodmap don't play nice together
if [ -z "$XKB_IN_USE" ]; then
    if [ -f "$usermodmap" ]; then
       xmodmap "$usermodmap"
    fi
fi

hth

Offline

#8 2011-08-24 11:15:51

boh
Member
Registered: 2011-07-25
Posts: 29

Re: [Solved] Adding (xmodmap) script to autostart problem/not working.

Hi, so i looked in /etc/X11/Xmodmap and it says "keysym Insert = Multi_key". Great, if it was being loaded.

So, i created an.Xmodmap file in my home folder, and tried your new command, and IT WORKED.

Nice one!

Little dialogue came up, asking if i wanted to load .xmodmap, so i did.

And, you showed me that great trick for sending text to files >>. Genius.

Thanks so much.

Thanks to everyone.


OB4LiFE

Offline

#9 2011-08-24 11:25:17

xaos52
The Good Doctor
From: Planet of the @s
Registered: 2011-06-24
Posts: 4,602

Re: [Solved] Adding (xmodmap) script to autostart problem/not working.

Glad I could help.
Please mark the thread as solved by editing the title of your first post and adding [solved]
gl

Offline

#10 2011-08-24 16:27:44

johnraff
nullglob
From: Nagoya, Japan
Registered: 2009-01-07
Posts: 2,935
Website

Re: [Solved] Adding (xmodmap) script to autostart problem/not working.

Glad this issue is now fixed anyway, but I'm curious:

machinebacon wrote:

I think that autostart.sh indeed doesn't open these commands with options/parameters. The same happens for certain bash scripts called in obmenu IIRC (those with terminator --command="X")

It's true that there are limits on what commands you can put in openbox's menu.xml, but I don't know of any for autostart.sh. You should be able to run almost anything there as it's just sourced by a normal shell (but not bash) script. The only thing to watch is you must have a & at the end of each command so the script won't wait for it to exit before going on and starting up openbox. Could that have been the problem with trying to use autostart.sh to run xmodmap -e "keysym Insert = Multi_key"?

Last edited by johnraff (2011-08-31 17:45:23)


John
--------------------
( a boring Japan blog , idle twitterings  and GitStuff )
#! forum moderator

Offline

#11 2011-08-24 19:30:04

boh
Member
Registered: 2011-07-25
Posts: 29

Re: [Solved] Adding (xmodmap) script to autostart problem/not working.

Hi. Johnraff In answer to your question: no, definitely not. I have been using OB for a couple of years now, and am quite familiar with adding things to autostart.

Try it, put the command (xmodmap -e "keysym Insert = Multi_key")in terminal and you will see that when you press "Insert" the cursor no longer goes black, and if you follow it with an e and an ' you will get é. That wont survive a reboot though, and the only solution i found that worked and i tried al the ones suggested in this thread, was to create an .xmodmap file with the following content:

keysym Insert = Multi_key

Cheeers.


OB4LiFE

Offline

#12 2011-08-25 05:39:20

johnraff
nullglob
From: Nagoya, Japan
Registered: 2009-01-07
Posts: 2,935
Website

Re: [Solved] Adding (xmodmap) script to autostart problem/not working.

Hi boh, this is interesting. smile

I tried the command in a terminal and it worked.
I put it in a shell script, executed the script, and it worked.
I added the line 'xmodmap -e "keysym Insert = Multi_key" &' to my ~/.config/openbox/autostart.sh and... it worked. lol

So I don't know why it didn't work for you.
Two ideas:
* Maybe your system needed a bit of time to get ready for the command: would '(sleep 5; xmodmap -e "keysym Insert = Multi_key") &' work?
* Were you editing the same file? My autostart.sh has no lines "# Programs that will run after Openbox has started" or "# Programs to launch at startup".

But anyway, the .Xmodmap solution looks more elegant so let's stick with it!


John
--------------------
( a boring Japan blog , idle twitterings  and GitStuff )
#! forum moderator

Offline

#13 2011-08-25 08:55:39

mynis01
#! Die Hard
From: 127.0.0.1
Registered: 2010-07-02
Posts: 1,963

Re: [Solved] Adding (xmodmap) script to autostart problem/not working.

You can also set this in /etc/default/keyboard in debian squeeze systems. AFAIK settings in this file are applied before x starts, so they will work in a tty even if X doesn't start for whatever reason. From what I've read, in squeeze, this file overwrites the keymap settings that used to be in /etc/defualt/console-setup. Here's what relevant line in mine looks like:

XKBOPTIONS="lv3:ralt_switch,compose:caps,terminate:ctrl_alt_bksp"

This way you kill two birds with one stone; You have a conveniently located compose key, and you get rid of that annoying caps lock button as well! I imagine with what you're trying to do, it would look more like this:

XKBOPTIONS="lv3:ralt_switch,insert:compose,terminate:ctrl_alt_bksp"

If you wanted to use insert as the compose key but still get rid of caps lock, you could change capslock to a second super key for launching applications:

XKBOPTIONS="lv3:ralt_switch,insert:compose,terminate:ctrl_alt_bksp,caps:super"

Offline

#14 2011-08-25 16:29:36

boh
Member
Registered: 2011-07-25
Posts: 29

Re: [Solved] Adding (xmodmap) script to autostart problem/not working.

Hi, Johnraff. Well, i am surprised running the command form autostart worked for you. Very peculiar, as to why it didn't for me, then.  Adding the sleep time is something i did not do, but will keep in mind for next time i am troubleshooting such problems.

Strange too that our ~/.config/openbox/autostart.sh  files have different headings. I think i copied mine over from the example files, that are stored somewhere in /, can't remember where. After doing a little experimenting a while back i can find no perceptible difference in the startup order of programs according to which heading they were placed under.

But yeah, autostart is definitely working for me, as i have it starting up a few programs and such, here it is:

# Run the system-wide support stuff
. $GLOBALAUTOSTART

# Programs to launch at startup
hsetroot ~/wallpaper.png &
dbus-launch gnome-settings-daemon &
#gnome-panel &
#nm-applet &
##leafpad ~/Stuff/2do.txt &

# SCIM support (for typing non-english characters)
export LC_CTYPE=ja_JP.utf8
export XMODIFIERS=@im=SCIM
export GTK_IM_MODULE=scim
export QT_IM_MODULE=scim
scim -d &

# Programs that will run after Openbox has started
#(sleep 2 && fbpanel) &
nautilus -n &
#nautilus --no-desktop &
#gnome-do &
#devilspie &
kupfer --no-splash &
#update-notifier &
#xcompmgr -c -t-5 -l-5 -r4.2 -o.55 &
#wicd-client -n &
#/opt/wicd/autoconnect.py &
#Autoconnect the configured interfaces (eth0 dhcp) &
unclutter -idle 0.9 &
#gnome-terminal -e xset s off &
glipper &
sudo /etc/cron.daily/prelink &
conky -c ~/.conkyrc &
#conky -c /home/egon/.conkyrc2 &
#conky -c /home/egon/.conkyrc3 &
leafpad ~/Stuff/2do.txt &
leafpad ~/Stuff/2do2.txt &
#leafpad ~/Stuff/2fix.txt &
#leafpad ~/Stuff/2list.txt &
gksu xmodmap &

#xautolock -locker ~/Stuff/xdotool -corners ++++  -cornerdelay 0 &

# Set a background (the last bg set with feh)
eval `cat $HOME/.fehbg` &
/draw_background true &

#Disable Nautilus desktop.
gconftool-2 -s -t bool /apps/nautilus/preferences/show_desktop true &
#Do not let Nautilus set the background image.
gconftool-2 -s -t bool /desktop/gnome/background/draw_background true &

Plenty of hashed out things and services that i have left in place should i need them again.


Mynis01, that looks like a thorough solution, and would have the advantage of carrying my preferences across different DEs and WMs, as well as allowing me to insert an accented character into my login password (if i was so security minded).I will stick with the current solution for now, but will refer back to this thread and use yours, next time i am setting up a Debian based system.

As to caps lock, i am one of those that actually use it, i don't know if this is a cultural thing but in the UK people seem to use capslock and, from what i can tell from my US relaives, there people seem to favour using the Shift key, right?

I don't actually use a Super key either, i have remapped CTRL to left Alt, so that CTRL is closer to keys c v x z w q, for easier one handed shorctuts (i grew up on a mac and find that a much more ergonomic place for the most commonly used modifier key), and i have remapped Alt to my left Super key, and use it in conjunction with numbers 1-6 for launching most commonly used apps, and then CTRL +Alt + 1-6 for launching less commonly used apps, takes a bit of memorising but it leaves my letter keys clear for using in conjuntion with Alt for dialougs, i have also remapped right CTRL to replace Alt Gr and Alt to replace right CTRL, so i have an Alt and a CTRL on both sides of the spacebar.

I am a keyboard fiend and this means all shortcuts are available with whatever hand happens not to be propping up my head, holding a coffee, or whatever.

However, i might map Super to my second, orphaned left CTRL, all they way out there on the left edge of the keyboard (stupid place for it to my mind), just for those odd apps that have inbuilt shortcuts  mapped to a Super.

Cheers.


OB4LiFE

Offline

Board footer

Powered by FluxBB

Copyright © 2012 CrunchBang Linux.
Proudly powered by Debian. Hosted by Linode.
Debian is a registered trademark of Software in the Public Interest, Inc.

Debian Logo