You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

generate_cs_module_desktop_files.py 1.8 KiB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. #!/usr/bin/python3
  2. import os
  3. import gettext
  4. import glob
  5. import sys
  6. from mintcommon import additionalfiles
  7. import traceback
  8. DOMAIN = "cinnamon"
  9. PATH = "/usr/share/locale"
  10. os.environ['LANGUAGE'] = "en_US.UTF-8"
  11. gettext.install(DOMAIN, PATH)
  12. try:
  13. sys.path.append('files/usr/share/cinnamon/cinnamon-settings')
  14. sys.path.append('files/usr/share/cinnamon/cinnamon-settings/modules')
  15. sys.path.append('files/usr/share/cinnamon/cinnamon-settings/bin')
  16. mod_files = glob.glob('files/usr/share/cinnamon/cinnamon-settings/modules/*.py')
  17. mod_files.sort()
  18. if len(mod_files) is 0:
  19. print("No settings modules found!!")
  20. sys.exit(1)
  21. mod_files = [x.split('/')[-1].split('.')[0] for x in mod_files]
  22. for mod_file in mod_files:
  23. if mod_file[0:3] != "cs_":
  24. raise Exception("Settings modules must have a prefix of 'cs_' !!")
  25. print(mod_files)
  26. modules = map(__import__, mod_files)
  27. except Exception as detail:
  28. print(detail)
  29. sys.exit(1)
  30. for module in modules:
  31. try:
  32. mod = module.Module(None)
  33. if mod.category in ("admin"):
  34. category = "Settings;System;"
  35. else:
  36. category = "Settings;"
  37. formatted_keywords = mod.sidePage.keywords.replace(",", ";")
  38. formatted_keywords = formatted_keywords.replace(", ", ";")
  39. prefix = """[Desktop Entry]
  40. Icon=%(icon)s
  41. Exec=cinnamon-settings %(module)s
  42. Type=Application
  43. OnlyShowIn=X-Cinnamon;
  44. Categories=Settings;
  45. """ % {'module': mod.name, 'category': category, 'icon': mod.sidePage.icon}
  46. additionalfiles.generate(DOMAIN, PATH, "files/usr/share/applications/cinnamon-settings-%s.desktop" % mod.name, prefix, mod.sidePage.name, mod.comment, "", None, mod.sidePage.keywords)
  47. except Exception:
  48. print("Failed to load module %s" % module)
  49. traceback.print_exc()