-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapplauncher.py
103 lines (86 loc) · 2.26 KB
/
applauncher.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
import sys
import subprocess
import os
import configparser
import re
import glob
from PyQt5.QtWidgets import QApplication, QGraphicsOpacityEffect, QDialog, QLabel, QLineEdit
from PyQt5 import QtCore
from PyQt5.Qt import Qt
o = ""
cmd = ""
class Example(QDialog):
def __init__(self):
super().__init__()
self.setWindowOpacity(0)
self.rpath = None
self.path = None
self.appname = None
self.lineEntry = QLineEdit(self)
self.lineEntry.returnPressed.connect(self.run)
self.lineEntry.move(16,16)
self.lineEntry.resize(200,40)
self.qlabel = QLabel(self)
self.qlabel.move(16,64)
self.lineEntry.textChanged.connect(self.onChanged)
self.setGeometry(50,50,320,200)
self.setWindowTitle("QLineEdit Example")
self.show()
self.paths()
def paths(self):
self.qlabel.adjustSize()
config = configparser.RawConfigParser()
print(config.sections())
#saves all .desktop files to an array
path = glob.glob(f'/usr/share/applications/*.desktop')
names = []
for e in path:
config.read(e)
name = (config['Desktop Entry']['Name'])
a = f'{name }={e}'
names.append(a)
snames = '\n'.join(names)
print(snames)
self.paths = snames
def onChanged(self, text):
rpath=""
appname = ""
print(self.paths)
snames = self.paths
cinput = text.capitalize()
for line in snames.split('\n'):
if cinput in line:
t = re.sub(r'^.*?=', '=', line)
rpath = t.replace("=", "")
print(rpath)
break
for line in snames.split('\n'):
if cinput in line:
sline = ''.join(line)
format = sline.split("=", 1)
appname = format[0]
print(appname)
break
self.rpath = rpath
self.appname = appname
path = os.path.join('/tmp', 'ls.txt')
file = open(path, "w")
file.write(self.appname)
os.system('sh ~/code/appLauncher/barupdate.sh ')
def bar(self):
path = os.path.join('/tmp', 'ls.txt')
file = open(path, "w")
file.write(self.appname)
os.system('echo hook:module/demo2 >>/tmp/polybar_mqueue.*')
def run(self):
config = configparser.RawConfigParser()
print(self.rpath)
config.read(self.rpath)
exec = (config['Desktop Entry']['Exec'])
print(exec)
subprocess.run(f'{exec} & disown', shell=True)
exit()
if __name__ == '__main__':
app = QApplication(sys.argv)
ex = Example()
sys.exit(app.exec_())