awful.prompt: "Fix" for multi-byte characters
[awesome.git] / lib / awful / remote.lua.in
blob1b15813d575cb40fdb4474a8a9f987f9bd8fd5e9
1 ---------------------------------------------------------------------------
2 -- @author Julien Danjou <julien@danjou.info>
3 -- @copyright 2009 Julien Danjou
4 -- @release @AWESOME_VERSION@
5 ---------------------------------------------------------------------------
7 -- Grab environment we need
8 require("awful.dbus")
9 local loadstring = loadstring
10 local tostring = tostring
11 local ipairs = ipairs
12 local table = table
13 local dbus = dbus
14 local unpack = unpack
15 local type = type
17 --- Remote control module allowing usage of awesome-client.
18 module("awful.remote")
20 if dbus then
21 dbus.add_signal("org.naquadah.awesome.awful.Remote", function(data, code)
22 if data.member == "Eval" then
23 local f, e = loadstring(code)
24 if f then
25 results = { f() }
26 retvals = {}
27 for _, v in ipairs(results) do
28 local t = type(v)
29 if t == "boolean" then
30 table.insert(retvals, "b")
31 table.insert(retvals, v)
32 elseif t == "number" then
33 table.insert(retvals, "d")
34 table.insert(retvals, v)
35 else
36 table.insert(retvals, "s")
37 table.insert(retvals, tostring(v))
38 end
39 end
40 return unpack(retvals)
41 elseif e then
42 return "s", e
43 end
44 end
45 end)
46 end
48 -- vim: filetype=lua:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80