pakhandler.py 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. #!/usr/bin/python
  2. # -*- coding: utf-8 -*-
  3. import piksemel
  4. import os
  5. import fnmatch
  6. def updateData(filepath):
  7. parse = piksemel.parse(filepath)
  8. iconFound = False
  9. immoduleFound = False
  10. for icon in parse.tags("File"):
  11. path = icon.getTagData("Path")
  12. if path.startswith("usr/share/icons/hicolor") and not iconFound:
  13. os.system("/usr/bin/gtk-update-icon-cache -f /usr/share/icons/hicolor")
  14. iconFound = True
  15. if immoduleFound:
  16. return
  17. if fnmatch.fnmatch(path, "usr/lib/gtk-3.0/*immodules/*.so") and not immoduleFound:
  18. os.system("/usr/bin/gtk-query-immodules-3.0 --update-cache")
  19. immoduleFound = True
  20. if iconFound:
  21. return
  22. if fnmatch.fnmatch(path, "usr/lib32/gtk-3.0/*immodules/*.so") and not immoduleFound:
  23. os.system("/usr/bin/gtk-query-immodules-3.0-32bit --update-cache")
  24. immoduleFound = True
  25. if iconFound:
  26. return
  27. def setupPackage(metapath, filepath):
  28. updateData(filepath)
  29. def cleanupPackage(metapath, filepath):
  30. pass
  31. def postCleanupPackage(metapath, filepath):
  32. updateData(filepath)