GithubHelp home page GithubHelp logo

goose121 / alsd Goto Github PK

View Code? Open in Web Editor NEW
2.0 1.0 0.0 46 KB

An ambient light sensor daemon which responds to ACPI events

License: GNU General Public License v3.0

Rust 36.50% Common Lisp 63.50%

alsd's Introduction

alsd

alsd is a relatively simple Common Lisp program (with a Rust helper) which updates the display backlight brightness in accordance with ambient light sensor values. It requires als_bus in order to function. Configuration is mainly done by setting dynamic variable values; most of the variable declarations should be near the beginnings of files.

Usage

alsd is started using either the START-DAEMON or ENTRY-POINT function. START-DAEMON is mainly meant for interactive usage, while ENTRY-POINT is the entry point for creating an executable image, which can be done by soft-linking alsd.asd to a location where ASDF can find it, then executing (asdf:make :alsd) at a REPL. The first argument to either START-DAEMON or to the generated executable should be the path to the alsd-handler executable. Note that the alsd-handler executable must have certain permissions, detailed in the Installation section.

IPC

alsd can be controlled via a socket, which is created by default as an anonymous Unix-domain socket named alsd-ctl. It currently supports 3 commands: (update-screen), which updates the screen brightness in accordance with current ambient light conditions, and writes T back on the socket; (adjust-brightness AMOUNT), which adjusts the user-supplied brightness factor (which is multiplied by the factor associated with the current ambient brightness to obtain the actual brightness percentage) by AMOUNT percentage points and writes the new brightness value back on the socket; and (stop) (aliases (quit) and (exit)), which causes the daemon to shut down gracefully. Note that it closes the socket connection with a client after each command and that the commands are not processed in parallel so it can only handle one request at a time.

Building

Building the helper

$ cd /path/to/alsd/sources
$ cd alsd-helper
$ cargo build --release

Building a standalone alsd executable (optional)

These instructions are for SBCL, but they should work for any Common Lisp implementation by simply replacing sbcl with that Lisp interpreter’s executable, and fiddling with its arguments somewhat to make it evaluate (asdf:make :alsd).

$ cd /path/to/alsd/sources
# Note: this may need to be replaced with a different path depending
# on your local value of asdf:*central-registry*
$ ln -s alsd.asd ~/common-lisp/
$ sbcl --eval "(asdf:make :alsd)"

Installation

$ cd /path/to/alsd/sources
# This can go anywhere you want; its path just needs to be passed to
# alsd as an argument
$ sudo cp alsd-helper/target/release/alsd-helper /usr/local/sbin/
# Currently this is implemented as a setuid executable; in the future,
# it may be preferable to use capabilites (specifically CAP_NET_ADMIN)
# for security reasons
$ sudo chmod u+s /usr/local/sbin/alsd-helper

alsd's People

Contributors

goose121 avatar

Stargazers

 avatar  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.