print the degree symbol ° in kwrite via the keyboard
SlackwareThis Forum is for the discussion of Slackware Linux.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
print the degree symbol ° in kwrite via the keyboard
Hello!
I need to enable kwrite and openoffice to print the "degree" symbol when I press, say F4. I have checked the degreee symbol ° that I need is coded like: U+00B0 (176). How can I achieve that?
If it's ANY Gtk-based application, you just press Ctrl-Shift u<00b0>, if you're running a Unicode environment.
This should work in OpenOffice as well.
In kwrite, I don't know.
I do not quite understand how I could press u<00b0> ? ctrl-shift ok, but how do I press u<00b0> ? I tried typing that sequence in openoffice but nothing happened.
I just tried in Firefox, there it works. (I don't have an OpenOffice here right now.)
Otherwise, check your X-keyboard setup in /etc/X11/xkb/symbols/pc/; usally signs/chars like "degree" are a simple combined shortcuts. Which keys to type exactly depends on your keyboard setting.
I think there is something much easier than remembering Unicode code points for various symbols. What I’m talking about of course is the Compose Key. For example, on my computer (which uses en_US.UTF-8), the degree symbol is obtained in any program with:
Code:
<Multi_key> <o> <o>
You can customize compose key mappings using the file “$HOME/.XCompose” (there is a system-wide file named “/usr/share/X11/locale/$LC_LOCALE/Compose”). To get the various toolkits (e.g., gtk and qt) to use X for Compose Key processing (the so-called X input method), you might need to define a few environment variables:
Thank you very much for you responsiveness. I read some literature on xfree86, keycodes, keyboardmaps,etc, but it seems to be a whole bit of a science to me. I would be very thankful if someone can provide an easy step-by-step guide on how to make the degree symbol possible to type via the keyboard.
I found out that it is the so called Multi_key that has to be set, but I could neither find out which is the Multi_key on my keyboard and how can I set it to print the degree symbol.
Sorry for posting again. I managed to set the compose key to be left win by means of the kde Control Center.
Here is an excerpt of my /etc/X11/xkb/symbols/us file:
partial alphanumeric_keys
xkb_symbols "intl" {
name[Group1]= "U.S. English - International (with dead keys)";
And here is an excerpt of my /usr/share/X11/locale/en_US.UTF-8/Compose file:
# UTF-8 (Unicode) compose sequence
# David.Monniaux@ens.fr
#
# $XFree86: xc/nls/Compose/en_US.UTF-8,v 1.11 2004/01/06 13:14:04 pascal Exp $
Any ideas? What must I do to be able to type the degree symbol from the keyboard?
If you want to go the “Compose Key” route, use this entry:
Code:
<Multi_key> <o> <o> : "°" degree # DEGREE SIGN
What it says is this:
Press and release the Multi-Key (lwin or whatever).
Press and release the “o” key.
Press and release the “o” key again.
And the result will be the degree sign. See, watch: °
I would suggest you first try this in a plain X application (i.e., not gtk or qt). For example an xterm (provided you have appropriate fonts). Then, export those environment variables (QT_IM_MODULE and GTK_IM_MODULE) so they are in effect upon booting your computer. With the environment variables set, you should be able to use all the combos within gtk apps (e.g., firefox) and qt/kde apps (e.g., kwrite).
P.S., a few caveats regarding compose key usage:
Pay close attention to the case of keys specified. In this example, the keys specified are lowercase “o”, which means to type as if you are typing a lowercase “o” (i.e., just press and release the key). If you wanted, for example, the pilcrow sign (¶), you need two upper-case “P” presses (which means use the shift modifier while pressing and releasing the key).
If you create a file called $HOME/.XCompose, it will replace (not augment) your system-wide combos. Therefore, it is recommended to copy the system wide file to your home directory and edit it there (so you don’t lose the established combos).
I tried in xterm as well but in vain. For example <Multi_key> <a> <e> does work ć, but <Multi_key> <o> <o> does not . Anyway, what I by chance found out, is that pressing left alt+0 produces the degree symbol. Unfortunately this only works in xterm and in no other application. What can I do?
Hi
I have had a similar problem, trying to get a number of foreign characters to display from keyboard combinations. I have got nearly everything I got working and used as my main source of information the following link : http://www.in-ulm.de/~mascheck/X11/xmodmap.html
which (together with further links therein) explains a lot about how X keyboard mapping works. Including the nice quotation : ¨If you're thinking that this is all senselessly complicated... you're right."
Incidently, if you have the same default keyboard mappping as I have (works on both my Slackware Box and on a Suse installation) you can generate the degree symbol ° with the following key combination : AltGr-Shift-0 (that´s the zero on the line of numeric characters, not the 0 on the numeric keypad). If that does not work for you, the link above will show you how to make it work.
I tried in xterm as well but in vain. For example <Multi_key> <a> <e> does work ć, but <Multi_key> <o> <o> does not
This sounds to me like a font problem (you have to be using a fixed width xterm font that supports many unicode code points, specifically the degree symbol). What is displayed on the screen? Two o’s? A box (i.e., filler) character? Nothing at all?
In any case, it seems your multi-key works (at least for the glyphs supported by your font). Now try a gtk app. For example, try launching firefox like this:
Code:
$ GTK_IM_MODULE=xim firefox
and now try your multi-key combo (e.g., in a text box).
This sounds to me like a font problem (you have to be using a fixed width xterm font that supports many unicode code points, specifically the degree symbol). What is displayed on the screen? Two o’s? A box (i.e., filler) character? Nothing at all?
In any case, it seems your multi-key works (at least for the glyphs supported by your font). Now try a gtk app. For example, try launching firefox like this:
Code:
$ GTK_IM_MODULE=xim firefox
and now try your multi-key combo (e.g., in a text box).
I started firefox the way you suggested and again ć works, but degree does not. Nothing gets printed at all. Anyway, I followed the link that bogzab gave and I issued:
xmodmap -e "keycode 116 = 176"
Now with that key I can print the degree symbol in any application. The only problem is that any time I change the keyboard layout,e.g from "us" to "bg", I have to issue the command:
xmodmap -e "keycode 116 = 176"
Is there a way to get that command executed automatically at keyboard layout change ?
Is there a way to get that command executed automatically at keyboard layout change ?
That depends on how you change your keyboard layout. The hackiest way would be to write a wrapper script for the program called. The wrapper script would first call the actual utility then call xmodmap. There is probably a more elegant way using the file “~/.Xresources” or something like that.
P.S.:
If you still want to try using the Multi-key (and it’s understandable if you don’t), it seems you might have a case of mistaken locality. Specifically, what is the output of the “locale” command? If you want to use the Compose combos for en_US.UTF-8 (which on my system is the most complete), just copy /usr/share/X11/locale/en_US.UTF-8/Compose to ~/.XCompose. If after all that, it still doesn’t work, then I think it would be better to go the other route after all.
That depends on how you change your keyboard layout. The hackiest way would be to write a wrapper script for the program called. The wrapper script would first call the actual utility then call xmodmap. There is probably a more elegant way using the file “~/.Xresources” or something like that.
I change my keyboard layout pressing ctrl+tab. On my computer at work the keyboard layout is changed by pressing shift+ctrl. Where do I have to write the command "xmodmap -e "keycode 116 = 176" so that at pressing the key combination that changes the keyboard layout, the degree symbol is assigned to key number 176? If I need to write a wrapper script, what should it contain and where should it be located? How do I specify that this script must be executed at pressing ctrl+tab for instance?
the output of "locale" is:
LANG=en_US
LC_CTYPE="en_US"
LC_NUMERIC="en_US"
LC_TIME="en_US"
LC_COLLATE=C
LC_MONETARY="en_US"
LC_MESSAGES="en_US"
LC_PAPER="en_US"
LC_NAME="en_US"
LC_ADDRESS="en_US"
LC_TELEPHONE="en_US"
LC_MEASUREMENT="en_US"
LC_IDENTIFICATION="en_US"
LC_ALL=
I tried copying the file you suggested, but there was no difference.
Sorry for posting again. I managed to set the compose key to be left win by means of the kde Control Center.
Here is an excerpt of my /etc/X11/xkb/symbols/us file:
partial alphanumeric_keys
xkb_symbols "intl" {
name[Group1]= "U.S. English - International (with dead keys)";
<AC10> corresponds to the tenth alphanumeric key on row C of the keyboard. Ie the semicolon key.
no modifier - semicolon
<SHIFT> + <;> - colon
<ALT GR> + <;> - paragraph
<SHIFT> + <ALT GR> + <;> - degree
Hence for the degree symbol press and hold <ALT GR> then press and hold <SHIFT>, then press <;>.
On my UK keyboard it's <AE10>, the number 0 key. It doesn't seem to work if you press all 3 keys at the same time.
Hope this helps
Phil
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.