Repository: pwr-Solaar/Solaar

Issue:
Status icon could be conflated with that of system power.
Currently, Solaar appears to use the some generic battery icon as is used by the systems default power indicator. I'd suggest switching to the gpm/xfpm-mouse-\* icons in stead, to avoid conflating the two. I realise of course that solaar caters to keyboards and other devices besides mouses/mice_, but I would imagine that there are a hell of a lot more wireless logitech mouses/mice_ out there than keyboards, etc. Besides, gpm/xfpm-mouse-\* looks a damn sight better than gpm/xfpm-keyboard-\* (at least with respect to Ubuntu's default icon theme).

*For the love of atheismo, which is it?! ;-)

P.S.: Thank you for taking the time to develop this. This is one functionality that I have sorely missed since switching to linux some years ago. It's long overdue.



Discussion:
Yeah, more specific icons would be nice. Right now Solaar tries to detect what icon sets are available, because it tries to integrate as much as possible into the user's icon theme. The biggest problem has been finding a consistent way to pick the appropriate icon for each battery level, as each icon set appears to like having its own naming scheme :).

Given the complexity of this, i will be happy if i can choose to show the just sollar icon. I can click or hover on it and get the battery status.

Agreed - the battery icon is mildly confusing, as it's identical to the one used for the laptop battery, at least on Mint 15 XFCE.

I would propose using the Solaar logo instead, optionally lighting up or dimming the six bars to indicate the lowest battery level of all connected devices.

It is, of course, a minor thing; and I'm thankful to you for providing this excellent bit of software. Great work!

Hi!

The possibility not to show the icon (as it can be unneeded) should be provided.
Thanks again for this nice piece of software!
KDB

@KillerdeBug What prevents you from closing Solaar if you do not want to see it at all?

@Lekensteyn will the setting (smooth scrolling, sensitivity, side scrolling) be used if I don't launch Solaar on startup? 
Closing Solaar after every boot is... boring :)

@KillerdeBug Such settings are not retained, but have a look at the command line options (`solaar config -h`).

Ok, I will create a command that is launched as my system start with solaar-cli config...

Note the limitations: if your device is not activated before the CLI command is started, then changes are not applied. If a device is hotplugged, changes will also not apply automatically.

This definitely prove that an option for a silent launch (without systray icon) would be useful... 

@KillerdeBug See PR #161.

perfect thanks !

I thought Solaar wasn't working. It would start and then go away.
Then I realized I had two battery icons in my system tray. Sure enough, one of them is Solaar.
I though this was a bug, but I guess it is on purpose?

My two cents:
I would be happiest to just see the pretty Solaar icon instead of the second battery. The icon doesn't need to do anything fancy other than just reassure me that Solaar is running and give me a place to click to change settings.
I do want the icon though. If it was hidden I'd worry it had quit.
If there is such a problem with solaar when auto/smart picking the icon according to the current theme, then please give us an option to pick our own icons for the tray. Have some list of built-in icons that we can choose from.
This issue is likely to become worse as the scheme to pick the "best" icons is being removed because it was causing problems in dark themes.

Resolving patch:
diff --git a/lib/solaar/gtk.py b/lib/solaar/gtk.py
--- a/lib/solaar/gtk.py
+++ b/lib/solaar/gtk.py
@@ -40,6 +40,7 @@ def _require(module, os_package, gi=None, gi_package=None, gi_version=None):
 		import sys
 		sys.exit("%s: missing required system package %s" % (NAME, os_package))
 
+prefer_symbolic_battery_icons = False
 
 def _parse_arguments():
 	import argparse
@@ -51,6 +52,7 @@ def _parse_arguments():
 	arg_parser.add_argument('--restart-on-wake-up', action='store_true',
 							help='restart Solaar on sleep wake-up (experimental)')
 	arg_parser.add_argument('-w', '--window', choices=('show','hide','only'), help='start with window showing / hidden / only (no tray icon)')
