forked from linuxmint/mintupdate
-
Notifications
You must be signed in to change notification settings - Fork 1
/
generate_desktop_files
executable file
·59 lines (48 loc) · 1.9 KB
/
generate_desktop_files
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
#!/usr/bin/python
import commands, os
sourceFile = "usr/lib/linuxmint/mintUpdate/mintUpdate.py"
menuName = commands.getoutput("cat " + sourceFile + " | grep menuName")
menuName = menuName.replace("menuName", "")
menuName = menuName.replace("=", "")
menuName = menuName.replace("_(", "")
menuName = menuName.replace("\"", "")
menuName = menuName.replace(")", "")
menuName = menuName.strip()
menuComment = commands.getoutput("cat " + sourceFile + " | grep menuComment")
menuComment = menuComment.replace("menuComment", "")
menuComment = menuComment.replace("=", "")
menuComment = menuComment.replace("_(", "")
menuComment = menuComment.replace("\"", "")
menuComment = menuComment.replace(")", "")
menuComment = menuComment.strip()
desktopFile = open("usr/share/applications/mintUpdate.desktop", "w")
desktopFile.writelines("""[Desktop Entry]
Name=Update Manager
""")
import gettext
gettext.install("mintupdate", "/usr/share/linuxmint/locale")
for directory in os.listdir("/usr/share/linuxmint/locale"):
if os.path.isdir(os.path.join("/usr/share/linuxmint/locale", directory)):
try:
language = gettext.translation('mintupdate', "/usr/share/linuxmint/locale", languages=[directory])
language.install()
desktopFile.writelines("Name[%s]=%s\n" % (directory, _(menuName)))
except:
pass
desktopFile.writelines("Comment=Show and install available updates\n")
for directory in os.listdir("/usr/share/linuxmint/locale"):
if os.path.isdir(os.path.join("/usr/share/linuxmint/locale", directory)):
try:
language = gettext.translation('mintupdate', "/usr/share/linuxmint/locale", languages=[directory])
language.install()
desktopFile.writelines("Comment[%s]=%s\n" % (directory, _(menuComment)))
except:
pass
desktopFile.writelines("""Exec=mintupdate
Icon=/usr/lib/linuxmint/mintUpdate/icons/base.svg
Terminal=false
Type=Application
Encoding=UTF-8
Categories=Application;System;Settings;
StartupNotify=false
""")