I may not have a lot of experience with coding, software engineering or even with linux systems, but i do know one thing: a computer, no matter what system it uses, is mostly based on the human brain.
Now i know it's possible for a brain (and a computer) to learn 2 languages side-by-side, but what you're asking of the pc is a bit different. You're not asking it to use two languages side-by-side, you're asking it to use those two languages simultaniously, so basically to consider 2 outputs for a single input, and let the computer choose which one to use.
On itself, this shouldn't be too much of an issue, if it weren't for the fact that this translation process takes place within the software, rather than in the keyboard, making it (near) impossible for the computer to know which one to use. For instance (not entirely sure about the specific layout of the fr-iso keyboard, so forgive me if this is exaggerated) you could type the 'Q' key on the USB-keyboard, but the computer would have to interpret it as "'Q' or 'A'". Now yóu know you typed a Q, but all the computer knows is that you typed in a specific key with multiple translations. Which is where the keyboard settings come into action.
Using the keyboard layout setting, you tell your computer how to interpret your keystrokes. So you basically tell it what dictionary to use for that keyboard. If you want to use the other keyboard, you should set the dictionary to the appropriate language, or the computer might misinterpret your keystrokes, causing it to think you're still using the standard (fr-iso) keyboard, where you àctually want it to use the en-us dictionary. I would compare it with speaking spanish while in portugal: they mostly know what you mean, but some things just don't make sense due to semantic differences.
So, long story short: simultanious use is impossible, unless both keyboards have the ability to automatically tell the computer which layout to use. Imo, your best bet would be to set up shortcuts or scripts to easily change the keyboard settings (like Windows uses the Left-ctrl + Left-shift combination). However, to make sure this happens correctly, it ís recommended to manually map your keys (the only one who knows the correct interpretation for sure is you), and maybe find a way to export this mapping for easy use within either a script or application for ease of changing the layouts. (Like i said, no experience in coding, so although i assume there's a way, i'm not the person to know that way: comments would be welcome)
Hope it helps
After a little research, I've found a solution, although I'm still open to other (probably better) answers.
Here's a startup script (which can be added to Startup Applications) which will set the maually entered usbkbd_layout variable to the usbkbd device ids found in the xinput -list:
#!/bin/bash
usbkbd=`xinput -list | grep -c "USB Keyboard"`
if [[ "$usbkbd" -gt 0 ]]
then
usbkbd_ids=`xinput -list | grep "USB Keyboard" | awk -F'=' '{print $2}' | cut -c 1-2`
usbkbd_layout="tr(f)"
for ID in $usbkbd_ids
do
setxkbmap -device "${ID}" -layout "${usbkbd_layout}"
done
fi
exit 0
This script is quite useful (and more stable) for scenarios where user starts using the laptop on a desktop setup (with external keyboard, mouse and monitor, etc.), and it can also be run manually whenever the external USB keyboard is plugged in...
==========================================================================
THE BETTER (almost perfect) SOLUTION - found thanks to MinimusHeximus and the respective contributors to the thread he mentioned in his comment below:
I can now just plugin my USB keyboard and automatically have its different (TR-F) keyboard layout applied while still keeping the default keyboard layout (TR-Q) on my laptop!
Here are the files and their contents that make this possible:
/etc/udev/rules.d/00-usb-keyboard.rules
ATTRS{idVendor}=="09da", ATTRS{idProduct}=="0260", OWNER="sadi"
ACTION=="add", RUN+="/home/sadi/.bin/usb-keyboard-in_udev"
ACTION=="remove", RUN+="/home/sadi/.bin/usb-keyboard-out_udev"
/home/sadi/.bin/usb-keyboard-in_udev
#!/bin/bash
/home/sadi/.bin/usb-keyboard-in &
/home/sadi/.bin/usb-keyboard-in
#!/bin/bash
sleep 1
DISPLAY=":0.0"
HOME=/home/sadi/
XAUTHORITY=$HOME/.Xauthority
export DISPLAY XAUTHORITY HOME
usbkbd_id=`xinput -list | grep "USB Keyboard" | awk -F'=' '{print $2}' | cut -c 1-2 | head -1`
usbkbd_layout="tr(f)"
if [ "${usbkbd_id}" ]; then
gsettings set org.gnome.settings-daemon.plugins.keyboard active false
sleep 2
setxkbmap -device "${usbkbd_id}" -layout "${usbkbd_layout}"
fi
/home/sadi/.bin/usb-keyboard-out_udev
#!/bin/bash
/home/sadi/.bin/usb-keyboard-out &
/home/sadi/.bin/usb-keyboard-out
#!/bin/bash
sleep 1
DISPLAY=":0.0"
HOME=/home/sadi/
XAUTHORITY=$HOME/.Xauthority
export DISPLAY XAUTHORITY HOME
gsettings set org.gnome.settings-daemon.plugins.keyboard active true
Notes:
- Of course all of the four files in your ."bin" folder should have necessary permissions (readable and executable) which maybe
implemented for example with a Terminal command like
chmod - 755
/home/sadi/.bin/usb-keyboard-*
- Sometimes after the USB keyboard is plugged in it still uses the same (default) keyboard layout, and switches to the specified layout upon the second try (perhaps requiring a little more sleep time somewhere?)
- The USB keyboard specific layout is not effective in the login screen (when you Log Out).
- If you use a separate partition for /home, then it might be a better idea to put the four scripts somewhere in the root partition, e.g. /usr/local/bin and modify the contents of all respective files accordingly as sometimes udev may look for those files before your /home partition is mounted and cause problems.
IN ORDER TO ADAPT THIS SETUP TO DIFFERENT REQUIREMENTS:
- USB keyboard vendor and product ids should be changed as per the output of the command
lsusb
(For example, my lsusb
output have this for my USB Keyboard: Bus 001 Device 006: ID 09da:0260 A4 Tech Co., Ltd
)
- OWNER and all user directory names should be changed from "sadi" to another name
- The usbkbd_id may require a little adjustment to grab the correct device id (For example, output of the commands
xinput -list | grep "USB Keyboard"
gives me two lines; ↳ USB Keyboard id=14 [slave keyboard (3)]
and ↳ USB Keyboard id=16 [slave keyboard (3)]
; which are then filtered by awk
using "=" as field delimiter and capturing the second part; then cutting only the first two digits, and then using only the value in the first line)
- The value for usbkbd_layout may be any other valid choice
Best Answer
using
sudo dpkg-reconfigure keyboard-configuration
will change your keyboardlayout just for this session.go for
sudo nano /etc/default/keyboard
there you can change your keyboard settings.Find the line :
You can change
layout
andkboptions
as well as yourmodel
and thekbvariant
.Just put in
tr
for Turkishon older ubuntu versions you could go for
dpkg-reconfigure console-setup
and make permanently changes here. but for server 12.04 I guess it should be in the keyboard file.