Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • S Solaar
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 10
    • Issues 10
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 2
    • Merge requests 2
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • pwr-Solaar
  • Solaar
  • Merge requests
  • !1141

Prefer symbolic battery icons on GNOME

  • Review changes

  • Download
  • Email patches
  • Plain diff
Closed Administrator requested to merge github/fork/elsiehupp/prefer-symbolic-icons-on-gnome into master Apr 11, 2021
  • Overview 0
  • Commits 1
  • Pipelines 0
  • Changes 1

Created by: elsiehupp

Fixes https://github.com/pwr-Solaar/Solaar/issues/1130.

I was trying to diagnose the above Issue based on the maintainer’s assertion that it was down to the indicator plugin, so I took the following steps.

I added the following to icons.py:

import sys
...
print('gtk.battery_icons_style returns', file=sys.stdout)
print(gtk.battery_icons_style, file=sys.stdout)
print('_default_theme.has_icon(\'battery-good-symbolic\') returns', file=sys.stdout)
print(_default_theme.has_icon('battery-good-symbolic'), file=sys.stdout)

and got the following output:

gtk.battery_icons_style returns
regular
_default_theme.has_icon('battery-good-symbolic') returns
True

As far as I can tell, the only place gtk.battery_icons_style is set is from the command line arguments, with the following line in gtk.py: https://github.com/pwr-Solaar/Solaar/blob/69df28c15595363589c81fb0028bb140c9102057/lib/solaar/gtk.py#L99

In other words, Solaar does not actually check with the environment to see if the shell prefers symbolic icons. My guess is that this is based on a misunderstanding of how icon themes work (at least in GNOME): icon themes contain both symbolic and hicolor icons, with no preference either way, and it is up to application developers to choose.

If the preceding line were changed to:

battery_icons_style = args.battery_icons if args.battery_icons is not None

and the following lines in icons.py were changed from: https://github.com/pwr-Solaar/Solaar/blob/69df28c15595363589c81fb0028bb140c9102057/lib/solaar/ui/icons.py#L95-L102 to:

if gtk.battery_icons_style is None:
    if _default_theme.has_icon('battery-good-symbolic'):
        _log.warning('detected symbolic icons')
        gtk.battery_icons_style = ’symbolic’
    elif _default_theme.has_icon('battery-good'):
        _log.warning('detected hicolor icons')
        gtk.battery_icons_style = ’regular’
    else:
        _log.warning('failed to detect icons')
        gtk.battery_icons_style = 'none'

then Solaar would choose the icon theme based on whether it contains the necessary symbolic icons. (i.e. Solaar would prefer symbolic icons by default.)

I looked at gtk.IconTheme, and it does not have any members indicating whether to prefer symbolic icons, aside from the ability to search to icons with the suffix -symbolic.

Regardless of what indicator plugin an end user is using, gtk.IconTheme is the API that Solaar itself uses to detect icon themes.

In enum Gtk::IconLookupFlags, I do see the following:

Used to specify options for Gtk::IconTheme::lookup_icon() FORCE_REGULAR | Try to always load regular icons, even when symbolic icon names are given. FORCE_SYMBOLIC | Try to always load symbolic icons, even when regular icon names are given.

But this flag is provided by the application, not the icon theme.

ubuntu/gnome-shell-extension-appindicator does not contain any code for detecting a preference for symbolic icons.

AyatanaIndicators/libayatana-indicator does not contain the string "symbolic" anywhere in its code, period.

I searched several Ayatana applets, and the only one I found with any reference to symbolic icons was AyatanaIndicators/ayatana-indicator-power

Looking at ayatana-indicator-power, we see the following:

EXPECT_ICON_NAMES_EQ("ac-adapter-symbolic;"
                       "ac-adapter",
                       device);

which is based on the function:

#define EXPECT_ICON_NAMES_EQ(expected_in,device_in)                          \
  do {                                                                       \
    const std::string tmp_expected {expected_in};                            \
    const std::string tmp_actual {get_icon_names_from_device(device_in)};    \
    EXPECT_EQ(tmp_expected, tmp_actual);                                     \
  } while(0)

It appears that the applet lists a preference for the symbolic icon, then falls back to the hicolor icon (though the syntax of the function definition is a bit opaque to me).

Anyway!

In deference to desktop shells other than GNOME, instead of defaulting to symbolic across the board, the code in this pull request defaults to symbolic only if $XDG_CURRENT_DESKTOP equals GNOME. (I used in rather than equality because subprocess.run().stdout includes newlines and other gobbledygook.) I have tested this code, and it functions as intended on my computer.

I would be happy to modify this pull request to default to symbolic icons across the board, if the maintainers so prefer, or I could add different shell-specific defaults. It would probably also be desirable to put an explanation of this behavior in the documentation, so I can add that, too.

Assignee
Assign to
Reviewers
Request review from
Time tracking
Source branch: github/fork/elsiehupp/prefer-symbolic-icons-on-gnome