I have an ubuntustudio 16.10
64 bit on an IBM Thinkpad E431. I am able to launch an app from a shell script, but the next step involves pressing Ctrl+Shift+F10 On my notebook I need to press the button Fn before F10 . I use xfce
Desktop. I am unable to simulate this in a shell script. I had also disabled my touchpad but did not help.

- 829,060

- 117
-
It's worth making a related point. Fn keys can do weird things under the hood. For example, if I do Fn+F8, I get a volume-up keypress event coming from my keyboard, but if I press Fn+12 (labelled airplane mode), an event appears to come into Linux from my network card. Looking at what events are coming into which /dev/input/* files can help work out what's going on. – GKFX Feb 17 '18 at 17:05
3 Answers
You do not need to.
On my notebook I need to press the button Fn before F10.
That is, however, irrelevant to what X input events you need to simulate.
What you have to remember is that the Fn key is never seen on the wire between your keyboard and your computer. It is handled entirely by the microprocessor in the keyboard itself. What comes over the wire when you press the keys with the Fn and F10 engravings is simply the key code for the F10 key, as if you had a full keyboard with a fully-fledged independent F10 key.
You have a key that is engraved with F10 and something else. The keyboard microprocessor handles your Fn key as an entirely local modifier key that switches that key between looking like the "something else" key (when Fn is not pressed) on the wire and looking like the F10 (when Fn is pressed) on the wire.
In fact, laptop and suchlike keyboards usually have two such local modifiers. The other is the state of the NumLock LED (sic), making every key have four different ways in which it can appear on the wire to your computer.
But as seen by your computer, at the other end of the wire, all of this is invisible. It sees a full keyboard with a real, independent F10 key. That is also what the X applications see in X input events.
So that is all that you need to simulate. Just simulate X events that indicate that the F10 key has been pressed, with the Level2 ⇧ and Control ⎈ modifiers.
With xdotool
, as in flowtron's answer, that's just
xdotool key ctrl+shift+F10
Further reading
- Ubuntu 16.04 doesn't recognize Fn key
- Jonathan de Boyne Pollard (2020). The "Fn" key is local.. Frequently Given Answers.
- "KEYBOARD MATRIX DESIGN". SK5126 FlexMatrix Keyboard Controller data sheet. Sprintek. 2015-02-20.
- "Function Key Usage". HT82K629A Windows 2000 USB+PS/2 Keyboard Encoder data sheet. Holtek. 2004-09-15.

- 68,745
use xdotool as mentioned in this answer.
xdotool key KEYSTROKE_SPECIFIER
Where KEYSTROKE_SPECIFIER can be something like "a" or "F2" or "control+j"
The simulated key with xdotool
may not be captured on a bash/shell if xdotool
is not run in a forked way instead of xdotool key ctrl+shift+F10
you can use
xdotool key ctrl+shift+F10 &
If the keys are captured by your shell/terminal application, it will be occupied by xdotool when it's ran to simulate the keys preventing it from capturing them because the main process is busy simulating the keys... forking the process with &
will make the main process free to capture the keys.

- 14,406