LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices


Reply
  Search this Thread
Old 09-30-2007, 04:23 AM   #1
tramni1980
Member
 
Registered: Jul 2006
Location: Köln, Germany
Distribution: Slackware64-14.2 & -current, DragonFly BSD, OpenBSD
Posts: 819

Rep: Reputation: 55
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?

Any suggestions will be appreciated.
 
Old 09-30-2007, 05:22 AM   #2
Su-Shee
Member
 
Registered: Sep 2007
Location: Berlin
Distribution: Slackware
Posts: 510

Rep: Reputation: 53
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.
 
Old 09-30-2007, 05:57 AM   #3
tramni1980
Member
 
Registered: Jul 2006
Location: Köln, Germany
Distribution: Slackware64-14.2 & -current, DragonFly BSD, OpenBSD
Posts: 819

Original Poster
Rep: Reputation: 55
Quote:
Originally Posted by Su-Shee View Post
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.
 
Old 09-30-2007, 11:40 AM   #4
Su-Shee
Member
 
Registered: Sep 2007
Location: Berlin
Distribution: Slackware
Posts: 510

Rep: Reputation: 53
Hold Ctrl and Shift and press u00b0 in sequence.

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.
 
Old 09-30-2007, 11:45 AM   #5
osor
HCL Maintainer
 
Registered: Jan 2006
Distribution: (H)LFS, Gentoo
Posts: 2,450

Rep: Reputation: 78
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:
Code:
export QT_IM_MODULE=xim
export GTK_IM_MODULE=xim
 
Old 10-01-2007, 03:29 AM   #6
tramni1980
Member
 
Registered: Jul 2006
Location: Köln, Germany
Distribution: Slackware64-14.2 & -current, DragonFly BSD, OpenBSD
Posts: 819

Original Poster
Rep: Reputation: 55
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.
 
Old 10-01-2007, 05:00 AM   #7
tramni1980
Member
 
Registered: Jul 2006
Location: Köln, Germany
Distribution: Slackware64-14.2 & -current, DragonFly BSD, OpenBSD
Posts: 819

Original Poster
Rep: Reputation: 55
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)";

include "us(basic)"

// Alphanumeric section

key <AC10> { [ semicolon, colon, paragraph, degree ] };

include "level3(ralt_switch)"
};

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 $

# Part 1 - Manual definitions

# Spacing versions of dead accents

<dead_abovering> <space> : "В°" degree # DEGREE SIGN
<dead_abovering> <dead_abovering> : "В°" degree # DEGREE SIGN
# Spaces
<Multi_key> <o> <o> : "В°" degree # DEGREE SIGN


Any ideas? What must I do to be able to type the degree symbol from the keyboard?
 
Old 10-01-2007, 12:11 PM   #8
osor
HCL Maintainer
 
Registered: Jan 2006
Distribution: (H)LFS, Gentoo
Posts: 2,450

Rep: Reputation: 78
Quote:
Originally Posted by tramni1980 View Post
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:
  1. Press and release the Multi-Key (lwin or whatever).
  2. Press and release the “o” key.
  3. 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).
 
Old 10-01-2007, 01:42 PM   #9
tramni1980
Member
 
Registered: Jul 2006
Location: Köln, Germany
Distribution: Slackware64-14.2 & -current, DragonFly BSD, OpenBSD
Posts: 819

Original Poster
Rep: Reputation: 55
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?

I am very thankful for your responsiveness.
 
Old 10-01-2007, 02:38 PM   #10
bogzab
Member
 
Registered: Mar 2006
Location: Dyserth, Wales
Distribution: Slackware 14.0, Slackware 14.1, Slackware-current
Posts: 306

Rep: Reputation: 33
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.

Bogus
 
Old 10-01-2007, 03:00 PM   #11
osor
HCL Maintainer
 
Registered: Jan 2006
Distribution: (H)LFS, Gentoo
Posts: 2,450

Rep: Reputation: 78
Quote:
Originally Posted by tramni1980 View Post
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).
 
Old 10-02-2007, 01:29 AM   #12
tramni1980
Member
 
Registered: Jul 2006
Location: Köln, Germany
Distribution: Slackware64-14.2 & -current, DragonFly BSD, OpenBSD
Posts: 819

Original Poster
Rep: Reputation: 55
Quote:
Originally Posted by osor View Post
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 ?
 
Old 10-02-2007, 11:20 AM   #13
osor
HCL Maintainer
 
Registered: Jan 2006
Distribution: (H)LFS, Gentoo
Posts: 2,450

Rep: Reputation: 78
Quote:
Originally Posted by tramni1980 View Post
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.
 
Old 10-02-2007, 01:31 PM   #14
tramni1980
Member
 
Registered: Jul 2006
Location: Köln, Germany
Distribution: Slackware64-14.2 & -current, DragonFly BSD, OpenBSD
Posts: 819

Original Poster
Rep: Reputation: 55
Quote:
Originally Posted by osor View Post
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.
 
Old 10-04-2007, 04:00 AM   #15
phi11ip
Member
 
Registered: Jul 2007
Location: Nottingham, UK
Distribution: Slackware64-current
Posts: 93

Rep: Reputation: 23
Quote:
Originally Posted by tramni1980 View Post
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)";

include "us(basic)"

// Alphanumeric section

key <AC10> { [ semicolon, colon, paragraph, degree ] };

include "level3(ralt_switch)"
};
<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
 
  


Reply

Tags
keyboard



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
symbol lookup error: /usr/lib/libgtk-x11.2.0.so.0: undefined symbol:... IamI Slackware 17 02-29-2008 11:10 AM
KWrite refuses to print newbiesforever MEPIS 1 08-31-2006 03:59 PM
How do I get the pipe symbol on a uk keyboard? markhod Linux - General 4 11-03-2004 02:09 PM
X keyboard configuration and euro symbol derekp Slackware 3 02-27-2004 04:53 AM
keymap for us keyboard with euro symbol poison Slackware 0 12-11-2003 08:40 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware

All times are GMT -5. The time now is 03:16 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration