File: generate_cs_module_desktop_files.py

package info (click to toggle)
cinnamon 3.2.7-4
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 11,624 kB
  • sloc: ansic: 33,269; python: 18,048; xml: 1,504; makefile: 780; sh: 90; cpp: 54
file content (67 lines) | stat: -rwxr-xr-x 1,896 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#!/usr/bin/python2

DOMAIN = "cinnamon"
PATH = "/usr/share/locale"

import os, gettext, sys
sys.path.append('/usr/lib/linuxmint/common')
import additionalfiles

os.environ['LANG'] = "en_US.UTF-8"
gettext.install(DOMAIN, PATH)






import os
import glob
import polib
import sys
from gi.repository import GLib

try:
    sys.path.append('files/usr/share/cinnamon/cinnamon-settings/modules')
    sys.path.append('files/usr/share/cinnamon/cinnamon-settings/bin')
    mod_files = glob.glob('files/usr/share/cinnamon/cinnamon-settings/modules/*.py')
    mod_files.sort()
    if len(mod_files) is 0:
        raise Exception("No settings modules found!!")
    for i in range(len(mod_files)):
        mod_files[i] = mod_files[i].split('/')[-1]
        mod_files[i] = mod_files[i].split('.')[0]
        if mod_files[i][0:3] != "cs_":
            raise Exception("Settings modules must have a prefix of 'cs_' !!")
    modules = map(__import__, mod_files)
except Exception, detail:
    print detail
    sys.exit(1)


for i in range(len(modules)):
    try:
        mod = modules[i].Module(None)  

        if mod.category in ("admin"):
            category = "Settings;System;"
        else:
            category = "Settings;"

        formatted_keywords = mod.sidePage.keywords.replace(",", ";")
        formatted_keywords = formatted_keywords.replace(", ", ";")

        prefix = """[Desktop Entry]
Icon=%(icon)s
Exec=cinnamon-settings %(module)s
Type=Application
OnlyShowIn=X-Cinnamon;
Categories=Settings;
""" % {'module': mod.name, 'category': category, 'icon': mod.sidePage.icon}

        additionalfiles.generate(DOMAIN, PATH, "files/usr/share/applications/cinnamon-settings-%s.desktop" % mod.name, prefix, mod.sidePage.name, mod.comment, "", None, mod.sidePage.keywords)
        
    except:
        print "Failed to load module %s" % modules[i]
        import traceback
        traceback.print_exc()