2009-04-08 17:08:26 +02:00
|
|
|
---------------------------------------------------------------------------
|
|
|
|
-- @author Julien Danjou <julien@danjou.info>
|
|
|
|
-- @copyright 2009 Julien Danjou
|
|
|
|
-- @release @AWESOME_VERSION@
|
|
|
|
---------------------------------------------------------------------------
|
|
|
|
|
|
|
|
-- Grab environment we need
|
2009-06-15 20:52:40 +02:00
|
|
|
require("awful.dbus")
|
2009-04-08 17:08:26 +02:00
|
|
|
local hooks = require("awful.hooks")
|
|
|
|
local loadstring = loadstring
|
|
|
|
local tostring = tostring
|
|
|
|
local ipairs = ipairs
|
|
|
|
local table = table
|
2009-04-18 16:07:31 +02:00
|
|
|
local dbus = dbus
|
2009-04-08 17:08:26 +02:00
|
|
|
local unpack = unpack
|
|
|
|
local type = type
|
|
|
|
|
|
|
|
--- Remote control module for awful
|
|
|
|
module("awful.remote")
|
|
|
|
|
2009-06-15 20:52:40 +02:00
|
|
|
if dbus then
|
|
|
|
hooks.dbus.register("org.naquadah.awesome.awful.Remote", function(data, code)
|
2009-04-08 17:08:26 +02:00
|
|
|
if data.member == "Eval" then
|
|
|
|
local f, e = loadstring(code)
|
|
|
|
if f then
|
|
|
|
results = { f() }
|
|
|
|
retvals = {}
|
|
|
|
for _, v in ipairs(results) do
|
|
|
|
local t = type(v)
|
|
|
|
if t == "boolean" then
|
|
|
|
table.insert(retvals, "b")
|
|
|
|
table.insert(retvals, v)
|
|
|
|
elseif t == "number" then
|
|
|
|
table.insert(retvals, "d")
|
|
|
|
table.insert(retvals, v)
|
|
|
|
else
|
|
|
|
table.insert(retvals, "s")
|
|
|
|
table.insert(retvals, tostring(v))
|
|
|
|
end
|
|
|
|
end
|
|
|
|
return unpack(retvals)
|
|
|
|
elseif e then
|
|
|
|
return "s", e
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end)
|
|
|
|
end
|
|
|
|
|
|
|
|
-- vim: filetype=lua:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80
|