|
发表于 2009-11-12 09:07:07
|
显示全部楼层
Post by Hosanna;2019547
难道只有我一个人还坚守着FVWM??
还有我
也曾经试过gnome,感觉操作好不习惯,不过等到gnome3.0出来的时候,我可能会转过去
顺便献上代码一枚,解析/usr/share/applications/下的文件生成菜单,生成的只是个雏形,当然要弄的漂亮,还要自己改改
- #!/usr/bin/python
- import ConfigParser
- import string, os, sys
- cf = ConfigParser.ConfigParser()
- menu = []
- submenu = {}
- items = []
- item_list = []
- for f in os.listdir('/usr/share/applications'):
- pwd = '/usr/share/applications/' + f
- if os.path.isfile(pwd):
- cf.read(pwd)
- else:
- continue
- if cf.has_section('Desktop Entry'):
- if cf.has_option('Desktop Entry', 'Name'):
- Name = cf.get('Desktop Entry', 'Name')
- if cf.has_option('Desktop Entry', 'Categories'):
- tmp = cf.get('Desktop Entry', 'Categories')
- Category = tmp.split(';')[0]
- if cf.has_option('Desktop Entry', 'Exec'):
- tmp = cf.get('Desktop Entry', 'Exec')
- Exec = tmp.split(' ')[0]
- if cf.has_option('Desktop Entry', 'Icon'):
- Icon = cf.get('Desktop Entry', 'Icon')
- item = (Category, Name, Icon, Exec)
- if Category not in menu:
- menu.append(Category)
- items.append(item)
- for i in menu:
- item_list = []
- for j in items:
- if i == j[0]:
- item_list.append(j[1:])
- submenu[i] = item_list
-
- print 'DestroyMenu MenuStart'
- print 'AddToMenu MenuStart'
- for i in menu:
- line = '+\t"' + i + '"\t\tPopup SubMenu' + i
- print line
- print '\n\n'
- for i in menu:
- print 'DestroyMenu SubMenu' + i
- print 'AddToMenu SubMenu' + i
- for j in submenu[i]:
- line = '+\t%' + j[1] + '.png%"' + j[0] + '"' + '\t\tExec exec ' + j[2]
- print line
- print '\n'
复制代码 |
本帖子中包含更多资源
您需要 登录 才可以下载或查看,没有帐号?注册
x
|