Mirror of Awesome WM window manager
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

xrdb.c 1.7KB

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