Skip to content

Instantly share code, notes, and snippets.

@artizirk
Created August 4, 2016 23:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save artizirk/707769daeb1c7fc5b9c82ff4d45e1eae to your computer and use it in GitHub Desktop.
Save artizirk/707769daeb1c7fc5b9c82ff4d45e1eae to your computer and use it in GitHub Desktop.
Puts my keyboard and mouse to sleep, ie turns off the leds when the screen goes to sleep
#!/bin/bash
old_dpms=""
while true; do
dpms=$(xset -q|grep Monitor|awk '{print $3;}')
if [ "$dpms" != "$old_dpms" ]; then
old_dpms=$dpms
if [ "$dpms" == "Off" ]; then
echo "Puting keyboard and mouse to sleep"
echo auto | sudo tee /sys/bus/usb/devices/3-13/power/control
echo auto | sudo tee /sys/bus/usb/devices/3-14/power/control
else
echo "Waking keyboard and mouse"
echo on | sudo tee /sys/bus/usb/devices/3-13/power/control
echo on | sudo tee /sys/bus/usb/devices/3-14/power/control
fi
fi
sleep 1
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment