helpers.lua 889 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. -- {{{ License
  2. -- Awesome helpers
  3. -- 2012, Emmanuel Bouthenot <kolter@openics.org>
  4. --
  5. -- This file is distributed in the hope that it will be useful,
  6. -- but WITHOUT ANY WARRANTY
  7. --
  8. -- }}}
  9. -- {{{ Libraries
  10. -- Notification library
  11. require('naughty')
  12. -- User libraries
  13. require('utils')
  14. -- }}}
  15. -- {{{ Functions
  16. function whereis(program)
  17. local fh = io.popen('which ' .. program)
  18. path = string.trim(fh:read('*a'))
  19. fh:close()
  20. if path == "" then
  21. path = nil
  22. end
  23. return path
  24. end
  25. function runonce(cmd, screen)
  26. if cmd then
  27. awful.util.spawn_with_shell("pgrep -f -u $USER -x '" .. cmd .. "' >/dev/null 2>&1 || (" .. cmd .. " ; echo Starting '" .. cmd .. "')", screen)
  28. end
  29. end
  30. function debug(message)
  31. naughty.notify({ preset = naughty.config.presets.critical,
  32. title = "Debug message", text = message})
  33. end
  34. -- }}}
  35. -- vim: foldmethod=marker