Code Monkey home page Code Monkey logo

deai's Introduction

Table of Contents

deai

Codecov CircleCI Documentation Status

deai is a tool to automate your Linux desktop. It tries to expose common events and interfaces of a Linux system to scripting languages, to enable users to automate tasks with event-driven scripts. Example could be changing screen brightness with time-of-day, or automatically mounting/unmounting removable storage.

Compared unlike using shell scripts, deai is a single tool, rather than a collection of different commands created by different people, so it's more consistent. And handling events with deai's interface is much nicer than reading and parsing text output from commands.

!!!Warning!!! deai is currently under heavy development. Things might break or might not work correctly. If you are thinking about creating plugins for deai, please consider contribute directly to this repository, or wait until deai is stable. This is because neither the API nor the ABI of deai has been finalized. New changes to deai could break your plugins.

Documentation

Most of deai is documented here

There are also a few examples given here. If you need more information, you can ask me

Build and Run

Build Dependencies

  • libev
  • libudev (optional, for the udev plugin)
  • dbus-libs (optional, for the dbus plugin)
  • xorg (optional, for the xorg plugin)
    • xcb
    • xcb-randr
    • xcb-xinput
    • xcb-xkb
    • libxkbcommon
    • xcb-util-keysyms
  • lua (optional, for the lua plugin)
  • libinotify (optional, for the file plugin)

Usage

/path/to/deai module.method arguments...

A more detailed explanation of how the command line arguments works can be found here

Current features

Right now the only supported scripting language is Lua, so the examples will be give in Lua.

  • Launching programs

    -- "di" is how you access deai functionality in lua
    -- "di.spawn" refers to the "spawn" module
    -- "run" is the method that executes program
    p = di.spawn:run({"ls", "-lh"})
    p:on("stdout_line", function(line)
        print("output: ", line)
    end)
    p:on("exit", function()
        -- This tells deai to exit
        di:quit()
    end)
  • Set timer

    di.event:timer(10):on("elapsed", function()
        print("Time flies!")
    end)
  • Change/set environment variables

    di.os.env["PATH"] = "/usr"
  • Watch file changes

    (See this for all possible signals)

    watcher = di.file:watch({"."})
    watcher:on("open", function(dir, filepath)
        print(dir, filepath)
    end)
  • Connect to Xorg

    -- Connect to Xorg is the first step to get X events
    xc = di.xorg:connect()
    -- You can also use :connect_to(DISPLAY)
  • Set xrdb

    -- Assuming you have connected to X
    xc.xrdb = "Xft.dpi:\t192\n"
  • X Key bindings

    (See this for more information)

    -- Map ctrl-a
    xc.key:new({"ctrl"}, "a", false):on("pressed", function()
        -- do something
    end)
  • Get notified for new input devices

    xc.xinput:on("new-device", function(dev)
        print(dev.type, dev.use, dev.name, dev.id)
        -- do something about the device
    end)
  • Change input device properties

    (See this for more information)

    -- Assuming you get a dev from an "new-device" event
    if dev.type == "touchpad" then
        -- For property names, see libinput(4)
        dev.props["libinput Tapping Enabled"] = {1}
    end
    
    if dev.name == "<<<Some touchscreen device name here>>>" then
        -- Map your touchscreen to an output, if you use multiple
        -- monitors, you will understand the problem.
        M = compute_transformation_matrix(touchscreen_output)
        dev.props["Coordinate Transformation Matrix"] = M
    end
  • Get notified when resolution change, or when new monitor is connected, etc.

    (See this for more information)

    -- Note: RandR support is not quite done
    xc.randr:on("view-change", function(v)
        -- A "view" is a rectangular section of the X screen
        -- Each output (or monitor) is connected to one view
        for _, o in pairs(v.outputs) do
            -- But each view might be used by multiple outputs
            print(o.name)
        end
    end)
  • Adjust backlight

    for _, o in pairs(xc.randr.outputs) do
        -- Backlight must be set with an integer, math.floor is required here
        o.backlight = math.floor(o.max_backlight/2)
    end

Planned features

  • dbus support: Lots of the interfaces are now exposed via dbus, such as UDisks to manage removable storage, UPower for power management. So obviously dbus support is a must have.

  • Audio: Support adjust volumes, etc., via ALSA or Pulseaudio

  • Network: Support for network events and react to them. For example, automatically connect to VPN after switching to an open WiFi.

  • Power management: Reacts to power supply condition changes, etc.

  • UI components: Allows you to create tray icons, menus, etc. So you can interact with deai using a GUI.

  • More languages: Support everyone's favourite scripting languages!

  • And more... If you want something, just open an issue.

Contact

  • Email: yshuiv7 at gmail dot com

deai's People

Contributors

frasercrmck avatar gflegar avatar jbreitbart avatar kbenzie avatar tristan0x avatar yshui avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

deai's Issues

xorg features support

  • keyboard: changing keyboard layout, etc.
  • xrdb
  • clipboard
  • connect to a specific DISPLAY
  • xrandr (partially)
    • get screen size info so I can recalibrate my touch screen
    • handle screen change events to automatically do that every time I plug in a new monitor
    • also backlight
  • replace xbindkeys

Project Motivation

I was just looking for a ready made xrandr solution for my awesomewm config. And I came across this project as a possible option. Well, there are not many dependencies, simple C code, and the use of lua for configuration. This is the bingo that I love.
While reading the readme, I came across a mention that you are planning to add an implementation of UI components. And then I got confused. If you add more windowing functionality, you will end up with a less functional (in terms of ui ) version of awesomewm. But why? Why not just join this project and fix / add the necessary functionality?
Considering you are developing picom you could add an integration to control the compositor from the awesome config which would be really awesome especially for animations.
Does awesomewm have some fatal flaw? Is it just a desire to satisfy the nih syndrome (I don’t think it’s bad)?

dbus support

Add support for dbus:

  • invoke dbus methods
  • exposes deai objects on dbus

Support exec

One use case is deai can use exec to relaunch itself, thus supporting reloading config file

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.