• Stars
    star
    170
  • Rank 222,843 (Top 5 %)
  • Language
    C
  • License
    Mozilla Public Li...
  • Created over 8 years ago
  • Updated about 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

One-stop automation system for Linux

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

More Repositories

1

picom

A lightweight compositor for X11
C
3,965
star
2

runa

wayland compositor toolbox
Rust
100
star
3

index_camera_passthrough

Experimental Valve Index camera passthrough for Linux
Rust
33
star
4

job-security

job control from anywhere!
Rust
24
star
5

picom-xrdesktop-companion

picom's companion program to bring your desktop to XR
C
20
star
6

tooltip.nvim

Display tooltip for neovim
Python
12
star
7

wimp

WhereIsMyPointer
Rust
7
star
8

.files

Linux configuration
Nu
7
star
9

playgsf

GSF player with visualization (WIP)
C++
7
star
10

test.h

Header only C unit testing framework
C
6
star
11

SadOS

It makes me sad because I wasn't able to finish it
C
6
star
12

robot-stm32

A robotic vacuum cleaner
C
5
star
13

bcachefs-mount

A helper tool for mounting bcachefs
Rust
4
star
14

cvca

Contiguously Valued Cell Automata
JavaScript
4
star
15

protoplasm

A compiler for a simple language
Python
3
star
16

explain-algorithms

Computer algorithms in human readable format
HTML
2
star
17

cgrouper

cgrouper
C
2
star
18

entangle

Forward input devices over network
Rust
2
star
19

git-clang-format-lint

Shell
2
star
20

docconfig

Generate sample configuration file from serde serializable types
Rust
1
star
21

dotvim

Vim config
Vim Script
1
star
22

netsim

Content-aware file-sharing/video-streaming network simulator.
C
1
star
23

gentoo-overlay

Shell
1
star
24

tprj

~
C
1
star
25

ml_experiments

ML related experiments
Python
1
star
26

tinyvecdeq

Rust
1
star
27

misceltools

Miscellaneous tools
D
1
star
28

cfg.h

Header only config file & command line option library for C
C
1
star
29

pathogen

Generating parser directly from type definition
D
1
star
30

runa-adventure

Shell
1
star
31

borderless

a blogging system
CoffeeScript
1
star
32

puncher

A passive packet forwarder
C
1
star
33

DeTerminus

DeTerminus Font
Python
1
star
34

uchroot

chroot with user namespace
Rust
1
star
35

lethe

Shoot 'Em Up game engine WIP
D
1
star
36

evolve_image

Trianglize image using DNA algorithm
JavaScript
1
star
37

keygames

Implementation of key distribution schemes in different language
Rust
1
star
38

klipper

Klipper split out from plasma-workspace
C++
1
star
39

sync-bot

A wrapper of rsync for mirror sites.
Perl
1
star
40

antiad

youku antiad, a fork of http://git.oschina.net/kawaiiushio/antiad.git
JavaScript
1
star
41

inputsynth

X11 input synthesis
Rust
1
star
42

atomi

Fork of the AwesomeWM lua library
Lua
1
star
43

urstore

Universal Remote Store library (WIP)
C
1
star
44

dcon

Code snippet for programming contests
D
1
star
45

sorttabs

Tab sorting extension for firefox
TypeScript
1
star
46

ncproxy

NoCash Proxy
JavaScript
1
star
47

sdpc

Simple D Parser Combinator
D
1
star