Skip to content

Instantly share code, notes, and snippets.

@MaxVRAM
Created December 30, 2022 06:23
Show Gist options
  • Save MaxVRAM/a7b7bd22231a64b4f6ea5dd2dad37c2b to your computer and use it in GitHub Desktop.
Save MaxVRAM/a7b7bd22231a64b4f6ea5dd2dad37c2b to your computer and use it in GitHub Desktop.
#!/bin/bash
# Set the function-key lock state on system boot for Fedora 37. Adapted from hglee's solution on Linux Mint:
# https://forums.linuxmint.com/viewtopic.php?p=2247849&sid=dd549cc8f87191b1bf45a5727cdd0fae#p2247849
# Current PARAM and MODULE variables defined for ASUS ExpertBook B5
# Valid values depend on target system.
# Try something like `sudo find / | grep fnlock` or `find /sys/module | grep fn` to locate the relevant system module.
PARAM=fnlock_default
MODULE=asus_wmi
MODFILE=/etc/modprobe.d/fn-lock.conf
if [[ ! -f /sys/module/$MODULE/parameters/$PARAM ]]; then
echo -e "\n** $MODULE $PARAM NOT FOUND **\n"; exit 1
fi
echo
read -p "Enable $PARAM at boot (y/N)? " -n 1 STATE
if [[ $STATE =~ ^[Yy]$ ]]; then
STATE="Y"; else STATE="N"
fi
OPTION="options $MODULE $PARAM=$STATE"
echo -e "\n"
if [[ ! -f $MODFILE ]]; then
echo -e "Creating new modprobe file: $MODFILE"
else
grep -q "$OPTION" "$MODFILE"
if [ $? -eq 0 ]; then
echo -e "** PARAMETER ALREADY SET **"
exit 0
fi
fi
echo -e "$OPTION\n" | sudo tee $MODFILE
echo -e "** $PARAM SUCCESSFULLY UPDATED **"
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment