F2 to F4 does not work in Gentoo

Asked by Locutus

Running a fully updated version of Gentoo 64bit and emerged byobu. In both local mode and over a SSH connection the function keys F2 to F4 do not work.

 I have tried in the Tilda drop down console and in XFCE Terminal console. Logging remotely to an Ubuntu server with screen-profiles installed has those keys working.

I have tried comparing the configuration files between them but cannot find why those keys do not work. The command "echo $TERM" shows xterm and when byobu is started it shows screen-bce. The window manager is XFCE. The byobu version is 2.65-r1 according to Gentoo's emerge version. What do I need to do to have those function keys working?

Question information

Language:
English Edit question
Status:
Solved
For:
byobu Edit question
Assignee:
No assignee Edit question
Solved by:
Stephen Leavitt
Solved:
Last query:
Last reply:
Revision history for this message
Launchpad Janitor (janitor) said :
#1

This question was expired because it remained in the 'Open' state without activity for the last 15 days.

Revision history for this message
Locutus (shane-locutus) said :
#2

This problem has not been responded too or even looked at. I still need an answer please.

Revision history for this message
Dustin Kirkland  (kirkland) said :
#3

Sorry, no idea, not a Gentoo user. Check your xterm settings.

Revision history for this message
Best Stephen Leavitt (stephen-leavitt) said :
#4

Neither was I until recently, and this behaviour was annoying the hell out of me, so I tracked it down to what solves it for me.

The issue is in /etc/screenrc. Gentoo has a block of lines in it that reads something like this:

...
# tell screen that xterm can switch to dark background and has function
# keys.
  termcapinfo xterm 'VR=\E[?5h:VN=\E[?5l'
  termcapinfo xterm 'k1=\E[11~:k2=\E[12~:k3=\E[13~:k4=\E[14~'
  termcapinfo xterm 'kh=\EOH:kI=\E[2~:kD=\E[3~:kH=\EOF:kP=\E[5~:kN=\E[6~'
...

That second termcapinfo line is remapping F1-F4. I'm not sure why, I think it has something to do with the change in xterm. I'm not sure why, nor do I really care. The Ubuntu /etc/screenrc doesn't do this.

You could comment it out, but on a Gentoo system I would advocate changing ~/.byobu/keybindings to read like this instead:

...

source /usr/share/byobu/keybindings/common

# Since profile is a symlink, but it source the keybindings file,
# I'm using this for my own nefarious purposes

# We don't need the shell to be a login shell
shell "$SHELL"

# Fix the retarded F1-F4 key mappings in screenrc
#termcapinfo xterm 'k1=\E[11~:k2=\E[12~:k3=\E[13~:k4=\E[14~'
termcapinfo xterm 'k1=\EOP:k2=\EOQ:k3=\EOR:k4=\EOS'

...

The shell definition is to allow me to put && exit 0 after the byobu launch line added to ~/.profile if you want it to start properly.

Also, if you want bash-completion to work properly, you'll want to move /etc/profile.d/bash-completion.sh to /usr/local/bin/ , and add something like this to your ~/.bashrc file:

...

# Put your fun stuff here.

# Source bash_completion
if [ -f /usr/local/bin/bash-completion.sh ] && ! shopt -oq posix; then
    . /usr/local/bin/bash-completion.sh
fi

...

This is what I had to do to a Gentoo system to get it to behave like the Ubuntu systems I'm used to using byobu on. Hopefully this helps some.

Revision history for this message
Locutus (shane-locutus) said :
#5

Thanks Stephen Leavitt, that solved my question.

Revision history for this message
Dustin Kirkland  (kirkland) said :
#6

Just one bit of additional info...

You should be able to put these customizations in ~/.screenrc, which
is sourced *last* by byobu. No need to get all nefarious with the
keybindings config ;-)

Revision history for this message
Stephen Leavitt (stephen-leavitt) said :
#7

Sure, I was aware it did that, and .screenrc is probably overall a better place to do it since the same issue could probably afflict regular screen as well; however, since I can't be bothered to want to learn the default keypresses for regular screen other than C-A D to detach because they don't make sense to me, putting it in byobu's config files made sense to me since after discovering byobu, I don't have much use for regular screen any more ... :)