From 5ee1c6df306ca5542e9d80def83510ffd7cf6525 Mon Sep 17 00:00:00 2001 From: Swapnil Devesh Date: Tue, 5 Mar 2024 22:38:56 +0530 Subject: [PATCH] ui: fix app name casing in UI * Fix app name casing in UI * Linter fixes * Only use NAME variable * FIx linter errors --- lib/solaar/__init__.py | 2 +- lib/solaar/cli/__init__.py | 4 ++-- lib/solaar/cli/show.py | 2 +- lib/solaar/gtk.py | 2 +- lib/solaar/ui/notify.py | 8 ++++---- lib/solaar/ui/tray.py | 4 ++-- 6 files changed, 11 insertions(+), 11 deletions(-) diff --git a/lib/solaar/__init__.py b/lib/solaar/__init__.py index 11d0e3c9..5b26a152 100644 --- a/lib/solaar/__init__.py +++ b/lib/solaar/__init__.py @@ -18,7 +18,7 @@ import pkgutil as _pkgutil import subprocess as _subprocess import sys as _sys -NAME = "solaar" +NAME = "Solaar" try: __version__ = ( diff --git a/lib/solaar/cli/__init__.py b/lib/solaar/cli/__init__.py index 01f2b13b..5bb93fe3 100644 --- a/lib/solaar/cli/__init__.py +++ b/lib/solaar/cli/__init__.py @@ -117,7 +117,7 @@ def _receivers(dev_path=None): yield r except Exception as e: logger.exception("opening " + str(dev_info)) - _sys.exit("%s: error: %s" % (NAME, str(e))) + _sys.exit("%s: error: %s" % (NAME.lower(), str(e))) def _receivers_and_devices(dev_path=None): @@ -136,7 +136,7 @@ def _receivers_and_devices(dev_path=None): yield d except Exception as e: logger.exception("opening " + str(dev_info)) - _sys.exit("%s: error: %s" % (NAME, str(e))) + _sys.exit("%s: error: %s" % (NAME.lower(), str(e))) def _find_receiver(receivers, name): diff --git a/lib/solaar/cli/show.py b/lib/solaar/cli/show.py index 1ea33b2e..2837aa53 100644 --- a/lib/solaar/cli/show.py +++ b/lib/solaar/cli/show.py @@ -295,7 +295,7 @@ def run(devices, args, find_receiver, find_device): assert devices assert args.device - print("%s version %s" % (NAME, __version__)) + print("%s version %s" % (NAME.lower(), __version__)) print("") device_name = args.device.lower() diff --git a/lib/solaar/gtk.py b/lib/solaar/gtk.py index 8d0c0c21..b4cb7202 100755 --- a/lib/solaar/gtk.py +++ b/lib/solaar/gtk.py @@ -51,7 +51,7 @@ def _require(module, os_package, gi=None, gi_package=None, gi_version=None): gi.require_version(gi_package, gi_version) return importlib.import_module(module) except (ImportError, ValueError): - sys.exit("%s: missing required system package %s" % (NAME, os_package)) + sys.exit("%s: missing required system package %s" % (NAME.lower(), os_package)) battery_icons_style = "regular" diff --git a/lib/solaar/ui/notify.py b/lib/solaar/ui/notify.py index e05af856..fd41842e 100644 --- a/lib/solaar/ui/notify.py +++ b/lib/solaar/ui/notify.py @@ -55,7 +55,7 @@ if available: if logger.isEnabledFor(logging.INFO): logger.info("starting desktop notifications") try: - return Notify.init(NAME) + return Notify.init(NAME.lower()) except Exception: logger.exception("initializing desktop notifications") available = False @@ -80,15 +80,15 @@ if available: assert reason if available and Notify.is_initted(): - n = _notifications.get(NAME) + n = _notifications.get(NAME.lower()) if n is None: - n = _notifications[NAME] = Notify.Notification() + n = _notifications[NAME.lower()] = Notify.Notification() # we need to use the filename here because the notifications daemon # is an external application that does not know about our icon sets icon_file = _icons.icon_file(NAME.lower()) if icon is None else _icons.icon_file(icon) - n.update(NAME, reason, icon_file) + n.update(NAME.lower(), reason, icon_file) n.set_urgency(Notify.Urgency.NORMAL) n.set_hint("desktop-entry", GLib.Variant("s", NAME.lower())) diff --git a/lib/solaar/ui/tray.py b/lib/solaar/ui/tray.py index 7c682c60..81d3a02c 100644 --- a/lib/solaar/ui/tray.py +++ b/lib/solaar/ui/tray.py @@ -182,7 +182,7 @@ try: ind.set_title(NAME) ind.set_status(AppIndicator3.IndicatorStatus.ACTIVE) # ind.set_attention_icon_full(_icon_file(_icons.TRAY_ATTENTION), '') # works poorly for XFCE 16 - # ind.set_label(NAME, NAME) + # ind.set_label(NAME.lower(), NAME.lower()) ind.set_menu(menu) ind.connect("scroll-event", _scroll) @@ -231,7 +231,7 @@ except ImportError: def _create(menu): icon = Gtk.StatusIcon.new_from_icon_name(_icons.TRAY_INIT) - icon.set_name(NAME) + icon.set_name(NAME.lower()) icon.set_title(NAME) icon.set_tooltip_text(NAME) icon.connect("activate", _window_toggle)