From 3bf1d82ec776e852af16bdcf95f9fb97441f1edf Mon Sep 17 00:00:00 2001 From: Joey Payne Date: Wed, 6 May 2015 23:12:15 -0600 Subject: [PATCH] Added preliminary .desktop file generation for linux exports. --- command_line.py | 36 ++++++++++++++++++++++++++++++++++++ main.py | 2 +- 2 files changed, 37 insertions(+), 1 deletion(-) diff --git a/command_line.py b/command_line.py index 320bc03..03735c5 100644 --- a/command_line.py +++ b/command_line.py @@ -698,6 +698,8 @@ class CommandBase(object): dest_binary_path = os.path.join(export_dest, self.project_name() + ext) + if 'linux' in ex_setting.name: + self.make_desktop_file(dest_binary_path, export_dest) join_files(dest_binary_path, nw_path, zip_file) @@ -722,6 +724,40 @@ class CommandBase(object): finally: shutil.rmtree(temp_dir) + def make_desktop_file(self, nw_path, export_dest): + icon_set = self.get_setting('icon') + icon_path = os.path.join(self.project_dir(), icon_set.value) + if os.path.exists(icon_path): + shutil.copy(icon_path, export_dest) + icon_path = os.path.join(export_dest, os.path.basename(icon_path)) + else: + icon_path = '' + name = self.project_name() + pdir = self.project_dir() + version = self.get_setting('version') + desc = self.get_setting('description') + dfile_path = os.path.join(export_dest, name+'.desktop') + file_str = ( + '[Desktop Entry]\n' + 'Version={}\n' + 'Name={}\n' + 'Comment={}\n' + 'Exec={}\n' + 'Icon={}\n' + 'Terminal=false\n' + 'Type=Application\n' + 'Categories=Utility;Application;\n' + ) + file_str = file_str.format(version.value, + name, + desc.value, + nw_path, + icon_path) + with open(dfile_path, 'w+') as f: + f.write(file_str) + + os.chmod(dfile_path, 0755) + def compress_nw(self, nw_path): compression = self.get_setting('nw_compression_level') if compression.value == 0: diff --git a/main.py b/main.py index 52f2028..aec4117 100644 --- a/main.py +++ b/main.py @@ -1,6 +1,6 @@ from utils import log, open_folder_in_explorer -__gui_version__ = "v0.2.2b" +__gui_version__ = "v0.2.3b" import os import re