LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Desktop (https://www.linuxquestions.org/questions/linux-desktop-74/)
-   -   keyboard entry of "accented" characters (https://www.linuxquestions.org/questions/linux-desktop-74/keyboard-entry-of-accented-characters-946902/)

SaintDanBert 05-25-2012 05:04 PM

keyboard entry of "accented" characters
 
Can someone tell me how to enable and configure keyboard entry of "accented" characters such as the French 'e' with acute or grave accent, German 'u' with umlaut, Spanish 'c' with cedilla, etc?

That other software from Redmond will let me enter ALT plus numeric pad "0233" for the French 'e' acute. I cannot get anything similar working with linux.

I suspect that I simply do not know what name the linux world uses to refer to this and similar features.
I'm running Cinnamon on Linux Mint-12 (Ubuntu 11.10).

Thanks is advance,
~~~ 0;-Dan

Ser Olmy 05-25-2012 05:27 PM

Quote:

Originally Posted by SaintDanBert (Post 4687741)
That other software from Redmond will let me enter ALT plus numeric pad "0233" for the French 'e' acute. I cannot get anything similar working with linux.

That's really something of a hack. The "proper" way to access accented characters (provided they don't have a dedicated key on your keyboard, like the Swedish Ö/ö), is through "dead keys".

A "dead key" is a key which doesn't produce any output by itself, but acts as a modifier on the next keystroke/character. On my (non-English) keyboard, the ~ key is a dead key. I can produce "õ" and "ñ" by pressing "~" followed by "o" and "n" respectively. To get the "~" character by itself, I have to press ~ then space.

I know precious little about keyboard settings in X, but some other linuxquestion.org user (or Google) will no doubt be able to point you in the right direction.

frankbell 05-25-2012 10:07 PM

ALT-233 looks like a "high ASCII" code (I looked it up; it is).

It's a DOS thing that long predates Windows, going back to when DOS text increased from 128 (ASCII) to 256 ("high" ASCII, "high" meaning "above 128") characters. I suspect that, if Redmond could figure some way to make it go away, they would.

https://en.wikipedia.org/wiki/Extended_ASCII

This might help: http://linux.die.net/man/1/uni2ascii but I have no desire to test it.

DavidMcCann 05-26-2012 12:23 PM

Run the keyboard configuration tool in the preferences menu and set a key to use as the Compose key: Windows Menu or Right Control are popular choices. Then you can press the Compose key and the following keystrokes will be looked up in a table to find the accented character you want (see more information in Wikipedia):
Compose + ' + e → é
Compose + , + c → ç
Compose + " + u → ü
Don't use dead keys: they are a pain on the "American international" keyboard, where you get a dead acute at the expense of having to press the apostrophe twice to get an apostrophe.

273 05-26-2012 01:04 PM

On my systems <Alt Gr> is the compose key so pressing <Shift> then <Alt Gr> then e then ' gives me é.
I think it was this way by default, but this would only apply to Debian based systems.

SaintDanBert 05-26-2012 02:49 PM

Quote:

Originally Posted by 273 (Post 4688268)
On my systems <Alt Gr> is the compose key so pressing <Shift> then <Alt Gr> then e then ' gives me é. I think it was this way by default, but this would only apply to Debian based systems.

I don't recognize what you refer to as "< ALT Gr >" as a keystroke or a key cap. What might this be?
As I look at my keyboard, I have the following key faces:

Left-Ctrl ... Left-Windows ... Left-ALT ... Right-ALT ... Right-Menu ... Right-Ctrl ... Page-Left ... Page-Right

From the other replies, it seems that I need to search out "Compose Key" as something to enable and configure.

Thanks in advance,
~~~ 0;-Dan

273 05-26-2012 03:14 PM

Sorry I had forgotten that some keyboards don't have one. It's the right Alt key whcih on my keyboard is labelled "Alt Gr" (which I think stands for Alternative Graphics) so depending on your distribution and setup right Alt may still work as it does for me.
http://en.wikipedia.org/wiki/Alt_gr

David the H. 05-27-2012 05:36 AM

See here for a list of the most common compose key sequences, and a short explanation on how to enable it.

http://www.hermit.org/Linux/ComposeKeys.html

I have also modified and updated the script found on this page for searching the current compose key list on your system. It will output all the combinations that can be used for whatever character(s) you input (probably through cut&paste).

Code:

#!/bin/bash

#####################################################################
# ximkeys.sh (original script name)
# List the X compose sequences available to generate the specified character.
# I.E. the keyboard key sequence to enter after the compose (multi) key or
# a dead key is pressed.
#
# This version has been heavily modified by me (David the H.).  It is now
# bash-specific, reduces the need for external tools (only grep is called on),
# and can handle multiple inputs.
#
# The original script header follows.  The script itself can be found here:
# http://www.pixelbeat.org/docs/xkeyboard/
#
# Author:
#    P@draigBrady.com
# Notes:
#    GTK+ apps use a different but broadly similar input method
#    to X by default. Personally I tell GTK+ to use the X one by
#    adding `export GTK_IM_MODULE=xim` to /etc/profile
# Changes:
#    V0.1, 09 Sep 2005, Initial release
#    V0.2, 04 May 2007, Added support for ubuntu
######################################################################

# test for input, and print usage info if none found
if [[ -z $* ]]; then
        echo "Usage: ${0##*/} 'character(s)'" >&2
        echo "Multiple characters are supported." >&2
        echo "They don't need to be space-separated." >&2
        exit 1
fi

# determine the current language setting.  If not UTF-8, exit with error
re='(.*)[.][Uu][Tt][Ff].*8'
if [[ $LANG =~ $re ]]; then

        lang="${BASH_REMATCH[1]}"
        codeset=UTF-8

else

        echo "Sorry, only UTF-8 is supported at present" >&2
        exit 1

fi

# test for existence of the proper dir and file
dir=/usr/share/X11/locale

if [[ ! -d "$dir" ]]; then #if not found, check for the older X11 dir

        dir=/usr/X11R6/lib/X11/locale

fi

if [[ ! -d "$dir" || ! -r "$dir/locale.dir" ]]; then

        echo "Sorry, couldn't find your X windows locale data" >&2
        exit 1

fi

# extract the correct codepage file from the locale.dir
page="$( grep -m1 "${lang}.${codeset}$" <$dir/locale.dir )"
page=${page%%/*}
file="$dir/$page/Compose"

# loop through input characters, and print all matching entries.
echo

while read -n 1 character; do

        [[ -z $character ]] && continue
        echo "combinations found for [$character]"
        grep -F "\"$character\"" "$file"
        echo

done <<<"$*"

exit 0

I recommend sticking it in a global directory such as /usr/local/bin.
Then just make it executable, and run it like this:

Code:

$ ximkeys.sh ᄝ

combinations found for [ß]
<Multi_key> <s> <s>                        : "ß"  ssharp # LATIN SMALL LETTER SHARP S

combinations found for [ä]
<dead_diaeresis> <a>                        : "ä"  adiaeresis # LATIN SMALL LETTER A WITH DIAERESIS
<Multi_key> <quotedbl> <a>                : "ä"  adiaeresis # LATIN SMALL LETTER A WITH DIAERESIS

combinations found for [¥]
<Multi_key> <Y> <equal>                        : "¥"  yen # YEN SIGN
<Multi_key> <equal> <Y>                        : "¥"  yen # YEN SIGN
<dead_currency> <y>                        : "¥"  yen                # YEN SIGN


David the H. 05-27-2012 05:45 AM

Quote:

Originally Posted by frankbell (Post 4687887)
ALT-233 looks like a "high ASCII" code (I looked it up; it is).

I was always under the impression that the number used in the Windows keypad input was the unicode decimal code point. [é] is unicode 233 as well. I could be wrong though, as I never used it myself.

DavidMcCann 05-27-2012 11:44 AM

For the record, if you need custom compose sequences, you don't need to run a script. Just copy the existing file (mine lives at /usr/share/X11/locale/en_US.UTF-8/Compose) to ~/.XCompose and then edit it. Ensure that your input module is xim (and not the the GTK one usually installed by default in Gnome distros): putting GTK_IM_MODULE=xim in /etc/environment should work.

SaintDanBert 06-15-2012 05:21 PM

Following the combined advice from these responses, I was able to solve my troubles.

On my Mint-12 with Cinnamon (sounds tasty...) workstation, I did:
  • Desktop: System Menu --> Preferences --> Keyboard Layout
  • Keyboard Layout: Layouts tab --> select English(US) --> select Options buttons
  • select Compose Key Position
  • set check box for desired key I used Scroll Lock

I then made a local copy of the dot-XCompose file in my $HOME so that I could know and control what was available. I removed all of the Asian and similar language characters, and added a few of my special desirables.

Thanks to all,
~~~ 0;-Dan

frankbell 06-15-2012 09:23 PM

Thanks for coming back and posting the end of the story. If someone else comes along with that question, LQ is now ready.

SaintDanBert 06-16-2012 12:54 PM

Quote:

Originally Posted by frankbell (Post 4704512)
Thanks for coming back and posting the end of the story. If someone else comes along with that question, LQ is now ready.

It is too easy to grab your solution and run with it and then forget to close the loop.
Maybe LQ could "nag" the original poster after no activity for a while..

Glad you noticed. More glad I remembered...
~~~ 0;-Dan


All times are GMT -5. The time now is 10:33 PM.