Fixing FreeNX / NoMachine NX keyboard glitches (e.g. ALTGr)
There is a add-on technology to X or VNC called NX by an Italian company called NoMachine. It's quite useful as it speeds up working on remote desktops via slow network connections (i.e. DSL pipes) substantially.
The libraries that implement NX are released under GPLv2 by that company. A server wrapping up the libraries' functionality is available as closed source from NoMachine or as a free product (GPLv2 again) by Fabian Franz, called FreeNX.
FreeNX itself is amazing as it is written in BASH (with a few helper functions in C). It's also able to mend some of the shortcomings of the NX architecture. E.g. stock NX requires a technical user called "nx" to able to ssh into the NX server with a public/private keypair. FreeNX can work around that for more secure set-ups.
One issue I bumped into quite regularly with Linux clients and Linux hosts from different distributions/localisations is that the keymaps are not compatible. This usually results in the ALTGr key not usable, so German keyboard users can't enter a pipe ("|"), tilde ("~") or a backslash ("\") character. Also the up and down keys are usually resulting in weird characters being pasted to the shell. Now all of that makes using a shell/terminal prompt quite interesting.
Thankfully though, the users from Ubuntuforums have documented a fix
which was also echoed in the German Ubuntuusers forum.
Make sure you have xmodmap installed on both client and server (i.e. emerge -a xmodmap
on Gentoo, apt-get install x11-xserver-utils
on Debian/Ubuntu).
You basically need to export your local keymap and make that known to the server:
scp localxmodmap server:/home/<username>/.Xmodmap
ssh server
# now we're on the server
xmodmap ~/.Xmodmap
# for Debian / Ubuntu users only (to make the Xmodmap permanent)
# Gentoo users don't need this
if [ -e "/etc/debian_version" ] ; then echo "xmodmap ~/.Xmodmap" >> ~/.bashrc ; fi
~/.Xmodmap is sourced by /etc/X11/xinit/xinitrc on Gentoo for each user.
/etc/X11/Xmodmap can be used (by root) to set system-wide defaults.
On Debian you need to e.g. run xmodmap
via .bashrc as given in the above code snippet.
Comments
Display comments as Linear | Threaded
magvar on :
Thanks!! After a bit of editing (removing everything above 225) it also worked a lot better on my Ubuntu (client) -> OpenSolaris (server) connection.
/magvar
Martti Pitkanen on :
Ubuntu Karmic 9.10: After I did as instructed, my server displays in xterm [number 1-256] Keycode: command not found. xterm is uselas now.
Daniel Lange on :
Sounds like you're trying to run .Xmodmap directly in bash. That is wrong. You have to run
xmodmap .Xmodmap
(=xmodmap is the executable you need to run, .Xmodmap is the argument). Make sure you have that or a functional equivalent in .bashrc.Soukron on :
Try editing your .Xmodmap and delete the lines that appear as error. When you delete all error codes, it will works.
That worked for my as in my laptop I had keys for volume, bright, wlan and bluetooth, but in my remote server I didn't, so I had to delete those keys before xmodmad wanted to load .Xmodmap file.
Best regards and thank you for the tip!
andy on :
Unfortunately, this doesnt work for me. I did xmodmap -pke >clientxmodmap on the client Then i did xmodmap -pke >serverxmodmap on the server (via nx of course) then i copied clientxmodmap on the server and, on the server, i issued: diff serverxmodmap clientxmodmap they are exactly the same. I use evdev as keyboard driver on both sides, and them are exactly the same archlinux installation.
I've been able to fix other keyboard issues by typing, remotely on the server, via nx:
xmodmap -e "keycode 98=Up"
xmodmap -e "keycode 104=Down"
xmodmap -e "keycode 100=Left"
xmodmap -e "keycode 102=Right"
xmodmap -e "keycode 99=Page_Up"
xmodmap -e "keycode 105=Page_Down"
xmodmap -e "keycode 106=Insert"
xmodmap -e "keycode 97=Home"
xmodmap -e "keycode 103=End"
xmodmap -e "keycode 107=Delete"
xmodmap -e "keycode 109=Control_R"
xmodmap -e "keycode 113=Alt_R"
and now the keys are correctly mapped, i can check via xev utility, but
"alt_r doesn't seems to receive any keyup event, nor work as a modifier key :("
Tim on :
Doesn't work. Up still takes a screenshot.
Daniel Lange on :
As it works for others you may want to check that you did all steps correctly.
Sven on :
This one worked for me:
alias kb='setxkbmap -v 10 -display $DISPLAY -geometry "pc(pc105)" -keycodes "evdev+aliases(qwerty)" -option ctrl:nocaps -option compose:rctrl'
(from here: http://forums.opensuse.org/english/get-help-here/network-internet/446466-freenx-nomachine-nxclient-keyboard-problems.html )
Laura Rontu on :
You basically need to export your local keymap and make that known to the server: The original advice
xmodmap -pke > localxmodmap
scp localxmodmap server:/home//.Xmodmap ssh server
# now we're on the server
xmodmap ~/.Xmodmap
# for Debian / Ubuntu users only (to make the Xmodmap permanent)
# Gentoo users don't need this
if [ -e "/etc/debian_version" ] ; then echo "xmodmap ~/.Xmodmap" >> ~/.bashrc ; fi
is fine and worked for me but only when I removed from the newly-made ~/.Xmodmap all lines and words xmodmap was complaining on the server side. This was more than one hundred of the 256 lines. What was left, was however sufficient to solve the problems with arrows, alt-gr and other necessary keys. Thank you for the advise!
roberto on :
I've linux server but windows client. I've all keys working except for altgr key (in italian keyboard []{}@ and other important chars) Is there a workarounf? I've upgraded both server and client but nothing
J. A. Calvo on :
I had similar problems in Ubuntu 10.04 and I solved them by just installing libxklavier16. Hope this information is helpful to anyone.
dennis on :
I've fixed this directly in the freenx server code. No workaround is needed anymore. No libxklavier, no setxkbmap and no xmodmap.
fork at https://github.com/debe/freenx.
best, dennis
Daniel Lange on :
Looks like this https://github.com/debe/freenx/commit/3ceee2fca22fb4e519d37f4ddb66e3f3ef761fec is the fix Dennis made.
One line in freenx-server/nxnode. Easy to try out in your existing installs.
Thanks Dennis!
roberto on :
Don't work on my windows client (both opennx and nx client) alt-gr is simply ignored
Daniel Lange on :
The commands can't work for Windows as you have completely different keyboard handling there from Unix. Try the tip in http://www-flc.desy.de/flc/flcwiki/JörgenSamson/NXClientUsermode#Known_Problems_and_Issues
Mat on :
Thanks helped alot!
had problem since upgrade from ubuntu 12.04 to 14.04