目錄
DEAI是使Linux桌面自動化的工具。它試圖將Linux系統的常見事件和界面曝光以拼寫語言,以使用戶能夠使用事件驅動的腳本自動化任務。示例可能是隨著時間的時間改變屏幕亮度,或者自動安裝/卸載可移動存儲。
與使用Shell腳本不同,DEAI是一個工具,而不是由不同人創建的不同命令的集合,因此更一致。使用DEAI的界面處理事件要比閱讀和解析命令的文本輸出要好得多。
! ! !警告! ! ! DEAI目前處於重大發展。事情可能破裂或可能無法正常工作。如果您正在考慮為DEAI創建插件,請考慮直接為此存儲庫做出貢獻,或等到DEAI穩定。這是因為API和DEAI的ABI均未完成。 DEAI的新更改可能會破壞您的插件。
DEAI的大部分記錄在這裡
這裡還有一些例子。如果您需要更多信息,可以問我
udev插件)dbus插件)xorg插件)lua插件)file插件)/path/to/deai module.method arguments...可以在此處找到有關如何工作的命令線參數的更詳細的解釋
目前,唯一支持的腳本語言是lua,因此將在lua中給出示例。
啟動程序
-- "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 )設置計時器
di . event : timer ( 10 ): on ( " elapsed " , function ()
print ( " Time flies! " )
end )更改/設置環境變量
di . os . env [ " PATH " ] = " /usr "觀看文件更改
(有關所有可能的信號,請參閱此信息)
watcher = di . file : watch ({ " . " })
watcher : on ( " open " , function ( dir , filepath )
print ( dir , filepath )
end )連接到Xorg
-- Connect to Xorg is the first step to get X events
xc = di . xorg : connect ()
-- You can also use :connect_to(DISPLAY)設置XRDB
-- Assuming you have connected to X
xc . xrdb = " Xft.dpi: t 192 n "x鍵綁定
(有關更多信息,請參閱此信息)
-- Map ctrl-a
xc . key : new ({ " ctrl " }, " a " , true ): on ( " pressed " , function ()
-- do something
end )通知新輸入設備
xc . xinput : on ( " new-device " , function ( dev )
print ( dev . type , dev . use , dev . name , dev . id )
-- do something about the device
end )更改輸入設備屬性
(有關更多信息,請參閱此信息)
-- 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在更改解決方案或連接新監視器時獲得通知,等等。
(有關更多信息,請參閱此信息)
-- 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 )調整背光
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 DBUS支持:現在,許多接口都通過DBU曝光,例如udisks來管理可移動存儲空間,啟動電源管理。因此,顯然DBUS支持是必須的。
音頻:通過ALSA或Pulseaudio支持調整量等。
網絡:支持網絡事件並對它們做出反應。例如,切換到打開的WiFi後自動連接到VPN。
電源管理:對電源狀況變化的反應等。
UI組件:允許您創建托盤圖標,菜單等。因此,您可以使用GUI與DEAI進行交互。
更多語言:支持每個人喜歡的腳本語言!
還有更多...如果您想要一些東西,那就打開一個問題。