Guest User

Untitled

a guest
Sep 1st, 2018
1,983
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.88 KB | None | 0 0
  1. # Gmail sublet file
  2. # Created with sur-0.2
  3. require "gmail"
  4.  
  5. configure :gmail do |s|
  6. s.interval = s.config[:interval ] || 120
  7. s.icon = Subtlext::Icon.new("mail.xbm")
  8. s.user = s.config[:user]
  9. s.pass = s.config[:password]
  10. s.urgent_background = s.config[:urgent_bg]
  11. s.normal_background = s.config[:sublets_bg]
  12. s.count = 0
  13. end
  14.  
  15. on :run do |s|
  16. begin
  17. gmail = Gmail.new(s.user, s.pass)
  18. numb = gmail.inbox.count(:unread)
  19. gmail.logout
  20. s.count = numb
  21. if s.count > numb
  22. # s.background = s.normal_background
  23. s.data = s.icon + numb
  24. elsif numb == 0
  25. # s.background = s.normal_background
  26. s.data = s.icon + numb
  27. else
  28. s.background = s.urgent_background
  29. s.data = s.icon + numb
  30. end
  31. rescue => err # Sanitize to prevent unloading
  32. s.background = s.urgent_background
  33. s.data = "error"
  34. p err
  35. end
  36. end
Add Comment
Please, Sign In to add comment