-
Notifications
You must be signed in to change notification settings - Fork 0
/
creator.py
65 lines (52 loc) · 1.68 KB
/
creator.py
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
#!/usr/bin/env python
# -*- coding: utf-8 -*-
'''
Author: hfabio
'''
import json
import threading
import os
pwas_path = '~/PWAs/'
exists = os.path.isdir(os.path.expanduser(pwas_path))
if not exists:
os.mkdir(os.path.expanduser(pwas_path))
with open('./apps.json', 'r') as f:
data = json.load(f)
apps = data['apps']
def writeDesktopEntry(name):
with open('{}.desktop'.format(name), 'w') as desktop:
desktop.write('[Desktop Entry]\n')
desktop.write('Terminal=false\n')
desktop.write('Name={}\n'.format(name))
desktop.write(
'Exec={}{}-linux-x64/{}\n'.format(os.path.expanduser(pwas_path), name, name))
desktop.write('Type=Application\n')
desktop.write(
'Icon={}{}-linux-x64/resources/app/icon.png\n'.format(os.path.expanduser(pwas_path), name))
desktop.write('Categories=Network;')
desktop.close()
def createApp(url, name, icon):
print('Installing {}'.format(name))
if icon != '':
os.system(
'nativefier "{}" --name "{}" --icon "icons/{}" ~/PWAs'.format(url, name, icon))
else:
os.system('nativefier "{}" --name "{}" ~/PWAs'.format(url, name))
writeDesktopEntry(name)
def create(app):
if 'icon' in app:
createApp(app['url'], app['name'], app['icon'])
else:
createApp(app['url'], app['name'], '')
for app in apps:
create(app)
print('\n'*50)
print('please, insert your sudo password to move all .desktop and create access')
os.system('sudo mv *.desktop /usr/share/applications/')
'''
threads = [threading.Thread(target=create, args=(app,)) for app in apps]
for thread in threads:
thread.start()
for thread in threads:
thread.join()
'''