Wednesday, May 15, 2024
 Popular · Latest · Hot · Upcoming
3
rated 0 times [  3] [ 0]  / answers: 1 / hits: 9146  / 2 Years ago, wed, october 19, 2022, 7:01:34

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


More From » drivers

 Answers
0

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:



  1. Show the current keyboard map by running the following command in the terminal:


xmodmap -pke


  1. Inspect the output and identify lines that contain XF68... right after the = sign like so:


keycode 232 = XF86MonBrightnessDown NoSymbol XF86MonBrightnessDown NoSymbol XF86MonBrightnessDown

The 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'.



  1. Inspect the output and identify lines that contain function keys names F1, F2, ...., F12 right 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_11

The 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'.



  1. Now switch the two keys' values by assigning the F11 functionality to key 232 and XF86MonBrightnessDown functionality to key 95 by running the following two commands in the terminal:


First,


xmodmap -e 'keycode 232 = F11'

Then,


xmodmap -e 'keycode 95 = XF86MonBrightnessDown'


  1. 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:



  1. Create and edit a script file in your home directory by running the following command in the terminal:


nano ~/.Modify_Multimedia_Keys.sh


  1. Add this #!/bin/bash in the first line then add your xmodmap -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'


  1. Save the script file and exit the editor by pressing Ctrl + X then press Y.

  2. Make the script file executable by running the following command in the terminal:


chmod +x ~/.Modify_Multimedia_Keys.sh


  1. 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.desktop file in the ~/.config/autostart/ directory that contains the following content replacing YOUR_USERNAME with 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 keys



Notice:


For more information and other ways of detecting or remapping keys, please refer to this answer.


[#1996] Thursday, October 20, 2022, 2 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
lishrag

Total Points: 306
Total Questions: 109
Total Answers: 125

Location: Saint Lucia
Member since Wed, Feb 8, 2023
1 Year ago
;