Advertisement
Guest User

update_dash_icon

a guest
Aug 22nd, 2014
167
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.71 KB | None | 0 0
  1. #!/usr/bin/python
  2. # update bar on dash icon bye stdin
  3. # ex: for i in {0..100};do echo "$i";sleep 0.3;done | ./$0
  4.  
  5. import sys, time
  6. from gi.repository import Unity, Gio, GObject, Dbusmenu
  7.  
  8. loop = GObject.MainLoop()
  9.  
  10. launcher = Unity.LauncherEntry.get_for_desktop_id ("launcher.desktop")
  11. launcher.set_property("progress_visible", True)
  12.  
  13. def update_line():
  14.     line = sys.stdin.readline()
  15.     while line :
  16.         line = float(line) * .01
  17.         launcher.set_property("progress", line)
  18.         line = sys.stdin.readline()
  19.         if len(line) == 0: # fin de ~"fichier"
  20.             launcher.set_property("urgent", True)
  21.             time.sleep(3)
  22.             print "It's the end..."
  23.             loop.quit()
  24.         return True
  25.  
  26. GObject.timeout_add_seconds(1, update_line)
  27. loop.run()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement