From c29ae3aa2f598e457435f60915efef552f06a140 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hakan=20D=C3=BCndar?= Date: Sat, 9 Apr 2022 15:33:56 +0300 Subject: [PATCH] Minor improvements --- Changes.md | 2 +- integration/system-monitoring-center | 5 +++++ setup.py | 25 +++++++++++++------------ src/MainGUI.py | 24 ++++++++++++++++-------- src/__version__ | 2 +- 5 files changed, 36 insertions(+), 22 deletions(-) create mode 100755 integration/system-monitoring-center diff --git a/Changes.md b/Changes.md index 1360149a..36966f92 100755 --- a/Changes.md +++ b/Changes.md @@ -1,6 +1,6 @@ # System Monitoring Center -### v1.10.1 +### v1.10.2 * Improved: Getting ARM CPU model names * Improved: Device vendor-model detection * Fix: Detect window manager of GNOME DE diff --git a/integration/system-monitoring-center b/integration/system-monitoring-center new file mode 100755 index 00000000..033fb840 --- /dev/null +++ b/integration/system-monitoring-center @@ -0,0 +1,5 @@ +#!/usr/bin/env python3 + +import sys +sys.path.insert(0, '/usr/share/system-monitoring-center/src/') +import Main diff --git a/setup.py b/setup.py index 56c41b4f..b03da834 100755 --- a/setup.py +++ b/setup.py @@ -15,16 +15,18 @@ def files_in_folder(folder): data_files = [ - ("/systemmonitoringcenter/applications/", ["integration/com.github.hakand34.system-monitoring-center.desktop"]), - ("/systemmonitoringcenter/locale/cs/LC_MESSAGES/", ["locale/cs/system-monitoring-center.mo"]), - ("/systemmonitoringcenter/locale/pl/LC_MESSAGES/", ["locale/pl/system-monitoring-center.mo"]), - ("/systemmonitoringcenter/locale/pt_BR/LC_MESSAGES/", ["locale/pt_BR/system-monitoring-center.mo"]), - ("/systemmonitoringcenter/locale/tr/LC_MESSAGES/", ["locale/tr/system-monitoring-center.mo"]), - ("/systemmonitoringcenter/database/", files_in_folder("database/")), - ("/systemmonitoringcenter/src/", files_in_folder("src/")), - ("/systemmonitoringcenter/ui/", files_in_folder("ui/")), - ("/systemmonitoringcenter/icons/hicolor/scalable/actions/", files_in_folder("icons/hicolor/scalable/actions/")), - ("/systemmonitoringcenter/icons/hicolor/scalable/apps/", ["icons/hicolor/scalable/apps/system-monitoring-center.svg"]), + ("/usr/share/applications/", ["integration/com.github.hakand34.system-monitoring-center.desktop"]), + ("/usr/share/system-monitoring-center/locale/cs/LC_MESSAGES/", ["locale/cs/system-monitoring-center.mo"]), + ("/usr/share/system-monitoring-center/locale/pl/LC_MESSAGES/", ["locale/pl/system-monitoring-center.mo"]), + ("/usr/share/system-monitoring-center/locale/pt_BR/LC_MESSAGES/", ["locale/pt_BR/system-monitoring-center.mo"]), + ("/usr/share/system-monitoring-center/locale/tr/LC_MESSAGES/", ["locale/tr/system-monitoring-center.mo"]), + ("/usr/share/system-monitoring-center/database/", files_in_folder("database/")), + ("/usr/share/system-monitoring-center/src/", files_in_folder("src/")), + ("/usr/share/system-monitoring-center/ui/", files_in_folder("ui/")), + ("/usr/share/icons/hicolor/scalable/actions/", files_in_folder("icons/hicolor/scalable/actions/")), + ("/usr/share/icons/hicolor/scalable/apps/", ["icons/hicolor/scalable/apps/system-monitoring-center.svg"]), + ("/usr/share/man/man1/", ["man/system-monitoring-center.1.gz"]), + ("/usr/bin/", ["integration/system-monitoring-center"]) ] @@ -38,11 +40,10 @@ def files_in_folder(folder): url="https://github.com/hakandundar34coding/system-monitoring-center", keywords="system monitor task manager center performance speed frequency usage cpu ram swap memory storage network download fps ratio processes users startup services os", license="GPLv3", - install_requires=["PyGObject", "pycairo"], + install_requires=["PyGObject"], python_requires=">=3.6", packages=find_packages(), data_files=data_files, - entry_points={"gui_scripts": ["system-monitoring-center = systemmonitoringcenter.start:start_app"]}, classifiers=[ "Programming Language :: Python :: 3 :: Only", "Programming Language :: Python :: 3", diff --git a/src/MainGUI.py b/src/MainGUI.py index e0213396..4cda7f8c 100755 --- a/src/MainGUI.py +++ b/src/MainGUI.py @@ -482,13 +482,15 @@ def main_gui_application_system_integration_func(self): current_dir = os.path.dirname(os.path.realpath(__file__)) current_user_homedir = os.environ.get('HOME') - # Prevent running this function if the application code is in "/usr/lib/" folder which means the application is a Python application and packaged for a distribution package manager and it has a desktop file after installation. - if current_dir.startswith("/usr/lib/") == True: - return - # This file is used for checking if symlinks are copied before. file_to_check_if_generated = current_user_homedir + "/.local/share/applications/com.github.hakand34.system-monitoring-center.desktop" + # Get icon list. + try: + icon_list = os.listdir(current_dir + "/../icons/hicolor/scalable/actions") + except FileNotFoundError: + icon_list = os.listdir("/usr/share/icons/hicolor/scalable/actions") + # Called for removing files. def remove_file(file): try: @@ -521,20 +523,26 @@ def generate_symlink(source, target): remove_file(current_user_homedir + "/.local/share/applications/com.github.hakand34.system-monitoring-center.desktop") remove_file(current_user_homedir + "/.local/share/icons/hicolor/scalable/apps/system-monitoring-center.svg") for file in os.listdir(current_user_homedir + "/.local/share/icons/hicolor/scalable/actions"): - remove_file(file) + if file in icon_list: + remove_file(file) # Check if symlinks are not copied before. - if os.path.isfile(file_to_check_if_generated) == False: + else: # Try to remove previous symlinks ("isfile" check gives "False" if there are symlinks and targets are removed. Example cases: If the application is removed from user-specific directory and installed into system-wide directory or vice versa.). remove_file(current_user_homedir + "/.local/share/applications/com.github.hakand34.system-monitoring-center.desktop") remove_file(current_user_homedir + "/.local/share/icons/hicolor/scalable/apps/system-monitoring-center.svg") try: for file in os.listdir(current_user_homedir + "/.local/share/icons/hicolor/scalable/actions"): - remove_file(current_user_homedir + "/.local/share/icons/hicolor/scalable/actions/" + file) + if file in icon_list: + remove_file(current_user_homedir + "/.local/share/icons/hicolor/scalable/actions/" + file) except Exception: pass + # Prevent running rest of this function if the application code is in "/usr/lib/" folder which means the application is a Python application and packaged for a distribution package manager and it has a desktop file after installation. + if current_dir.startswith("/usr/lib/") == True or current_dir.startswith("/usr/share/") == True: + return + # Generate folders. generate_folder(current_user_homedir + "/.local/share/applications") generate_folder(current_user_homedir + "/.local/share/icons/hicolor/scalable/apps") @@ -544,7 +552,7 @@ def generate_symlink(source, target): generate_symlink(current_dir + "/../applications/com.github.hakand34.system-monitoring-center.desktop", current_user_homedir + "/.local/share/applications/com.github.hakand34.system-monitoring-center.desktop") generate_symlink(current_dir + "/../icons/hicolor/scalable/apps/system-monitoring-center.svg", current_user_homedir + "/.local/share/icons/hicolor/scalable/apps/system-monitoring-center.svg") target_path = current_user_homedir + "/.local/share/icons/hicolor/scalable/actions" - for file in os.listdir(current_dir + "/../icons/hicolor/scalable/actions"): + for file in icon_list: generate_symlink(current_dir + "/../icons/hicolor/scalable/actions/" + file, target_path + "/" + file) diff --git a/src/__version__ b/src/__version__ index 4dae2985..5ad2491c 100644 --- a/src/__version__ +++ b/src/__version__ @@ -1 +1 @@ -1.10.1 +1.10.2