mirror of https://github.com/lcpz/lain.git
lain is now as asynchronous as possible
This commit is contained in:
parent
c0deea2503
commit
d836fcd625
|
@ -67,7 +67,7 @@ function calendar.show(t_out, inc_offset, scr)
|
|||
calendar.notification_preset.screen = src or 1
|
||||
end
|
||||
|
||||
async(string.format("%s -c '%s'", awful.util.shell, f), function(ws)
|
||||
async(f, function(ws)
|
||||
fg, bg = calendar.notification_preset.fg, calendar.notification_preset.bg
|
||||
ws = ws:gsub("%c%[7m%d+%c%[27m", markup.bold(markup.color(bg, fg, today)))
|
||||
calendar.notification = naughty.notify({
|
||||
|
@ -94,7 +94,7 @@ function calendar.attach(widget, args)
|
|||
end
|
||||
|
||||
if widget then
|
||||
widget:connect_signal("mouse::enter", function () calendar.show() end)
|
||||
widget:connect_signal("mouse::enter", function () calendar.show(0) end)
|
||||
widget:connect_signal("mouse::leave", function () calendar.hide() end)
|
||||
widget:buttons(awful.util.table.join(awful.button({ }, 1, function ()
|
||||
calendar.show(0, -1, calendar.scr_pos) end),
|
||||
|
|
|
@ -38,8 +38,7 @@ local function worker(args)
|
|||
end
|
||||
|
||||
function kbdlayout.update()
|
||||
helpers.async(string.format("%s -c 'setxkbmap -query'", awful.util.shell),
|
||||
function(status)
|
||||
helpers.async("setxkbmap -query", function(status)
|
||||
kbd_run_settings(string.match(status, "layout:%s*([^\n]*)"),
|
||||
string.match(status, "variant:%s*([^\n]*)"))
|
||||
end)
|
||||
|
|
|
@ -79,8 +79,8 @@ local function worker(args)
|
|||
}
|
||||
|
||||
local path = string.format("%s/%s", music_dir, string.match(moc_now.file, ".*/"))
|
||||
local cover = string.format("%s -c \"find '%s' -maxdepth 1 -type f | egrep -i -m1 '%s'\"", shell, path, cover_pattern)
|
||||
helpers.async(cover, function(current_icon)
|
||||
local cover = string.format("find '%s' -maxdepth 1 -type f | egrep -i -m1 '%s'", path, cover_pattern)
|
||||
helpers.async({ shell, "-c", cover }, function(current_icon)
|
||||
common.icon = current_icon:gsub("\n", "")
|
||||
moc.id = naughty.notify(common).id
|
||||
end)
|
||||
|
|
|
@ -26,7 +26,7 @@ function redshift:start()
|
|||
end
|
||||
|
||||
function redshift:toggle()
|
||||
async(string.format("%s -c 'ps -p %d -o pid='", awful.util.shell, redshift.pid), function(f)
|
||||
async({ awful.util.shell, "-c", string.format("ps -p %d -o pid=", redshift.pid) }, function(f)
|
||||
if f and #f > 0 then -- redshift is running
|
||||
-- Sending -USR1 toggles redshift (See project website)
|
||||
execute("pkill -USR1 redshift")
|
||||
|
|
|
@ -30,11 +30,10 @@ function task.show(scr)
|
|||
task.notification_preset.screen = scr
|
||||
end
|
||||
|
||||
helpers.async(string.format("%s -c '%s'", awful.util.shell, task.cmd),
|
||||
function(f)
|
||||
helpers.async(task.show_cmd, function(f)
|
||||
task.notification = naughty.notify({
|
||||
preset = task_notification_preset,
|
||||
title = task.cmd,
|
||||
title = task.show_cmd,
|
||||
text = markup.font(task.notification_preset.font,
|
||||
awful.util.escape(f:gsub("\n*$", "")))
|
||||
})
|
||||
|
@ -46,10 +45,9 @@ function task.prompt()
|
|||
prompt = task.prompt_text,
|
||||
textbox = awful.screen.focused().mypromptbox.widget,
|
||||
exe_callback = function(t)
|
||||
helpers.async(string.format("%s -c '%s'", awful.util.shell, t),
|
||||
function(f)
|
||||
helpers.async(t, function(f)
|
||||
naughty.notify {
|
||||
preset = task_notification_preset,
|
||||
preset = task.notification_preset,
|
||||
title = t,
|
||||
text = markup.font(task.notification_preset.font,
|
||||
awful.util.escape(f:gsub("\n*$", "")))
|
||||
|
@ -62,7 +60,7 @@ end
|
|||
|
||||
function task.attach(widget, args)
|
||||
local args = args or {}
|
||||
task.show_cmd = args.cmd or "task"
|
||||
task.show_cmd = args.show_cmd or "task next"
|
||||
task.prompt_text = args.prompt_text or "Enter task command: "
|
||||
task.followtag = args.followtag or false
|
||||
task.notification_preset = args.notification_preset
|
||||
|
|
|
@ -76,7 +76,7 @@ local function worker(args)
|
|||
|
||||
function update()
|
||||
fs_info, fs_now = {}, {}
|
||||
helpers.async(string.format("%s -c 'LC_ALL=C df -k --output=target,size,used,avail,pcent'", shell), function(f)
|
||||
helpers.async({ shell, "-c", "LC_ALL=C df -k --output=target,size,used,avail,pcent" }, function(f)
|
||||
for line in string.gmatch(f, "\n[^\n]+") do
|
||||
local m,s,u,a,p = string.match(line, "(/.-%s).-(%d+).-(%d+).-(%d+).-([%d]+)%%")
|
||||
m = m:gsub(" ", "") -- clean target from any whitespace
|
||||
|
|
|
@ -39,14 +39,14 @@ local function worker(args)
|
|||
|
||||
local mpdh = string.format("telnet://%s:%s", host, port)
|
||||
local echo = string.format("printf \"%sstatus\\ncurrentsong\\nclose\\n\"", password)
|
||||
local cmd = string.format("%s -c '%s | curl --connect-timeout 1 -fsm 3 %s'", shell, echo, mpdh)
|
||||
local cmd = string.format("%s | curl --connect-timeout 1 -fsm 3 %s", echo, mpdh)
|
||||
|
||||
mpd_notification_preset = { title = "Now playing", timeout = 6 }
|
||||
|
||||
helpers.set_map("current mpd track", nil)
|
||||
|
||||
function mpd.update()
|
||||
helpers.async(cmd, function(f)
|
||||
helpers.async({ shell, "-c", cmd }, function(f)
|
||||
mpd_now = {
|
||||
random_mode = false,
|
||||
single_mode = false,
|
||||
|
@ -110,8 +110,8 @@ local function worker(args)
|
|||
|
||||
if not string.match(mpd_now.file, "http.*://") then -- local file instead of http stream
|
||||
local path = string.format("%s/%s", music_dir, string.match(mpd_now.file, ".*/"))
|
||||
local cover = string.format("%s -c \"find '%s' -maxdepth 1 -type f | egrep -i -m1 '%s'\"", shell, path, cover_pattern)
|
||||
helpers.async(cover, function(current_icon)
|
||||
local cover = string.format("find '%s' -maxdepth 1 -type f | egrep -i -m1 '%s'", path, cover_pattern)
|
||||
helpers.async({ shell, "-c", cover }, function(current_icon)
|
||||
common.icon = current_icon:gsub("\n", "")
|
||||
mpd.id = naughty.notify(common).id
|
||||
end)
|
||||
|
|
|
@ -10,7 +10,6 @@
|
|||
local helpers = require("lain.helpers")
|
||||
local naughty = require("naughty")
|
||||
local wibox = require("wibox")
|
||||
local shell = require("awful.util").shell
|
||||
local string = { format = string.format,
|
||||
match = string.match }
|
||||
local setmetatable = setmetatable
|
||||
|
@ -35,7 +34,7 @@ local function worker(args)
|
|||
net.iface = (args.iface and type(args.iface) == "string" and {args.iface}) or {}
|
||||
|
||||
function net.get_device()
|
||||
helpers.async(string.format("%s -c 'ip link show'", shell, device_cmd), function(ws)
|
||||
helpers.async(string.format("ip link show", device_cmd), function(ws)
|
||||
ws = ws:match("(%w+): <BROADCAST,MULTICAST,.-,UP,LOWER_UP>")
|
||||
net.iface = ws and { ws } or {}
|
||||
end)
|
||||
|
|
2
wiki
2
wiki
|
@ -1 +1 @@
|
|||
Subproject commit 3d8de07f057bcc4cb16bb1244e53276ea11ecff4
|
||||
Subproject commit 991e3bb813a650a6d6bcd27a9563a746fe489716
|
Loading…
Reference in New Issue