10

When I press Ctrl+Alt+F{1..12}, it switches me to other virtual terminal.

Even xte "keydown Control_L" "keydown Alt_L" "key F1" "keyup Alt_L" "keyup Control_L" leads to switching to vt instead of sending that keys to focused window.

Use cases of this includes (but not limits to) sending special keystrokes to VNC or virtualization clients to be handled by clinet/guest system instead of the host one. Sometimes (like in VirtualBox) applications explicitly map some special alternative keystroke to that special ones (like Ctrl+Alt+Del or Ctrl+Alt+Backspace in VirtualBox), but I want clean and universal solution.

6
  • The answer depends on which VNC client you're using; each has a different way of doing this. Which VNC client are you using? Jul 24, 2012 at 16:13
  • I want universal solution for any X programs, not any VNC or virtual machine client -specific ones.
    – Vi.
    Jul 24, 2012 at 19:59
  • I think you just need to run xte on the remote machine, rather than the local machine. Jul 24, 2012 at 20:56
  • It's not about local or remote things at all (this is just one use case). It is about delivering arbitrary key presses to X applications in general.
    – Vi.
    Jul 24, 2012 at 23:53
  • Perhaps you should clarify your question, then? Jul 24, 2012 at 23:58

3 Answers 3

10

Let's call Ctrl+Alt+Fx (where Fx is one of function buttons: F1, F2, F3...) srvr keys.
There is a way to disable/enable srvr keys on the fly. By disabling I mean that X11 do not swallow them, but passes to window manager (kwin in kde).

For diabling srvr keys, you run setxkbmap -option srvrkeys:none
For enabling srvr keys, you run setxkbmap -option
To check if srvr_ctrl(no_srvr_keys) flag is enabled, run setxkbmap -print | grep xkb_symbols

In kde there is possibility to perform window actions (for example, execute some command when window gets or looses focus). So you can automatically disable srvr keys when your special application window is focused, and automatically enable them back when it looses focus. It is universal solution. Useful for such applications as TeamViewer, VirtualBox, Chrome Remote Desktop, ipkvm viewer, krdc and so on.
If you interested, here is my script that I use for this thing: https://github.com/Ashark/aten-ip8000/blob/master/srvrkeys

1
  • Thanks, very useful for using Teamviewer at a console.
    – Tom Hale
    Dec 14, 2023 at 9:17
1

For VirtualBox, try the key combination REL + F1. Here, REL is the key used to release the mouse grab in the VirtualBox window, usually right Ctrl or Alt key.

3
  • @diago better now?
    – maxelost
    Jan 11, 2011 at 17:07
  • The question is not about VirtualBox or VMWare (however the VMWare analogue of REL+F1 whould be interesting) or even about VNC clients, it's about "In general". /* trying to do it with xte */
    – Vi.
    Jan 12, 2011 at 14:39
  • in virtualbox it's called Host key
    – phuclv
    Dec 7, 2016 at 9:13
0

It is not possible to send Ctrl+Alt+F[1..12] because the virtual terminals are seperate from the desktop that the VNC is connected to.

1
  • Unclear. I expect if the "Ctrl+Alt+Fx" event goes into a VNC client then the client will cause VNC server to issue "Ctrl+Alt+Fx". The problematic part that "Ctrl+Alt+Fx" does not reach the client, being interpreted by Xorg.
    – Vi.
    Jan 18, 2015 at 20:09

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .