X-Git-Url: https://git.madduck.net/etc/awesome.git/blobdiff_plain/f2fb4f6fdadc1b09877e5ef6bd75e06a668a4080..7af06fff37b5da6ff625e7c1f39306fe7cc04a91:/asyncshell.lua diff --git a/asyncshell.lua b/asyncshell.lua index c05fb6b..0aafa17 100644 --- a/asyncshell.lua +++ b/asyncshell.lua @@ -10,8 +10,8 @@ -- How to use... -- ...asynchronously: -- asyncshell.request('wscript -Kiev', function(f) wwidget.text = f:read("*l") end) --- ...synchronously --- wwidget.text = asyncshell.demand('wscript -Kiev', 5):read("*l") or "Error" +-- ...synchronously: +-- widget:set_text(asyncshell.demand('wscript -Kiev', 5):read("*l") or "Error") local spawn = require('awful.util').spawn @@ -37,13 +37,12 @@ end function asyncshell.request(command, callback) local id = next_id() local tmpfname = asyncshell.file_template .. id - asyncshell.request_table[id] = {callback = callback} + asyncshell.request_table[id] = { callback = callback } local req = - string.format("bash -c '%s > %s; " .. + string.format("sh -c '%s > %s; " .. 'echo "asyncshell.deliver(%s)" | ' .. "awesome-client' 2> /dev/null", - string.gsub(command, "'", "'\\''"), tmpfname, - id, tmpfname) + string.gsub(command, "'", "'\\''"), tmpfname, id) spawn(req, false) return id end