Commits

Kaspar Schiess committed 59778d9

Fixes #3 by making keyboard_layout configurable

Of course there are other defaults which cannot be overridden - so this
is only the first half of the fix. I will have to create some sort of
central configuration mechanism that allows setting these defaults and
overriding what cannot currently be changed.

  • Participants
  • Parent commits f306ba0

Comments (0)

Files changed (5)

File doc/qemu-toolkit-configuration.7

 
 .
 .TP
+keyboard_layout \fILAYOUT\fR
+Configure keyboard layout of the VNC display\. The default is \'en\-us\'\.
+.
+.IP "" 4
+.
+.nf
+
+# Set keyboard to \'de\-ch\'
+keyboard_layout \'de\-ch\'
+.
+.fi
+.
+.IP "" 0
+.
+.IP
+The available layouts are:
+.
+.IP "" 4
+.
+.nf
+
+ar  de\-ch  es  fo     fr\-ca  hu  ja  mk     no  pt\-br  sv
+da  en\-gb  et  fr     fr\-ch  is  lt  nl     pl  ru     th
+de  en\-us  fi  fr\-be  hr     it  lv  nl\-be  pt  sl     tr
+.
+.fi
+.
+.IP "" 0
+
+.
+.TP
 net \fITYPE\fR, \fIOPTIONS\fR
 Manual network configuration\. This gives you full access to QEMU options, with the disadvantage of a slightly more complicated set of options\. Here\'s what you would need to do to duplicate the convencience macro \fBnic\fR below:
 .

File doc/qemu-toolkit-configuration.7.ronn

         # Manual drive configuration:
         drive if: 'floppy', file: 'floppy.dsk'
         
+  * keyboard_layout <LAYOUT>:
+    Configure keyboard layout of the VNC display. The default is 'en-us'. 
+    
+        # Set keyboard to 'de-ch'
+        keyboard_layout 'de-ch'
+        
+    The available layouts are: 
+        
+        ar  de-ch  es  fo     fr-ca  hu  ja  mk     no  pt-br  sv
+        da  en-gb  et  fr     fr-ch  is  lt  nl     pl  ru     th
+        de  en-us  fi  fr-be  hr     it  lv  nl-be  pt  sl     tr
+        
   * net <TYPE>, <OPTIONS>:
     Manual network configuration. This gives you full access to QEMU options, 
     with the disadvantage of a slightly more complicated set of options. 

File lib/qemu-toolkit/vm.rb

     attr_accessor :ram
     # VNC display port
     attr_accessor :vnc_display
+    # Keyboard layout
+    attr_accessor :keyboard_layout
     
     def initialize(backend)
       @disks = []
       cmd << "-no-hpet"
       cmd << "-enable-kvm"
       cmd << "-vga cirrus"
-      cmd << "-k de-ch"
       cmd << "-parallel none"
       cmd << "-usb"
       cmd << '-usbdevice tablet'
+      
+      if keyboard_layout
+        cmd << "-k #{keyboard_layout}"
+      end
 
       # Add disks
       cmd += disk_options

File spec/fixture/etc/all.rb

   net :nic, vlan: 1, name: "vm1", model: "virtio", macaddr: '1:8:20:52:a6:7e'
   
   # Make vnc listen on a given port: (5900 + display = port)
-  vnc_display 0
+  vnc_display ':0'
+  
+  # Change the keyboard layout (-k option on qemu)
+  keyboard_layout 'de-ch'
   
   # Arguments that are appended to the qemu launch command line: 
   extra_arg '-foo'

File spec/lib/qemu-toolkit/vm_spec.rb

     end 
   end
   
+  describe 'keyboard layout' do
+    let(:all) { QemuToolkit::VM['all', backend] }
+
+    # Turn off disk configuration.
+    before(:each) { flexmock(all, disk_options: []) }
+    
+    subject { all.command }
+    
+    it { should include('-k de-ch') }
+  end
   describe 'network configuration' do
     describe 'basic sample (nic.rb)' do
       let(:nic) { QemuToolkit::VM['nic', backend] }