Score:0

External keyboard function keys not recognised unless I run script

mr flag

I am running Ubuntu 20.04.5 LTS with XFCE on a Dell laptop. When I am using an external keyboard the function keys are not correctly detected- for example in Intellij IDE.

I have a work-around which I got from amazon of all places - someone else who reviewed the keyboard added the snippet and it works fine:

echo 0 | sudo tee /sys/module/hid_apple/parameters/fnmode

However this has to be run in a terminal every session.

So I would like to run this (or something like it) automatically - probably every time a user starts a session, But I do not mind if the ode is run multiple times (I think it is idempotent). What is the easiest and safest way to achieve this? I can use command line and have furtled in various bits of the sensitive configuration stuff, but I do not really know what I am doing so cannot easily backout/repair/troubleshoot stuff when I mess up.

Most solutions that I have found involve plumbing something into systemd but I am not sure it should need to be that complicated....

All help gratefully received. (I am happy to dump system information and copy it here - but thought it may be a noisy distraction)

I did try the solution suggested in Keychron Q1 Function Keysbut itmade no difference.

Phill

My apologies for posting the wrong version originally.

David avatar
cn flag
You say you are running Ubuntu 22 so you must be using Ubuntu Core 22. That is the only version to use a single digit number. If it is not that version please edit the question and put in the actual version.
DrPhill avatar
mr flag
Edited, sorry....
Score:1
cn flag

If this has to be in effect as you start your computer, the easiest way will be to execute the command @reboot in a root cron job:

sudo crontab -e

to open the root's crontab file for editing.

Add the line

@reboot echo 0 | tee /sys/module/hid_apple/parameters/fnmode

Save and exit. The command now will be executed at every boot. sudo is not needed because these cron jobs run as root.

b.t.w., there is no need to use tee; echo 0 > /sys/module/hid_apple/parameters/fnmode should work equally well.

DrPhill avatar
mr flag
Thanks Vanadium. That works a treat- at (least for the user I used to set it up). I was initially thrown by the suggested file being in the temp directory so I read up a little about crontab edit. I like the extra feeling of security from knowing that crontab will check my input.
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.