Wednesday, 3 December 2008

VMWare and the fubar keyboard effect

Welcome to the Ubuntu community! See my note about this at the end.

Note:
As this is my most popular blog entry, it looks like a lot of people are suffering the same problem. I'm grateful for all the positive feedback - thanks! Feel free to continue to leave feedback, especially if you have more information (or something that doesn't work), or links to related pages. Thanks :)

For what seems like 300 years I've been struggling with the horrible effect of VMWare workstation on my keyboard. I have a perfectly good license for VMWare workstation 4, so I continued to use it regardless of the fact that version 6 is available. (I've since upgraded to version 6, and from the responses from others this fix still works).

This never used to be a problem, but it got successively worse: Once VMWare grabbed the keyboard, many function keys (ctrl, shift, alt, etc) would remap to nothing, or worse, some other key function!

Solution 1
I solved this out-side of vmware thanks to a gentoo-user thread:
  • Run `setxkbmap` from your terminal
    (Ubuntu: install x11-xkb-utils; Gentoo: install x11-apps/setxkbmap). This fixes some keys, but not all
  • Then put your cursor over the VMWare menu bar somewhere, but not in the client window
    (don't let the keyboard/mouse get grabbed automatically)
  • Press Ctrl-g
    (this grabs the keyboard/mouse). You should see the cursor jump to the middle of the VMWare screen. If this doesn't work, focus a different window, and try again.
  • Press Ctrl-Alt
    (This un-grabs the keyboard/mouse)
This solved the problem outside VMWare (on the host), but still didn't solve the problem where within VMWare (on the guest), my arrow keys, del and ins, etc. were still screwed. For a keyboard-shortcut lover such as myself, who uses the keyboard more than the mouse, this is very annoying.

Finally I thought I'd try VMPlayer (and wow, does the suspend / resume feature work fast!). The problem was even more evident - now every use of VMWare many non alpha-numeric keys were unusable.

Solution 3:
(no, you didn't miss the 2!)


Some readers have had success with the one line:
xkeymap.nokeycodeMap = true
in the file /etc/vmware/config. As the root user (sudo won't work in this case), this command should do it for you:
echo "xkeymap.nokeycodeMap = true" >> /etc/vmware/config
or:
echo "xkeymap.nokeycodeMap = true" >> ~/.vmware/config

If you don't have root access. See Solution 2 for more locations of this config file.

Solution 2:
This is the original Solution 2, and since many comments reference it I have left it numbered so. However, Solution 3 is much simpler (and newer) so I've put that first.

Apparently this issue arrises with the evdev input driver. Thanks to "doranikov", The solution is simple: Tell VMWare what your keyboard really does! Put this in either /etc/vmware/config, or /usr/lib/vmware/config if you have root access, or in ~/.vmware/config otherwise. (Do this in the host OS, not the client) If the file doesn't exist, just create it:
xkeymap.keycode.108 = 0x138 # Alt_R
xkeymap.keycode.106 = 0x135 # KP_Divide
xkeymap.keycode.104 = 0x11c # KP_Enter
xkeymap.keycode.111 = 0x148 # Up
xkeymap.keycode.116 = 0x150 # Down
xkeymap.keycode.113 = 0x14b # Left
xkeymap.keycode.114 = 0x14d # Right
xkeymap.keycode.105 = 0x11d # Control_R
xkeymap.keycode.118 = 0x152 # Insert
xkeymap.keycode.119 = 0x153 # Delete
xkeymap.keycode.110 = 0x147 # Home
xkeymap.keycode.115 = 0x14f # End
xkeymap.keycode.112 = 0x149 # Prior
xkeymap.keycode.117 = 0x151 # Next
xkeymap.keycode.78 = 0x46 # Scroll_Lock
xkeymap.keycode.127 = 0x100 # Pause
xkeymap.keycode.133 = 0x15b # Meta_L
xkeymap.keycode.134 = 0x15c # Meta_R
xkeymap.keycode.135 = 0x15d # Menu
done!

Getting keycodes

What if your keycodes are different? To get the keycodes, you'll need xev or xmodmap. Run xev and place your cursor in the xev window. Then press the key you want (eg, right Control).

You'll get output like this on the terminal:
KeyPress event, serial 33, synthetic NO, window 0x3200001,
root 0x1cb, subw 0x0, time 749698, (167,181), root:(1793,706),
state 0x10, keycode 105 (keysym 0xffe4, Control_R), same_screen YES,
XLookupString gives 0 bytes:
XmbLookupString gives 0 bytes:
XFilterEvent returns: False

KeyRelease event, serial 33, synthetic NO, window 0x3200001,
root 0x1cb, subw 0x0, time 749810, (167,181), root:(1793,706),
state 0x14, keycode 105 (keysym 0xffe4, Control_R), same_screen YES,
XLookupString gives 0 bytes:
XFilterEvent returns: False
Look at the value after keycode. In this case 105. Change the xkeymap.keycode. to 105:
xkeymap.keycode.105 = 0x11d # Control_R
0x11d is the scan code.

For xmodmap, use:
xmodmap -pk
Further help:
Where'd you come from?
P.S. hello to all the planet larry readers, and the Ubuntu community. Thanks to you guys (and some great linking from other bloggers, VMWare forums, etc) I now have over 1000 hits a month! In November 2008, I got over 6500 hits! blog on!

Thursday, 27 November 2008

The Closest Book Meme

(better late than never!)
  1. Grab the nearest book.
  2. Open it to page 56.
  3. Find the fifth sentence.
  4. Post the text of the sentence in your journal along with these instructions.
  5. Don’t dig for your favorite book, the cool book, or the intellectual one: pick the CLOSEST.
The British party had hoped to leave their cold-weather clothes in Hong Kong; but their rapid transit had frustrated that plan, and Neill was still carrying his waxed jacket, which was fine for Yorkshire, but not entirely suitable for Brunei.
from SOS, a story about an army expedition to Borneo's "Death Valley" which went wrong and turned into a fight for survival.

Monday, 10 November 2008

Movember

Movember - Sponsor Me
It's Movember!

During Movember (the month formerly known as November) I'm growing a Mo to help raise awareness about men's health issues and being proactive in the fight against men's depression and prostate cancer.

You can follow my progress on my Mo Space!

To donate to my Mo you can either:

  1. Click this link https://www.movember.com/au/donate/donate-details.php?action=sponsorlink&rego=2049857&country=au and donate online using your credit card or PayPal account, or
  2. Write a cheque payable to ‘Movember Foundation', referencing my Registration Number 2049857 and mailing it to:

Movember Foundation
PO Box 292
Prahran VIC 3181

All donations over $2 are tax deductible in Australia. Other countries may have similar benefits.

The money raised by Movember is used to raise awareness of men's health issues and donated to the Prostate Cancer Foundation of Australia and beyondblue - the national depression initiative. The PCFA and beyondblue will use the funds to fund research and increase support networks for those men who suffer from prostate cancer and depression.

Did you know:

  • Depression affects 1 in 6 men....most don't seek help. Untreated depression is a leading risk factor for suicide.
  • Last year in Australia 18,700 men were diagnosed with prostate cancer and more than 2,900 died of prostate cancer - equivalent to the number of women who will die from breast cancer annually.

For those that have supported Movember in previous years you can be very proud of the impact it has had and can check out the details at: [ Fundraising Outcomes ].

Movember culminates at the end of month Gala Partés. If you would like to be part of this great night you'll need to purchase a [ Gala Parté Ticket ].

Thanks for your support

Thursday, 11 September 2008

You know you're using the computer too much when

Last Sunday morning, I was actually trying to sleep in longer by dreaming something like --extend-sleep=1h. I am not joking *sigh*.

It didn't work - but for a good reason - my family was waking me up with a breakfast in bed for Fathers day :)

Thursday, 14 August 2008

nVidia xinerama on a Dell M6300

I wrote recently about my efforts to get two screens going, with the primary screen not coming off the primary video output. I used a neat trick, the option:
Option         "UseDisplayDevice" "DFP-0"
The downside with that method of separate X screens, is that you can't drag a window from one to the other.

Now I decided I should try using xinerama. The use should be almost identical, with the advantage that I can drag windows from one screen to the other. There are other subtle advantages such as better panel integration, and general WM goodness.

1. Firstly, compile everything with xinerama support.

If you use a binary distribution, this is probably done for you. For gentoo, add this the /etc/make.conf:
USE="... xinerama"
I prefer this to using /etc/portage/package.use in this case, because you want to catch all future installations that can support this USE flag.

Now, recompile everything that can use the USE flag:
# emerge -vauDN world
(v)erbose, (a)sk, (u)pdate, (D)eep, (N)ewUSE

It shouldn't be necessary to include nvidia-drivers in the recompile, but you will need them installed.

2. edit xorg.conf

You must start with a working xorg.conf, and you must have only one display set up or this step will fail:

# nvidia-xconfig -c /etc/X11/xorg.conf-20080728 -o /etc/X11/xorg.conf --twinview --dynamic-twinview --twinview-orientation=LeftOf --twinview-xinerama-info-order=DFP-2,DFP-0 --constant-dpi --use-edid --use-edid-dpi --damage-events --render-accel

The options are:
  • -c uses a specified input file. I do this so I can start from the same point each time, rather than a constantly changing xorg.conf file
  • -o writes to this file
  • --twinview enables twinview
  • --dynamic-twinview enables dynamically change twinview settings
  • --twinview-orientation=LeftOf sets the second monitor to be left of the primary
  • --twinview-xinerama-info-order=DFP-2,DFP-0 says that DFP-2 (DVI) is the primary display
  • --constant-dpi --use-edid --use-edid-dpi --damage-events --render-accel are other settings I play with to fine tune performance.

3. Restart X

You probably know how to do this. Logging off usually does the trick.

If everything worked you should have:
  • log in screen on one display only
  • desktop extended to second display
  • windows open completely on one display and not in the middle
  • windows snap to the edge of one display
  • windows can be dragged to the second display
  • both displays can be treated like one large screen (my geometry is now 3840x1200!)
 
Copyright 2009 Another Blog. Powered by Blogger Blogger Templates create by Deluxe Templates. WP by Masterplan