Steps to get the fan control keyboard shortcut (FN+F5) to work on your ASUS ROG Zephyrus M GM501
(May work for other pc models as well but I have only tested it on this model)
Save this as a bash script somewhere you can find later:
#!/bin/bash
# Get the current fan mode
current_mode=$(cat /sys/devices/platform/asus-nb-wmi/fan_boost_mode)
# Define the total number of modes and their corresponding labels
declare -A mode_labels=( [0]="Balanced" [1]="Turbo" )
total_modes=2
# Calculate the next mode
next_mode=$(( (current_mode + 1) % total_modes ))
# Write the next mode to the fan_boost_mode file
echo $next_mode | pkexec tee /sys/devices/platform/asus-nb-wmi/fan_boost_mode
# Output the current and next modes
kdialog --passivepopup "Switched Fan to ${mode_labels[$next_mode]}" 4
Make sure to check that the file can be executed as a program.
In Keyboard > Shortcuts setting, select Add a custom shortcut, name it and click on the (none) folder button to direct to the script you just created.
Under Keyboard Bindings, click on unassigned and press the fn+f5 keys to bind to your shortcut.
You will need to enter your sudo password for the script to run, then you should get a desktop notification that the fan has changed speeds.
Additional:
There is a third fan mode that can be added for a silent fan curve (fan is off most of the time), but I do not recommend this mode as it could cause overheating on the laptop. If you wish to modify the script on your own to add this; add mode_labels [2]=“Silent” and change total_modes= to 3.
Everything I tried to avoid entering a password for this resulted in a permissions denied error, I think since it is modifying a system file.