[Solved] Function keys in urxvt

Forum rules
We don't support installations in VirtualBox, VMWare, qemu or others. We ignore posts about WINE, PlayOnLinux, Steam and Skype. We don't support btrfs, lvm, UEFI, side-by-side installations with GPT or dualboot with anything newer than Windows XP.
Google your problem first. Check the Wiki. Read the existing threads. It's okay to "hijack" an existing thread, yes! If your problem is not yet covered, open a new thread. To get the quickest possible help, mention the exact release codename in your post (uname -a is a good idea, too). Due to the lack of crystal balls, attach the output of lspci -nnk if you encounter hardware problems.
User avatar
kexolino
Common Boob
Posts: 557
Joined: Sun Jun 16, 2013 1:57 pm

[Solved] Function keys in urxvt

Unread post by kexolino » Thu Jan 23, 2014 8:16 pm

Googling skills must be pretty crappy, cause I found next to nothing concerning this. My problem is that in urxvt none of the F keys work like they should, instead they just write a ~ (all through F1-F12). Any pointers, what I should look for to solve this? Here's my .Xresources, though nothing in it has to do with these keys:

Code: Select all

Xft.autohint: true
Xft.antialias: true
Xft.hinting: true
Xft.hintstyle: hintslight
Xft.rgba: rgb
Xft.lcdfilter: lcddefault
Xcursor.theme: DMZ-White

URxvt*termName: xterm-256color
URxvt.geometry: 80x22
URxvt.scrollBar: false
URxvt.iconFile: /usr/share/icons/Faenza/apps/48/xterm.png

URxvt*letterSpace : 1
URxvt.font: xft:Terminus:pixelsize=9
URxvt.boldFont: xft:Terminus:pixelsize=9

URxvt.perl-ext-common:  default,matcher
URxvt.urlLauncher:      x-www-browser
URxvt.matcher.button:   1

URxvt.keysym.Control-Up:   \033[1;5A
URxvt.keysym.Control-Down:    \033[1;5B
URxvt.keysym.Control-Left:    \033[1;5D
URxvt.keysym.Control-Right:    \033[1;5C
URxvt*keysym.Home: \033[1~
URxvt*keysym.End: \033[4~

! Mustang color scheme
*background:#1a1a1a
*foreground:#fff
*color0:#000000
*color1:#ff6565
*color2:#93d44f
*color3:#eab93d
*color4:#204a87
*color5:#ce5c00
*color6:#89b6e2
*color7:#cccccc
*color8:#555753
*color9:#ff8d8d
*color10:#c8e7a8
*color11:#ffc123
*color12:#3465a4
*color13:#f57900
*color14:#46a4ff
*color15:#ffffff
urxvt version is 9.19-1, on "vanilla" Sid (upgraded from a Wheezy netinstall).
Last edited by kexolino on Fri Jan 24, 2014 1:39 am, edited 1 time in total.

User avatar
kexolino
Common Boob
Posts: 557
Joined: Sun Jun 16, 2013 1:57 pm

Re: Function keys in urxvt

Unread post by kexolino » Fri Jan 24, 2014 12:40 am

Allright, it turns out that the problem is only with htop and only with F1-F4, only in urxvt - as far as I can see (tried in xterm and xfce4-terminal, everything fine there). The keys in other applications like Midnight Commander and Weechat are working fine; also it doesn't matter if it's in tmux or not. Not a big deal, because there are other keys that do the same things as F1-F4, but still it would be good to know why this is happening.

pidsley
Hermit
Posts: 2539
Joined: Wed Oct 17, 2012 12:31 pm

Re: Function keys in urxvt

Unread post by pidsley » Fri Jan 24, 2014 1:04 am

rxvt-unicode or rxvt-unicode-256color? I have rxvt-unicode 9.19-1, and I can't duplicate this problem with htop. The only difference I see is that I don't have any of this in my Xresources:

Code: Select all

URxvt.perl-ext-common:  default,matcher
URxvt.urlLauncher:      x-www-browser
URxvt.matcher.button:   1

URxvt.keysym.Control-Up:   \033[1;5A
URxvt.keysym.Control-Down:    \033[1;5B
URxvt.keysym.Control-Left:    \033[1;5D
URxvt.keysym.Control-Right:    \033[1;5C
URxvt*keysym.Home: \033[1~
URxvt*keysym.End: \033[4~
and I don't define the termName variable. I'm curious why you are setting it to xterm when you are using urxvt?

You might try going back to a more vanilla Xresources just to see if that maks a difference.

User avatar
kexolino
Common Boob
Posts: 557
Joined: Sun Jun 16, 2013 1:57 pm

Re: Function keys in urxvt

Unread post by kexolino » Fri Jan 24, 2014 1:38 am

It is rxvt-unicode-256color, and removing URxvt*termName: xterm-256color seems to have fixed it. I think I added it when I was fiddling with Weechat colors, but bad move because I don't really know what it's for (if you cared to explain I'd be grateful)...

pidsley
Hermit
Posts: 2539
Joined: Wed Oct 17, 2012 12:31 pm

Re: Function keys in urxvt

Unread post by pidsley » Fri Jan 24, 2014 7:28 am

kexolino wrote:It is rxvt-unicode-256color, and removing URxvt*termName: xterm-256color seems to have fixed it. I think I added it when I was fiddling with Weechat colors, but bad move because I don't really know what it's for (if you cared to explain I'd be grateful)...
I'm not 100% sure why this fixed the problem, but I think it is related to a slight difference in the way urxvt and xterm handle escape sequences, especially for the first four function keys. By setting termName to xterm-256color, you were telling programs to expect xterm escape sequences (and to send those sequences back), and they were in fact receiving urxvt escapes. Some programs didn't seem to mind, but htop did not work properly.

There are more clues in the Terminfo database and the infocmp command, but the short answer (as you discovered) is that it's not a good idea to set the termName to something you're not using. It just confuses everyone. :)

https://en.wikipedia.org/wiki/Rxvt
http://www.tldp.org/HOWTO/Text-Terminal-HOWTO-16.html

User avatar
kexolino
Common Boob
Posts: 557
Joined: Sun Jun 16, 2013 1:57 pm

Re: [Solved] Function keys in urxvt

Unread post by kexolino » Fri Jan 24, 2014 3:48 pm

Thanks for the explanation and links pids, they cleared things up :)

Post Reply