Guest User

Untitled

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