TLDR:
In Gnome Tweak Tool, set "Ctrl key position" to "Caps Lock as Ctrl" and "Caps Lock key behavior" to "Caps Lock is disabled".
Full story:
The problem appears to be how Ubuntu is remapping the CapsLock key. When Gnome Tweak Tool's "Caps Lock key behavior" property is set to "Make Caps an additional Ctrl", xmodmap reports:
xmodmap: up to 4 keys per modifier, (keycodes in parentheses):
shift Shift_L (0x32), Shift_R (0x3e)
lock Caps_Lock (0x42)
control Control_L (0x25), Caps_Lock (0x42), Control_R (0x69)
mod1 Alt_L (0x40), Alt_R (0x6c), Meta_L (0xcd)
mod2 Num_Lock (0x4d)
mod3
mod4 Super_L (0x85), Super_R (0x86), Super_L (0xce), Hyper_L (0xcf)
mod5 ISO_Level3_Shift (0x5c), Mode_switch (0xcb)
The problem appears to be that both lock and control list "Caps_Lock (0x42)". Everything works well until you set focus into a VMWare VM (I tested using VMWare Player). After focusing VMWare's window, xmodmap
will report an empty mapping:
xmodmap: up to 0 keys per modifier, (keycodes in parentheses):
shift
lock
control
mod1
mod2
mod3
mod4
mod5
Running setxkbmap
resets the keyboard mapping and temporarily resolves the issue. Playing with xmodmap
, I found that removing Caps_Lock (0x42) from lock stopped VMWare from flushing the keyboard mappings. But, Ubuntu 14.04 ignores .Xmodmap
files, so there was no simple method to use xmodmap
.
We can fix the root-cause of this situation by changing two settings in Gnome Tweak Tool, as described at the top of this post. Doing so will properly configure the keyboard mappings so that Caps_Lock (0x42) does not show up in two locations:
xmodmap: up to 4 keys per modifier, (keycodes in parentheses):
shift Shift_L (0x32), Shift_R (0x3e)
lock
control Control_L (0x25), Control_L (0x42), Control_R (0x69)
mod1 Alt_L (0x40), Alt_R (0x6c), Meta_L (0xcd)
mod2 Num_Lock (0x4d)
mod3
mod4 Super_L (0x85), Super_R (0x86), Super_L (0xce), Hyper_L (0xcf)
mod5 ISO_Level3_Shift (0x5c), Mode_switch (0xcb)
Best Answer
I think installing Caffeine could help you. It's a nice application which blocks your PC from going to suspend/lock-screen/black-screen when selected applications are running.
You can install it like this (available for precise):
After that just run the program. You will have a little indicator of a coffee mug in your panel.
You can manually activate Caffeine by clicking on the indicator and selecting "Deactivate screensaver" or you go to Preferences and select the applications for which it should activate itself automatically. It's also great for video players or Flash videos.
You can also read all about it on OMG!ubuntu.