Giter VIP home page Giter VIP logo

toggle-leds's Introduction

toggle-leds

Toggle LEDs using triggers. Made for discrete notifications (e.g. while sitting in a lecture hall at cfgmgmtcamp :).

Usage

To blink the caps lock trigger on a ThinkPad when host.example.org responds to ping requests:

until ping -w2 -c1 -D host.example.org &>/dev/null; do
  echo -n .
  sleep 1
done && while sleep 0.5; do
  ./build/toggle-leds input4::capslock
done

In the above we send a single ICMP packet (-c1), exit after a deadline of 2 seconds (-w2) and use quiet mode (-q) and throw stdout and stderr away (&>/dev/null). Until ping exits with an exit code of 0 we’ll print a single dot with no newline (echo -n .) and sleep 1 second (which also means that we have an easier time killing the process if we want to cancel it).

When ping exits with 0 we’ll toggle the input4::capslock LED every 0.5 seconds until terminated.

Available LEDs

The available LEDs differ between platforms. On a ThinkPad A485 the following are available:

$ find /sys/class/leds/ -mindepth 1 -maxdepth 1 -type d -follow -exec basename {} \; | sort
input4::capslock
input4::numlock
input4::scrolllock
input8::capslock
input8::compose
input8::kana
input8::numlock
input8::scrolllock
phy0-led
platform::micmute
platform::mute
tpacpi::kbd_backlight
tpacpi::power
tpacpi::standby
tpacpi::thinklight
tpacpi::thinkvantage

Note that not all of these actually work; Lenovo sadly decided to do away with the awesome thinklight

To show a list of LEDs on your platform, run the following command:

find /sys/class/leds/ -mindepth 1 -maxdepth 1 -type d -follow -exec basename {} \; |
  sort

Notes

The binary needs read/write access to the brightness file and read access to the max_brightness file for LED devices under /sys/class/leds/ to work. The Makefile does this automatically, but for posterity this is the command you need to run — …but only if you understand what it actually does; setuid is dangerous!

setuid u+s ./build/toggle-leds

toggle-leds's People

Contributors

runejuhl avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.