Last active
April 19, 2026 07:54
-
-
Save QuanTrieuPCYT/8e1f42915715f4837e029d8cedd73b06 to your computer and use it in GitHub Desktop.
Auto-switch between 120Hz and 60Hz when plugged in on MacBook Pro 14-inch running Asahi Linux
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| DISPLAY_NAME="eDP-1" | |
| PLUGGED="3024x1964@120" | |
| UNPLUGGED="3024x1964@60" | |
| toggle() { | |
| if grep -q "1" /sys/class/power_supply/*/online 2>/dev/null; then | |
| kscreen-doctor output."$DISPLAY_NAME".mode."$PLUGGED" | |
| else | |
| kscreen-doctor output."$DISPLAY_NAME".mode."$UNPLUGGED" | |
| fi | |
| } | |
| toggle | |
| udevadm monitor --subsystem-match=power_supply | while read -r event; do | |
| sleep 1 | |
| toggle | |
| done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment