From 5731728a414ae3cf7e0dc8eac0da6588a855e41a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Szyma=C5=84ski?= Date: Sun, 19 May 2019 19:46:54 +0200 Subject: [PATCH] Create desktop icon --- WoeUSB/data/{icon.png => icon.ico} | Bin WoeUSB/gui.py | 4 +- doc/conf.py | 2 +- miscellaneous/WoeUSB-ng.desktop | 7 +++ .../com.github.woeusb.woeusb-ng.policy | 18 +++++++ setup.py | 45 +++++++++++++----- 6 files changed, 62 insertions(+), 14 deletions(-) rename WoeUSB/data/{icon.png => icon.ico} (100%) create mode 100755 miscellaneous/WoeUSB-ng.desktop rename {polkit => miscellaneous}/com.github.woeusb.woeusb-ng.policy (59%) diff --git a/WoeUSB/data/icon.png b/WoeUSB/data/icon.ico similarity index 100% rename from WoeUSB/data/icon.png rename to WoeUSB/data/icon.ico diff --git a/WoeUSB/gui.py b/WoeUSB/gui.py index 095f5bf..a485509 100644 --- a/WoeUSB/gui.py +++ b/WoeUSB/gui.py @@ -30,7 +30,7 @@ class MainFrame(wx.Frame): def __init__(self, title, pos, size, style=wx.DEFAULT_FRAME_STYLE): super(MainFrame, self).__init__(None, -1, title, pos, size, style) - self.SetIcon(wx.Icon(data_directory + "icon.png")) + self.SetIcon(wx.Icon(data_directory + "icon.ico")) file_menu = wx.Menu() self.__menuItemShowAll = wx.MenuItem(file_menu, wx.ID_ANY, _("Show all drives") + " \tCtrl+A", @@ -289,7 +289,7 @@ class DialogAbout(wx.Dialog): sizer_all = wx.BoxSizer(wx.VERTICAL) sizer_img = wx.BoxSizer(wx.HORIZONTAL) - img = wx.Image(data_directory + "icon.png", wx.BITMAP_TYPE_PNG) + img = wx.Image(data_directory + "icon.ico", wx.BITMAP_TYPE_PNG) self.__bitmapIcone = wx.StaticBitmap(self, wx.ID_ANY, wx.Bitmap(img), wx.DefaultPosition, wx.Size(48, 48)) sizer_img.Add(self.__bitmapIcone, 0, wx.ALL, 5) diff --git a/doc/conf.py b/doc/conf.py index 891f471..9760f1d 100644 --- a/doc/conf.py +++ b/doc/conf.py @@ -165,4 +165,4 @@ texinfo_documents = [ todo_include_todos = True html_logo = "../src/data/woeusb-logo.png" -html_favicon = "../src/data/icon.png" \ No newline at end of file +html_favicon = "../src/data/icon.ico" \ No newline at end of file diff --git a/miscellaneous/WoeUSB-ng.desktop b/miscellaneous/WoeUSB-ng.desktop new file mode 100755 index 0000000..72b884e --- /dev/null +++ b/miscellaneous/WoeUSB-ng.desktop @@ -0,0 +1,7 @@ +#!/usr/bin/env xdg-open +[Desktop Entry] +Name=WoeUSB-ng +Exec=/usr/bin/woeusbgui +Icon=/usr/share/icons/WoeUSB-ng/icon.ico +Terminal=false +Type=Application diff --git a/polkit/com.github.woeusb.woeusb-ng.policy b/miscellaneous/com.github.woeusb.woeusb-ng.policy similarity index 59% rename from polkit/com.github.woeusb.woeusb-ng.policy rename to miscellaneous/com.github.woeusb.woeusb-ng.policy index 7ce0c82..cee50ce 100644 --- a/polkit/com.github.woeusb.woeusb-ng.policy +++ b/miscellaneous/com.github.woeusb.woeusb-ng.policy @@ -23,4 +23,22 @@ DOC: https://www.freedesktop.org/software/polkit/docs/latest/polkit.8.html /usr/bin/woeusbgui true + + Run `woeusb` as SuperUser + 以超級使用者(SuperUser)身份執行 `woeusb` + Uruchom `woeusb` jako root + + Authentication is required to run `woeusb` as SuperUser. + 以超級使用者(SuperUser)身份執行 `woeusb` 需要通過身份驗證。 + Wymagana jest autoryzacja do uruchomienia `woeusb` jako root + + + auth_admin + auth_admin + auth_admin_keep + + + /usr/local/bin/woeusbgui + true + \ No newline at end of file diff --git a/setup.py b/setup.py index 68ad370..858dad1 100644 --- a/setup.py +++ b/setup.py @@ -2,9 +2,11 @@ from setuptools import setup from setuptools.command.develop import develop from setuptools.command.install import install from xml.dom.minidom import parse +import configparser import shutil import os + this_directory = os.path.abspath(os.path.dirname(__file__)) with open(os.path.join(this_directory, 'README.md'), encoding='utf-8') as f: @@ -23,19 +25,40 @@ class PostInstallCommand(install): """Post-installation for installation mode.""" def run(self): - path = shutil.which('woeusbgui') + path = shutil.which('woeusbgui') # I have no clue how to find were pip puts exec's + if path is None: + path = 'usr/local/bin/woeusbgui' + else: + dom = parse(this_directory + '/miscellaneous/com.github.woeusb.woeusb-ng.policy') + for action in dom.getElementsByTagName('action'): + if action.getAttribute('id') == "com.github.slacka.woeusb.run-gui-using-pkexec": + for annotate in action.getElementsByTagName('annotate'): + if annotate.getAttribute('key') == "org.freedesktop.policykit.exec.path": + annotate.childNodes[0].nodeValue = path - dom = parse(this_directory + '/polkit/com.github.woeusb.woeusb-ng.policy') - for action in dom.getElementsByTagName('action'): - if action.getAttribute('id') == "com.github.slacka.woeusb.run-gui-using-pkexec": - for annotate in action.getElementsByTagName('annotate'): - if annotate.getAttribute('key') == "org.freedesktop.policykit.exec.path": - annotate.childNodes[0].nodeValue = path + with open(this_directory + '/miscellaneous/com.github.woeusb.woeusb-ng.policy', "w") as file: + dom.writexml(file) - with open(this_directory + '/polkit/com.github.woeusb.woeusb-ng.policy', "w") as file: - dom.writexml(file) + shutil.copy2(this_directory + '/miscellaneous/com.github.woeusb.woeusb-ng.policy', "/usr/share/polkit-1/actions") + + try: + os.makedirs('/usr/share/icons/WoeUSB-ng') + except FileExistsError: + pass + + shutil.copy2(this_directory + '/WoeUSB/data/icon.ico', '/usr/share/icons/WoeUSB-ng/icon.ico') + + desktop = configparser.ConfigParser() + desktop.read(this_directory + '/miscellaneous/WoeUSB-ng.desktop') + desktop.set('Desktop Entry', 'value', path) + with open(this_directory + '/miscellaneous/WoeUSB-ng.desktop', "w") as file: + desktop.write(file) + + shutil.copy2( + this_directory + '/miscellaneous/WoeUSB-ng.desktop', + '/home/' + os.environ['SUDO_USER'] + '/.local/share/applications' + ) - shutil.copy2(this_directory + '/polkit/com.github.woeusb.woeusb-ng.policy', "/usr/share/polkit-1/actions") install.run(self) @@ -58,7 +81,7 @@ setup( ], install_requires=[ 'termcolor', - 'wxPython' + 'wxPython', ], cmdclass={ 'develop': PostDevelopCommand,