4

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.

1
  • 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
    Commented Feb 17, 2018 at 17:05

3 Answers 3

10

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

1
  • nicely done - why didn't I take the time to elaborate? upvote!
    – flowtron
    Commented Dec 19, 2016 at 21:42
4

use xdotool as mentioned in this answer.

xdotool key KEYSTROKE_SPECIFIER

Where KEYSTROKE_SPECIFIER can be something like "a" or "F2" or "control+j"

1

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.

You must log in to answer this question.

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