Guest User

Untitled

a guest
May 23rd, 2018
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.56 KB | None | 0 0
  1. bar_applet("todo", 100) do |wmii, bar|
  2. bar.min_width = -10
  3. todo_file = wmii.plugin_config["erikh:todo"]["filename"] || File.join(ENV["HOME"], ".todo")
  4. terminal_program = wmii.plugin_config["standard"]["x-terminal-emulator"] || "xterm"
  5. editor = wmii.plugin_config["erikh:todo"]["editor"] || "xterm -e #{ENV["EDITOR"]}" || "xterm -e #{ENV["VISUAL"]}" || "xterm -e vi"
  6.  
  7. todo_offset = 0
  8.  
  9. change_todo = lambda do |increment|
  10. if increment
  11. todo_offset += increment
  12.  
  13. todo_offset = 0 if todo_offset < 0
  14. end
  15.  
  16. todo = nil
  17.  
  18. while todo_offset > -1
  19. begin
  20. todo = File.open(todo_file) { |f| f.read.split(/\n/)[todo_offset].strip }
  21. break if todo.length > 0
  22. rescue Exception
  23. end
  24. todo_offset -= 1
  25. end
  26.  
  27. if todo_offset == -1 and todo.length == 0
  28. todo_offset = 0
  29. todo = "Nothing"
  30. end
  31.  
  32. bar.data = "To Do: \##{todo_offset}: #{todo}"
  33. end
  34.  
  35. Thread.new do
  36. loop do
  37. change_todo[nil]
  38. sleep 3
  39. end
  40. end
  41.  
  42. bar.on_click(MOUSE_BUTTON_LEFT) do
  43. system "ssid #{editor} #{todo_file} &"
  44. end
  45.  
  46. bar.on_click(MOUSE_SCROLL_UP) do
  47. change_todo[-1]
  48. end
  49.  
  50. bar.on_click(MOUSE_SCROLL_DOWN) do
  51. change_todo[1]
  52. end
  53. end
Add Comment
Please, Sign In to add comment