-
Notifications
You must be signed in to change notification settings - Fork 0
/
launcher.py
169 lines (115 loc) · 3.08 KB
/
launcher.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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
#!/usr/bin/python3
#
# FOX LAUNCHER
#
# Created for Fur Desktop Environment
# http://github.com/krushndayshmookh/fur-box
#
# Created by Krushn Dayshmookh
# http://krushndayshmookh.github.io
#
#
import sys
# import subprocess
from os import system
from os import listdir
files = listdir("/usr/share/applications")
files.sort()
#print (files)
appList = []
class AnApp:
"""An app information object"""
name = "no name"
executable = "true"
icon = "folder-new"
category = "unknown"
def readAppName (desktopFile):
x = AnApp()
file = open (desktopFile,"r")
lines = file.readlines()
shouldAppBeShown = True
for data in lines:
prop = data.split("=")
if prop[0] == "Name":
prop[1] = prop[1].replace("\n","")
prop[1] = prop[1].replace(" ","-")
x.name = prop[1]
if prop[0] == "Exec":
prop[1] = prop[1].replace("\n","")
x.executable = prop[1]
if prop[0] == "Icon":
prop[1] = prop[1].replace("\n","")
x.icon = prop[1]
#print (appIcon + "\n")
if prop[0] == "Categories":
prop[1] = prop[1].replace("\n","")
categories = prop[1].split(";")
x.category = categories
if prop[0] == "NoDisplay":
prop[1] = prop[1].replace("\n","")
if prop[1] == "true":
shouldAppBeShown = False
#app = AnApp(appName, appExec, appIcon)
#
#print (x.name)
if shouldAppBeShown:
appList.append(x)
#print (appList[0].name,appList[0].executable,appList[0].icon,)
file.close()
for filename in files:
readAppName("/usr/share/applications"+"/"+filename)
#readAppName("deluge.desktop")
def list():
for app in appList:
print (app.name)
#print (appList)
def runProgram(program):
for app in appList:
if app.name == program:
print (app.name)
system(app.executable)
# -------------- CATEGORIES -----------------------
def addCategory (categoryName, program, categoryKey):
for x in program.category:
if x == categoryKey:
categoryName.append(program)
network = []
development = []
for app in appList:
addCategory(network, app, "Network")
addCategory(network, app, "Internet")
addCategory(development, app, "Development")
#for app in network:
# print (app.name)
# -------------------------------------------------------------
#if __name__ == __main__:
# if sys.argv[1] == "run":
# runProgram(sys.argv[2])
#
# if sys.argv[1] == "list":
# list()
#print sys.argv[0]
#print sys.argv[1]
#print sys.argv[2]
# -------------------------------------------------------------------------------------------------
#
# USAGE INSTRUCTIONS
#
# use "python launcher.py list" to list all applications in /usr/share/applications
#
#
# after that to run "app-name" from the list use "python launcher.py run app-name"
#
#
# This is currently very much in development.
# It may not work at all some times.
#
#
#
#
#
#
#
#
#
#