Add awesome.hostname
Signed-off-by: Uli Schlachter <psychon@znc.in>
This commit is contained in:
parent
2d35886a76
commit
badf338542
14
luaa.c
14
luaa.c
|
@ -56,6 +56,8 @@
|
|||
|
||||
#include <xcb/xcb_atom.h>
|
||||
|
||||
#include <unistd.h> /* for gethostname() */
|
||||
|
||||
#ifdef WITH_DBUS
|
||||
extern const struct luaL_Reg awesome_dbus_lib[];
|
||||
#endif
|
||||
|
@ -255,6 +257,7 @@ luaA_fixups(lua_State *L)
|
|||
* startup.
|
||||
* @field composite_manager_running True if a composite manager is running.
|
||||
* @field unix_signal Table mapping between signal numbers and signal identifiers.
|
||||
* @field hostname The hostname of the computer on which we are running.
|
||||
* @table awesome
|
||||
*/
|
||||
static int
|
||||
|
@ -303,6 +306,17 @@ luaA_awesome_index(lua_State *L)
|
|||
return 1;
|
||||
}
|
||||
|
||||
if(A_STREQ(buf, "hostname"))
|
||||
{
|
||||
/* No good way to handle failures... */
|
||||
char hostname[256] = "";
|
||||
gethostname(&hostname[0], countof(hostname));
|
||||
hostname[countof(hostname) - 1] = '\0';
|
||||
|
||||
lua_pushstring(L, hostname);
|
||||
return 1;
|
||||
}
|
||||
|
||||
return luaA_default_index(L);
|
||||
}
|
||||
|
||||
|
|
|
@ -8,6 +8,8 @@ local manage_called, c_snid
|
|||
client.connect_signal("manage", function(c)
|
||||
manage_called = true
|
||||
c_snid = c.startup_id
|
||||
assert(c.machine == awesome.hostname,
|
||||
tostring(c.machine) .. " ~= " .. tostring(awesome.hostname))
|
||||
end)
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue