-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgapa.py
38 lines (29 loc) · 1.08 KB
/
gapa.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
import rumps
import os
from subprocess import call
FILE_NAME_STATUS = "gapak"
class Gapa(rumps.App):
def __init__(self, name):
super().__init__(name, icon='images/circle.png', menu=['Toggle Desktop Items', None, 'Quit'], quit_button=None)
try:
with open(FILE_NAME_STATUS, "r") as file:
self.__isHidden = (file.readlines().pop(0) == 'True')
except FileNotFoundError:
self.__isHidden = False
@rumps.clicked('Toggle Desktop Items')
def hide(self, _):
desktop = '{0}/Desktop/**'.format(os.path.expanduser('~'))
if not self.__isHidden:
call("/usr/bin/chflags hidden " + desktop, shell=True)
self.__isHidden = True
else:
call("/usr/bin/chflags nohidden " + desktop, shell=True)
self.__isHidden = False
@rumps.clicked('Quit')
def clean_up_before_quit(self, _):
with open(FILE_NAME_STATUS, "w") as file:
file.write(str(self.__isHidden))
rumps.quit_application()
if __name__ == "__main__":
app = Gapa("gapa")
app.run()