Skip to content

Instantly share code, notes, and snippets.

@OndraZizka
Created October 4, 2022 11:54
Show Gist options
  • Save OndraZizka/2e05346a39194f6e03e99f1781a0cfba to your computer and use it in GitHub Desktop.
Save OndraZizka/2e05346a39194f6e03e99f1781a0cfba to your computer and use it in GitHub Desktop.
Apple screen brightness control script for Linux (Ubuntu)
##
## This is not a script, rather a sequence of commands to do.
## I have tested it and it works.
## Use at your own responsibility.
## Compiled from https://www.dionysopoulos.me/apple-display-brightness-controls-in-ubuntu-desktop.html
## See https://github.com/yhaenggi/acdcontrol.git for more info.
##
sudo apt-install g++ make
git clone https://github.com/yhaenggi/acdcontrol.git
cd acdcontrol && make
chmod +x acdcontrol
sudo cp acdcontrol /usr/local/bin
sudo chown root:users /usr/local/bin/acdcontrol
sudo chmod 0755 /usr/local/bin/acdcontrol
sudo chmod +s /usr/local/bin/acdcontrol
lsusb | grep Apple ## You should see Apple LED Cinema or such
if [ -f /etc/udev/rules.d/50-apple-display.rules ] ; then echo "/etc/udev/rules.d/50-apple-display.rules already exists!"; read ; fi
YOUR_GROUP=`id -gn`
echo 'KERNEL=="hiddev*", ATTRS{idVendor}=="05ac", ATTRS{idProduct}=="9226", GROUP="'$YOUR_GROUP'", OWNER="root", MODE="0660"' >> /etc/udev/rules.d/50-apple-display.rules
sudo udevadm control --reload-rules
sudo udevadm trigger
acdcontrol --detect /dev/usb/hiddev*
## Should list something like: /dev/usb/hiddev1: USB Monitor - SUPPORTED. Vendor= 0x5ac (Apple), Product=0x9226[Apple Cinema HD Display 27"
cat << EOF > sudo chmod +x /usr/local/bin/appleLcdBrightness
#!/bin/bash
HIDDEV=`acdcontrol --detect /dev/usb/hiddev* | grep -Po "/dev/usb/hiddev[0-9]"`
acdcontrol $HIDDEV -- $@ > /dev/null
EOF
sudo chmod +x /usr/local/bin/appleLcdBrightness
## Now let's test it: A scale between 0 and 1000
appleLcdBrightness +200
appleLcdBrightness -200
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment