My configuration files for Debian/Ubuntu applications
選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。
 
 
 
 
 
 

93 行
2.7 KiB

  1. --[[
  2. Licensed under GNU General Public License v2
  3. * (c) 2013, Jan Xie
  4. --]]
  5. local helpers = require("lain.helpers")
  6. local markup = require("lain.util").markup
  7. local awful = require("awful")
  8. local naughty = require("naughty")
  9. local mouse = mouse
  10. -- Taskwarrior notification
  11. -- lain.widget.contrib.task
  12. local task = {}
  13. function task.hide()
  14. if not task.notification then return end
  15. naughty.destroy(task.notification)
  16. task.notification = nil
  17. end
  18. function task.show(scr)
  19. task.notification_preset.screen = task.followtag and awful.screen.focused() or scr or 1
  20. helpers.async({ awful.util.shell, "-c", task.show_cmd }, function(f)
  21. local widget_focused = true
  22. if mouse.current_widgets then
  23. widget_focused = false
  24. for _,v in ipairs(mouse.current_widgets) do
  25. if task.widget == v then
  26. widget_focused = true
  27. break
  28. end
  29. end
  30. end
  31. if widget_focused then
  32. task.hide()
  33. task.notification = naughty.notify {
  34. preset = task.notification_preset,
  35. title = "task next",
  36. text = markup.font(task.notification_preset.font,
  37. awful.util.escape(f:gsub("\n*$", "")))
  38. }
  39. end
  40. end)
  41. end
  42. function task.prompt()
  43. awful.prompt.run {
  44. prompt = task.prompt_text,
  45. textbox = awful.screen.focused().mypromptbox.widget,
  46. exe_callback = function(t)
  47. helpers.async(t, function(f)
  48. naughty.notify {
  49. preset = task.notification_preset,
  50. title = t,
  51. text = markup.font(task.notification_preset.font,
  52. awful.util.escape(f:gsub("\n*$", "")))
  53. }
  54. end)
  55. end,
  56. history_path = awful.util.getdir("cache") .. "/history_task"
  57. }
  58. end
  59. function task.attach(widget, args)
  60. args = args or {}
  61. task.show_cmd = args.show_cmd or "task next"
  62. task.prompt_text = args.prompt_text or "Enter task command: "
  63. task.followtag = args.followtag or false
  64. task.notification_preset = args.notification_preset
  65. task.widget = widget
  66. if not task.notification_preset then
  67. task.notification_preset = {
  68. font = "Monospace 10",
  69. icon = helpers.icons_dir .. "/taskwarrior.png"
  70. }
  71. end
  72. if widget then
  73. widget:connect_signal("mouse::enter", function () task.show() end)
  74. widget:connect_signal("mouse::leave", function () task.hide() end)
  75. end
  76. end
  77. return task