Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/desktop_luncher.py
blob: 6f050cd516da1be6d2591bcb6f136d4e97c2e226 (plain)
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
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# Copyright (C) 2012 S. Daniel Francis <francis@sugarlabs.org>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
# MA 02110-1301, USA.

import sys
import os
os.environ['INFO_L10N'] = '0'
import pwd
sys.path.append(os.path.abspath('./'))
import info
user = pwd.getpwuid(os.getuid()).pw_name
execdir = '/usr/bin' if user == 'root' else os.path.abspath('./')
appdir = '/usr/share/%s' % info.lower_name if user ==\
 'root' else os.path.abspath('./')

desktop_file = open('app-entry.desktop', 'w')
string = '[Desktop Entry]\nEncoding=UTF-8\n'
string += 'Name=' + info.name
string += '\nGenericName=' + info.generic_name
string += '\nComment=' + info.description
if user == 'root':
    string += '\nExec=/usr/bin/command %U'.replace('command', info.lower_name)
else:
    string += '\nExec=' + os.path.join(appdir, info.lower_name) + ' %U'
string += '\nIcon=' + os.path.join(appdir, info.lower_name + '.png')
string += '\nTerminal=false'
string += '\nCategories=' + ';'.join(info.categories)
if info.file_filter_mime:
    string += '\nMimeType=' + info.file_filter_mime + ';'
string += '\nType=Application'
desktop_file.write(string)
desktop_file.close()