Advertisement
Guest User

Untitled

a guest
Jul 2nd, 2013
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.31 KB | None | 0 0
  1. #!/usr/bin/env python
  2.  
  3. import xchat
  4. from gi.repository import Unity, Gio, GObject, Dbusmenu
  5.  
  6.  
  7. __module_name__ = "Unity launcher count"
  8. __module_version__ = "1.0"
  9. __module_description__ = "--"
  10.  
  11. count = {}
  12. launcher = Unity.LauncherEntry.get_for_desktop_id ('hexchat.desktop')
  13.  
  14. def add_count(word, word_eol, userdata):
  15. key = str(xchat.get_info("network") + ":" + xchat.get_info("channel"))
  16. if count.get(key) == None:
  17. count[key] = 0
  18. count[key] += 1
  19. display_count(0,0,0)
  20.  
  21. def clear_count(word, word_eol, userdata):
  22. count[str(xchat.get_info("network") + ":" + xchat.get_info("channel"))] = 0
  23. display_count(0,0,0)
  24.  
  25. def clear_all_count():
  26. count = {}
  27. display_count(0,0,0)
  28.  
  29. def display_count(word, word_eol, userdata):
  30. total = 0
  31. for key in count:
  32. total += count[key]
  33. launcher.set_property ('count', total)
  34. if total > 0:
  35. launcher.set_property ('count_visible', True)
  36. else:
  37. launcher.set_property ('count_visible', False)
  38.  
  39. def show_count(word, word_eol, userdata):
  40. total = 0
  41. for key in count:
  42. total += count[key]
  43. print count
  44. print total
  45.  
  46. xchat.hook_print("Focus Window", clear_count)
  47. xchat.hook_print("Focus Tab", clear_count)
  48. xchat.hook_server("PRIVMSG", add_count)
  49. xchat.hook_command("count", show_count)
  50. xchat.hook_command("count_clear", clear_all_count)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement