From: copycat-killer Date: Mon, 23 Jan 2017 22:03:13 +0000 (+0100) Subject: lain is now as asynchronous as possible X-Git-Url: https://git.madduck.net/etc/awesome.git/commitdiff_plain/d836fcd6255b34dc19713d9e7b0b737fee738b59?hp=--cc lain is now as asynchronous as possible --- d836fcd6255b34dc19713d9e7b0b737fee738b59 diff --git a/widgets/calendar.lua b/widgets/calendar.lua index e4216e4..7988ba2 100644 --- a/widgets/calendar.lua +++ b/widgets/calendar.lua @@ -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), diff --git a/widgets/contrib/kbdlayout.lua b/widgets/contrib/kbdlayout.lua index 3b514c5..da3084c 100644 --- a/widgets/contrib/kbdlayout.lua +++ b/widgets/contrib/kbdlayout.lua @@ -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) diff --git a/widgets/contrib/moc.lua b/widgets/contrib/moc.lua index 44f46a6..d2f544f 100644 --- a/widgets/contrib/moc.lua +++ b/widgets/contrib/moc.lua @@ -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) diff --git a/widgets/contrib/redshift.lua b/widgets/contrib/redshift.lua index fdda61f..73cc100 100644 --- a/widgets/contrib/redshift.lua +++ b/widgets/contrib/redshift.lua @@ -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") diff --git a/widgets/contrib/task.lua b/widgets/contrib/task.lua index 2f57317..4325437 100644 --- a/widgets/contrib/task.lua +++ b/widgets/contrib/task.lua @@ -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 diff --git a/widgets/fs.lua b/widgets/fs.lua index 3a97d4c..eda3ffc 100644 --- a/widgets/fs.lua +++ b/widgets/fs.lua @@ -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 diff --git a/widgets/mpd.lua b/widgets/mpd.lua index 6011e03..02b5680 100644 --- a/widgets/mpd.lua +++ b/widgets/mpd.lua @@ -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) diff --git a/widgets/net.lua b/widgets/net.lua index ff16075..983ec7a 100644 --- a/widgets/net.lua +++ b/widgets/net.lua @@ -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+): ") net.iface = ws and { ws } or {} end) diff --git a/wiki b/wiki index 3d8de07..991e3bb 160000 --- a/wiki +++ b/wiki @@ -1 +1 @@ -Subproject commit 3d8de07f057bcc4cb16bb1244e53276ea11ecff4 +Subproject commit 991e3bb813a650a6d6bcd27a9563a746fe489716