forked from Elv13/awesome-1
-
Notifications
You must be signed in to change notification settings - Fork 0
/
xrdb.c
50 lines (44 loc) · 1.66 KB
/
xrdb.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
/*
* xrdb.c - X Resources DataBase communication functions
*
* Copyright © 2015 Yauhen Kirylau <[email protected]>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
*/
#include "xrdb.h"
#include "globalconf.h"
#include <string.h>
/* \brief get value from X Resources DataBase
* \param L The Lua VM state.
* \return The number of elements pushed on stack.
* \luastack
* \lparam string xrdb class, ie "URxvt" or ""
* \lparam string xrdb name, ie "background" or "color0"
* \lreturn string xrdb value or nil if not exists. \
*/
int luaA_xrdb_get_value(lua_State *L) {
const char *resource_class = luaL_checkstring(L, 1);
const char *resource_name = luaL_checkstring(L, 2);
char *result = NULL;
if (xcb_xrm_resource_get_string(globalconf.xrmdb, resource_name, resource_class, &result) < 0 ) {
lua_pushnil(L);
} else {
lua_pushstring(L, result);
p_delete(&result);
}
return 1;
}
// vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80