+	arg_parser.add_argument('-b', '--battery-icons', choices=('regular','symbolic'), help='prefer regular / symbolic icons')
 	arg_parser.add_argument('-V', '--version', action='version', version='%(prog)s ' + __version__)
 	arg_parser.add_argument('--help-actions', action='store_true',
 							help='print help for the optional actions')
@@ -66,6 +68,9 @@ def _parse_arguments():
 	if args.window is None:
 		args.window = 'show' # default behaviour is to show main window
 
+	global prefer_symbolic_battery_icons
+	prefer_symbolic_battery_icons = True if args.battery_icons == 'symbolic' else False
+
 	import logging
 	if args.debug > 0:
 		log_level = logging.WARNING - 10 * args.debug
diff --git a/lib/solaar/ui/icons.py b/lib/solaar/ui/icons.py
--- a/lib/solaar/ui/icons.py
+++ b/lib/solaar/ui/icons.py
@@ -24,6 +24,7 @@
 del getLogger
 
 from gi.repository import Gtk
+import solaar.gtk as gtk
 
 #
 #
@@ -73,6 +74,7 @@ def _look_for_application_icons():
 
 
 _default_theme = None
+_use_symbolic_icons = False
 
 def _init_icon_paths():
 	global _default_theme
@@ -85,6 +87,13 @@ def _init_icon_paths():
 	if _log.isEnabledFor(_DEBUG):
 		_log.debug("icon theme paths: %s", _default_theme.get_search_path())
 
+	if gtk.prefer_symbolic_battery_icons:
+		if _default_theme.has_icon('battery-good-symbolic'):
+			global _use_symbolic_icons
+			_use_symbolic_icons = True
+			return
+		else:
+			_log.warning("failed to detect symbolic icons")
 	if not _default_theme.has_icon('battery-good'):
 		_log.warning("failed to detect icons")
 
@@ -110,10 +119,10 @@ def _battery_icon_name(level, charging):
 	_init_icon_paths()
 
 	if level is None or level < 0:
-		return 'battery-missing'
+		return 'battery-missing' + ( '-symbolic' if _use_symbolic_icons else '' )
 
 	level_name = _first_res(level,((90,'full'), (50,'good'), (20,'low'), (5,'caution'), (0,'empty')))
-	return 'battery-%s%s' % (level_name, '-charging' if charging else '')
+	return 'battery-%s%s%s' % (level_name, '-charging' if charging else '', '-symbolic' if _use_symbolic_icons else '')
 
 #
 #
diff --git a/lib/solaar/ui/tray.py b/lib/solaar/ui/tray.py
--- a/lib/solaar/ui/tray.py
+++ b/lib/solaar/ui/tray.py
@@ -203,9 +203,6 @@ def _update_tray_icon():
 			battery_charging = device_status.get(_K.BATTERY_CHARGING)
 			tray_icon_name = _icons.battery(battery_level, battery_charging)
 
-			# get around system tray icons not having styling and not having css class
-			tray_icon_name = tray_icon_name + ( "-symbolic" if "SOLAAR_TRAY_BATTERY_ICON_SYBOLIC" in os.environ else "" )
-
 			description =  '%s: %s' % (name, device_status.to_string())
 		else:
 			# there may be a receiver, but no peripherals
@@ -263,9 +260,6 @@ def _update_tray_icon():
 			battery_level = device_status.get(_K.BATTERY_LEVEL)
 			battery_charging = device_status.get(_K.BATTERY_CHARGING)
 			tray_icon_name = _icons.battery(battery_level, battery_charging)
-
-			# get around system tray icons not having styling and not having css class
-			tray_icon_name = tray_icon_name + ( "-symbolic" if "SOLAAR_TRAY_BATTERY_ICON_SYBOLIC" in os.environ else "" )
 		else:
 			# there may be a receiver, but no peripherals
 			tray_icon_name = _icons.TRAY_OKAY if _devices_info else _icons.TRAY_ATTENTION


Test patch: