Fn key lock of Logitech keyboard
I have a Logitech G512 Carbon (wired usb keyboard) and I am sick of having to use the fn key to pause music or adjust the volume. On windows, I use logitech software to turn on fn lock so I can access media keys directly (without holding fn). Is there a way to do this on ubuntu? I haven't been able to find a solution for this.
EDIT:
Things I tried:
- Solaar
- Bunch of key combinations that are meant to activate fn lock. Looks like this keyboard does not support that
2 Answers
I assume that currently function keys F1, F2,.....,F12 work without Fn and multimedia keys work with Fn and you want the opposite.
What you can do in this case is to remap function keys to work with Fn and multimedia keys to work without Fn by following these steps:
- Show the current keyboard map by running the following command in the terminal:
xmodmap -pke- Inspect the output and identify lines that contain
XF68...right after the=sign like so:
keycode 232 = XF86MonBrightnessDown NoSymbol XF86MonBrightnessDown NoSymbol XF86MonBrightnessDownThe above line, for example, shows that the key with code number 232 is currently configured to trigger XF86MonBrightnessDown which will decrease the monitor's brightness and you can change this behavior by assigning a different value to it like so xmodmap -e 'keycode 232 = New_Value'.
- Inspect the output and identify lines that contain function keys names
F1, F2, ...., F12right after the=sign like so:
keycode 95 = F11 F11 F11 F11 F11 F11 XF86Switch_VT_11 F11 F11 XF86Switch_VT_11 F11 F11 F11 F11 XF86Switch_VT_11The above line, for example, shows that the key with code number 95 is currently configured to trigger F11 function and you can change this behavior by assigning a different value to it like so xmodmap -e 'keycode 95 = New_Value'.
- Now switch the two keys' values by assigning the F11 functionality to key 232 and
XF86MonBrightnessDownfunctionality to key 95 by running the following two commands in the terminal:
First,
xmodmap -e 'keycode 232 = F11'Then,
xmodmap -e 'keycode 95 = XF86MonBrightnessDown'- Do the same for all the multimedia and function keys to reflect what you see on your keyboard.
The new functionality will be effective immediately. This change in functionality will, however, be lost after reboot or logout/login.
To preserve the change after reboots and logouts/logins, you will need to do the following:
- Create and edit a script file in your home directory by running the following command in the terminal:
nano ~/.Modify_Multimedia_Keys.sh- Add this
#!/bin/bashin the first line then add yourxmodmap -e 'keycode Number = New_Value'commands below the first line ( each command in a single new line ) like so:
#!/bin/bash
xmodmap -e 'keycode 232 = F11'
xmodmap -e 'keycode 95 = XF86MonBrightnessDown'- Save the script file and exit the editor by pressing Ctrl + X then press Y.
- Make the script file executable by running the following command in the terminal:
chmod +x ~/.Modify_Multimedia_Keys.sh- Make the script file execute at each start-up either by adding it to your Startup Applications through the GUI or by placing a
Modify_Multimedia_Keys.desktopfile in the~/.config/autostart/directory that contains the following content replacingYOUR_USERNAMEwith your actual username:
[Desktop Entry]
Type=Application
Exec=/home/YOUR_USERNAME/.Modify_Multimedia_Keys.sh
Hidden=false
X-GNOME-Autostart-enabled=true
Name=Modify Multimedia Keys
Comment=This modifies keyboard multimedia keysNotice:
For more information and other ways of detecting or remapping keys, please refer to this answer.
Have a look at the solaar package: apt install solaar solaar-gnome3. This package is designed for use mainly with Logitech wireless keyboards, but also supports some USB keyboards, sometimes with limited functionality.
If you have any success, please consider contributing here:
If this doesn't work, consider building the latest version with the instructions here:
2More in general
"Zoraya ter Beek, age 29, just died by assisted suicide in the Netherlands. She was physically healthy, but psychologically depressed. It's an abomination that an entire society would actively facilitate, even encourage, someone ending their own life because they had no hope. Th…"