(no commit message)
[drlaunch] / apps.py
1 #!/usr/bin/env python
2 # coding=UTF-8
3
4 # Copyright (C) 2010 Stefanos Harhalakis
5 #
6 # This file is part of wifieye.
7 #
8 # wifieye is free software: you can redistribute it and/or modify
9 # it under the terms of the GNU General Public License as published by
10 # the Free Software Foundation, either version 3 of the License, or
11 # (at your option) any later version.
12 #
13 # wifieye is distributed in the hope that it will be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 # GNU General Public License for more details.
17 #
18 # You should have received a copy of the GNU General Public License
19 # along with wifieye.  If not, see <http://www.gnu.org/licenses/>.
20 #
21 # $Id: 0.py 2265 2010-02-21 19:16:26Z v13 $
22
23 __version__ = "$Id: 0.py 2265 2010-02-21 19:16:26Z v13 $"
24
25 import os
26
27 #from xdg.IconTheme import getIconPath
28
29 appdir="/usr/share/applications/hildon"
30
31 def readOneFn(fn):
32     global appdir
33
34     fn2=appdir + '/' + fn
35
36     f=open(fn2, 'rt')
37
38     ret={
39         'id':       fn[:-8],
40         'name':     None,
41         'exec':     None,
42         'icon':     None,
43         'iconpath': None,
44         }
45     for line in f:
46         line=line.strip()
47         if line.startswith('Name='):
48             l=line[5:]
49             ret['name']=l
50         elif line.startswith('Exec='):
51             l=line[5:]
52             ret['exec']=l
53         elif line.startswith('Icon='):
54             l=line[5:]
55             ret['icon']=l
56             # ret['iconpath']=getIconPath(l)
57
58     return(ret)
59
60 def readOne(name):
61     fn=name + ".desktop"
62
63     ret=readOneFn(fn)
64
65     return(ret)
66
67 def scan():
68     global appdir
69
70     files=os.listdir(appdir)
71
72     ret={}
73
74     for f in files:
75         if not f.endswith('.desktop'):
76             continue
77         dt=readOneFn(f)
78         t=f[:-8]
79         ret[t]=dt
80
81     return(ret)
82
83 if __name__=="__main__":
84     print scan()
85
86 # vim: set ts=8 sts=4 sw=4 noet formatoptions=r ai nocindent:
87