Centos – How to turn on Keyboard Autorepeat permanently on VMware instances of CentOS 6

centoskeyboardvmwarex11

In my lab we have about 40-50 machines, all cloned with the same image of CentOS 6.

For some reason the keyboard auto repeat function decides to randomly turn itself off. Typically we just have students type xset r on which will turn it on. However, all throughout the day and random intervals it turns itself off again. There seems to be nothing in common with the times it does it, or the actions that were being performed on the system at the time it turned off. Recently it will even remain off even after typing xset r on multiple times in a row as both root and a normal user.

It's highly annoying and I can't seem for the life of me to figure out how to permanently turn this on. My only real solution I've thought of was to create a cron job that turns it on every minute or so, however this only seemed to work temporarily. Hours after it starts running it just turns off again and the script seems to be rendered null and void. I've tried adding it to start up scripts, bash_profile, xinit scripts etc. But it will not stay on.

What may be causing this and how can I permanently fix it?

I have found others with similar issues that seem to believe it has something to do with VMware's mouse and keyboard driver that allows seamless integration of desktops. Which could be the case since we do run VMware Workstation on the machines. But sometimes it will happen even if a Virtual Machine isn't running even after a fresh reboot.

UPDATE #1: I found a few potential fixes when searching around. None of which have actually fixed the problem. Here is what I tried:

Potential Fix #1 (Unsuccessful)

Source: VMware update: Keyboard repeat problem solved

Added: divider=1- clocksource=acpi_pm to /etc/grub.conf

This didn't work, nor do I understand why it would work. But was worth a shot. Also this fix is for the Guest OS. My problem isn't related to the Guest, it's a problem with the Host which carries over to Guest OS's to include Windows and Linux VM's.

Potential Fix #2 (Unsuccessful)

Source: VMware and the fubar keyboard effect

This user had a different problem with the keyboard keys remapping randomly. However, I thought I'd try his fix to see if it would fix mine. It was not successful.

Add: xkeymap.nokeycodeMap = true to /etc/vmware/config (if it doesn't exist create it)

http://sgros.blogspot.com/2012/01/keyboard-autorepeat.html

UPDATE #2

So I ran a search to see what files and processes have a handle on XChangeKeyboardControl since that is the function which controls the keyboard auto repeat toggle. Here is the command I ran and my results:

PATH=$PATH:$HOME/bin:/usr/lib:/usr/lib64:/usr/share:/usr/include:/usr/libexec

IFS=:; find $PATH -type f -exec grep -lw XChangeKeyboardControl {} +  

My results were:

/usr/lib/vmware/bin/vmware-remotemks
" "                /vmware-vmx-debug  
" "                /vmware-vmx  
" "                /vmware-vmx-stats  
/usr/lib64/libX11.so.6.3.0  
" "       /gnome-settings-daemon-2.0/libkeyboard.so  
" "       /libxklavier.so.15.0.0  
/usr/share/vm/io/L-master/linuxop-cl1.vmdk  
/usr/include/X11/Xlib.h

I also ran the same command searching for "XAutoRepeatOff" and found this string in /usr/bin/expresskeys which is some sort of program that enables the use of PDA's and tablets style stylus's with the system. But its not running and isn't loaded at startup.

UPDATE#3

Note I verified I am using VMware Workstation 9.0. So all answers I've found that simply suggested upgrading to 8.0+ shouldn't really work.

Still no resolution to this problem.

Best Answer

This is largely a guess, so take this all with a pinch of salt.

I encountered something that may be related where, when vmware was configured to 'grab' and 'release' the keyboard/mouse when the cursor moved in and out of the vmware window. I switched using a specific keypress to grab and release. Basically, in the preferences under keyboard/input control I unchecked most of the options. (I recall switching from the default control+alt to something else, because I suspected a window manager key binding was conflicting somehow.)

At the very, absolute worst, figure out how to add a global startup item that on your centos machine's that executes a script containing:

{ while sleep 2; do xset r on; done } &

Good luck!

P.S. When I had the similar problem, before I figured how to fix it, I would just ssh into my guest linux VMs or rdesktop into my guest windows VMs. In the end, I found that approach to be much nicer. Certainly made it gobs easier to move files back and forth using ssh ControlSockets or the rdesktop -r disk: redirection. Just a thought.

[Edit: Potentially worthwhile details I discovered.]

While poking around trying to find evidence proving GTK at fault, I used strings on the binaries to find a poorly documented configuration statement to increase MKS (mouse keyboard screen) logging. Then I discovered the following strings:

MKS Keyboard: Reset auto-repeat = %d
MKS Keyboard: Restore on-grab auto-repeat = %d
MKS Keyboard: Restore power-on auto-repeat = %d
MKS Keyboard: Auto-repeat = %d
MKS Keyboard: Saved power-on global_auto_repeat = %d
MKS Keyboard: On-grab global_auto_repeat = %d
MKS Keyboard: Saved on-grab global_auto_repeat = %d

Clearly, formatting for conditional log messages. Unfortunately, I've been unable to reproduce your problem so I can't test this myself, but near those log messages I found another string, I suspect a configuration file label. Try adding this to your ~/.vmware/preferences and your VM's .vmx file

mks.x.saveAutoRepeatEveryGrab = "TRUE"

I don't know what that statement causes and it may be the default condition - the very opposite may be necessary. These might enable the logging that would pin the problem down. I don't know if they belong in the VMX or in the preferences, so I would add them to both.

mks.x.printXError = "TRUE"
mks.dbg = "TRUE"
mks.mksDbg = "TRUE"

If you do discover what was causing this, please do let me know.

Good Luck.

Related Question