We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Option monochrome indicator or autostart enable / disable
Hello and good day,

first and foremost thank you very much for this wonderful application.

As a GNOME Shell user I would like to see a monochrome indicator icon or alternatively an option to disable the autostart feature.

![grafik](https://user-images.githubusercontent.com/6410852/149958194-8d840366-7689-4ed8-b1bb-b8ba8a98a1f2.png)

Currently it's the only coloured icon in my bar and it really does not blend well. I would therefore either prefer a monochrome icon or an option to hide it.

Thank you for reading and all the best

--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `lib/solaar/ui/icons.py`
Content:
```
1 # -*- python-mode -*-
2 
3 ## Copyright (C) 2012-2013  Daniel Pavel
4 ##
5 ## This program is free software; you can redistribute it and/or modify
6 ## it under the terms of the GNU General Public License as published by
7 ## the Free Software Foundation; either version 2 of the License, or
8 ## (at your option) any later version.
9 ##
10 ## This program is distributed in the hope that it will be useful,
11 ## but WITHOUT ANY WARRANTY; without even the implied warranty of
12 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 ## GNU General Public License for more details.
14 ##
15 ## You should have received a copy of the GNU General Public License along
16 ## with this program; if not, write to the Free Software Foundation, Inc.,
17 ## 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18 
19 from logging import DEBUG as _DEBUG
20 from logging import getLogger
21 
22 import solaar.gtk as gtk
23 
24 from gi.repository import Gtk
25 
26 _log = getLogger(__name__)
27 del getLogger
28 
29 #
30 #
31 #
32 
33 _LARGE_SIZE = 64
34 Gtk.IconSize.LARGE = Gtk.icon_size_register('large', _LARGE_SIZE, _LARGE_SIZE)
35 # Gtk.IconSize.XLARGE = Gtk.icon_size_register('x-large', _LARGE_SIZE * 2, _LARGE_SIZE * 2)
36 # print ("menu", int(Gtk.IconSize.MENU), Gtk.icon_size_lookup(Gtk.IconSize.MENU))
37 # print ("small toolbar", int(Gtk.IconSize.SMALL_TOOLBAR), Gtk.icon_size_lookup(Gtk.IconSize.SMALL_TOOLBAR))
38 # print ("button", int(Gtk.IconSize.BUTTON), Gtk.icon_size_lookup(Gtk.IconSize.BUTTON))
39 # print ("large toolbar", int(Gtk.IconSize.LARGE_TOOLBAR), Gtk.icon_size_lookup(Gtk.IconSize.LARGE_TOOLBAR))
40 # print ("dnd", int(Gtk.IconSize.DND), Gtk.icon_size_lookup(Gtk.IconSize.DND))
41 # print ("dialog", int(Gtk.IconSize.DIALOG), Gtk.icon_size_lookup(Gtk.IconSize.DIALOG))
42 
43 TRAY_INIT = 'solaar-init'
44 TRAY_OKAY = 'solaar'
45 TRAY_ATTENTION = 'solaar-attention'
46 
47 
48 def _look_for_application_icons():
49     import os.path as _path
50     from os import environ as _environ
51 
52     import sys as _sys
53     if _log.isEnabledFor(_DEBUG):
54         _log.debug('sys.path[0] = %s', _sys.path[0])
55     prefix_share = _path.normpath(_path.join(_path.realpath(_sys.path[0]), '..'))
56     src_share = _path.normpath(_path.join(_path.realpath(_sys.path[0]), '..', 'share'))
57     local_share = _environ.get('XDG_DATA_HOME', _path.expanduser(_path.join('~', '.local', 'share')))
58     data_dirs = _environ.get('XDG_DATA_DIRS', '/usr/local/share:/usr/share')
59     repo_share = _path.normpath(_path.join(_path.dirname(__file__), '..', '..', '..', 'share'))
60     setuptools_share = _path.normpath(_path.join(_path.dirname(__file__), '..', '..', 'share'))
61     del _sys
62 
63     share_solaar = [prefix_share] + list(
64         _path.join(x, 'solaar') for x in [src_share, local_share, setuptools_share, repo_share] + data_dirs.split(':')
65     )
66     for location in share_solaar:
67         location = _path.join(location, 'icons')
68         if _log.isEnabledFor(_DEBUG):
69             _log.debug('looking for icons in %s', location)
70 
71         if _path.exists(_path.join(location, TRAY_ATTENTION + '.svg')):
72             yield location
73 
74     del _environ
75     # del _path
76 
77 
78 _default_theme = None
79 
80 
81 def _init_icon_paths():
82     global _default_theme
83     if _default_theme:
84         return
85 
86     _default_theme = Gtk.IconTheme.get_default()
87     for p in _look_for_application_icons():
88         _default_theme.prepend_search_path(p)
89         break  # only prepend one path - that's sufficient
90     if _log.isEnabledFor(_DEBUG):
91         _log.debug('icon theme paths: %s', _default_theme.get_search_path())
92 
93     if gtk.battery_icons_style == 'symbolic':
94         if not _default_theme.has_icon('battery-good-symbolic'):
95             _log.warning('failed to detect symbolic icons')
96             gtk.battery_icons_style = 'regular'
97     if gtk.battery_icons_style == 'regular':
98         if not _default_theme.has_icon('battery-good'):
99             _log.warning('failed to detect icons')
100             gtk.battery_icons_style = 'solaar'
101 
102 
103 #
104 #
105 #
106 
107 
108 def battery(level=None, charging=False):
109     icon_name = _battery_icon_name(level, charging)
110     if not _default_theme.has_icon(icon_name):
111         _log.warning('icon %s not found in current theme', icon_name)
112         return TRAY_OKAY  # use Solaar icon if battery icon not available
113     elif _log.isEnabledFor(_DEBUG):
114         _log.debug('battery icon for %s:%s = %s', level, charging, icon_name)
115     return icon_name
116 
117 
118 # return first res where val >= guard
119 # _first_res(val,((guard,res),...))
120 def _first_res(val, pairs):
121     return next((res for guard, res in pairs if val >= guard), None)
122 
123 
124 def _battery_icon_name(level, charging):
125     _init_icon_paths()
126 
127     if level is None or level < 0:
128         return 'battery-missing' + ('-symbolic' if gtk.battery_icons_style == 'symbolic' else '')
129 
130     level_name = _first_res(level, ((90, 'full'), (30, 'good'), (20, 'low'), (5, 'caution'), (0, 'empty')))
131     return 'battery-%s%s%s' % (
132         level_name, '-charging' if charging else '', '-symbolic' if gtk.battery_icons_style == 'symbolic' else ''
133     )
134 
135 
136 #
137 #
138 #
139 
140 
141 def lux(level=None):
142     if level is None or level < 0:
143         return 'light_unknown'
144     return 'light_%03d' % (20 * ((level + 50) // 100))
145 
146 
147 #
148 #
149 #
150 
151 _ICON_SETS = {}
152 
153 
154 def device_icon_set(name='_', kind=None):
155     icon_set = _ICON_SETS.get(name)
156     if icon_set is None:
157         icon_set = Gtk.IconSet.new()
158         _ICON_SETS[name] = icon_set
159 
160         # names of possible icons, in reverse order of likelihood
161         # the theme will hopefully pick up the most appropriate
162         names = ['preferences-desktop-peripherals']
163         if kind:
164             if str(kind) == 'numpad':
165                 names += ('input-keyboard', 'input-dialpad')
166             elif str(kind) == 'touchpad':
167                 names += ('input-mouse', 'input-tablet')
168             elif str(kind) == 'trackball':
169                 names += ('input-mouse', )
170             elif str(kind) == 'headset':
171                 names += ('audio-headphones', 'audio-headset')
172             names += ('input-' + str(kind), )
173         # names += (name.replace(' ', '-'),)
174 
175         source = Gtk.IconSource.new()
176         for n in names:
177             source.set_icon_name(n)
178             icon_set.add_source(source)
179         icon_set.names = names
180 
181     return icon_set
182 
183 
184 def device_icon_file(name, kind=None, size=_LARGE_SIZE):
185     _init_icon_paths()
186 
187     icon_set = device_icon_set(name, kind)
188     assert icon_set
189     for n in reversed(icon_set.names):
190         if _default_theme.has_icon(n):
191             return _default_theme.lookup_icon(n, size, 0).get_filename()
192 
193 
194 def device_icon_name(name, kind=None):
195     _init_icon_paths()
196 
197     icon_set = device_icon_set(name, kind)
198     assert icon_set
199     for n in reversed(icon_set.names):
200         if _default_theme.has_icon(n):
201             return n
202 
203 
204 def icon_file(name, size=_LARGE_SIZE):
205     _init_icon_paths()
206 
207     # has_icon() somehow returned False while lookup_icon returns non-None.
208     # I guess it happens because share/solaar/icons/ has no hicolor and
209     # resolution subdirs
210     theme_icon = _default_theme.lookup_icon(name, size, 0)
211     if theme_icon:
212         file_name = theme_icon.get_filename()
213         # if _log.isEnabledFor(_DEBUG):
214         #     _log.debug("icon %s(%d) => %s", name, size, file_name)
215         return file_name
216 
217     _log.warn('icon %s(%d) not found in current theme', name, size)
218
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

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
@@ -91,6 +91,8 @@
         _log.debug('icon theme paths: %s', _default_theme.get_search_path())
 
     if gtk.battery_icons_style == 'symbolic':
+        global TRAY_OKAY
+        TRAY_OKAY = TRAY_INIT  # use monochrome tray icon
         if not _default_theme.has_icon('battery-good-symbolic'):
             _log.warning('failed to detect symbolic icons')
             gtk.battery_icons_style = 'regular'

{"golden_diff": "diff --git a/lib/solaar/ui/icons.py b/lib/solaar/ui/icons.py\n--- a/lib/solaar/ui/icons.py\n+++ b/lib/solaar/ui/icons.py\n@@ -91,6 +91,8 @@\n         _log.debug('icon theme paths: %s', _default_theme.get_search_path())\n \n     if gtk.battery_icons_style == 'symbolic':\n+        global TRAY_OKAY\n+        TRAY_OKAY = TRAY_INIT  # use monochrome tray icon\n         if not _default_theme.has_icon('battery-good-symbolic'):\n             _log.warning('failed to detect symbolic icons')\n             gtk.battery_icons_style = 'regular'\n", "issue": "Option monochrome indicator or autostart enable / disable\nHello and good day,\r\n\r\nfirst and foremost thank you very much for this wonderful application.\r\n\r\nAs a GNOME Shell user I would like to see a monochrome indicator icon or alternatively an option to disable the autostart feature.\r\n\r\n![grafik](https://user-images.githubusercontent.com/6410852/149958194-8d840366-7689-4ed8-b1bb-b8ba8a98a1f2.png)\r\n\r\nCurrently it's the only coloured icon in my bar and it really does not blend well. I would therefore either prefer a monochrome icon or an option to hide it.\r\n\r\nThank you for reading and all the best\n", "before_files": [{"content": "# -*- python-mode -*-\n\n## Copyright (C) 2012-2013  Daniel Pavel\n##\n## This program is free software; you can redistribute it and/or modify\n## it under the terms of the GNU General Public License as published by\n## the Free Software Foundation; either version 2 of the License, or\n## (at your option) any later version.\n##\n## This program is distributed in the hope that it will be useful,\n## but WITHOUT ANY WARRANTY; without even the implied warranty of\n## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n## GNU General Public License for more details.\n##\n## You should have received a copy of the GNU General Public License along\n## with this program; if not, write to the Free Software Foundation, Inc.,\n## 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.\n\nfrom logging import DEBUG as _DEBUG\nfrom logging import getLogger\n\nimport solaar.gtk as gtk\n\nfrom gi.repository import Gtk\n\n_log = getLogger(__name__)\ndel getLogger\n\n#\n#\n#\n\n_LARGE_SIZE = 64\nGtk.IconSize.LARGE = Gtk.icon_size_register('large', _LARGE_SIZE, _LARGE_SIZE)\n# Gtk.IconSize.XLARGE = Gtk.icon_size_register('x-large', _LARGE_SIZE * 2, _LARGE_SIZE * 2)\n# print (\"menu\", int(Gtk.IconSize.MENU), Gtk.icon_size_lookup(Gtk.IconSize.MENU))\n# print (\"small toolbar\", int(Gtk.IconSize.SMALL_TOOLBAR), Gtk.icon_size_lookup(Gtk.IconSize.SMALL_TOOLBAR))\n# print (\"button\", int(Gtk.IconSize.BUTTON), Gtk.icon_size_lookup(Gtk.IconSize.BUTTON))\n# print (\"large toolbar\", int(Gtk.IconSize.LARGE_TOOLBAR), Gtk.icon_size_lookup(Gtk.IconSize.LARGE_TOOLBAR))\n# print (\"dnd\", int(Gtk.IconSize.DND), Gtk.icon_size_lookup(Gtk.IconSize.DND))\n# print (\"dialog\", int(Gtk.IconSize.DIALOG), Gtk.icon_size_lookup(Gtk.IconSize.DIALOG))\n\nTRAY_INIT = 'solaar-init'\nTRAY_OKAY = 'solaar'\nTRAY_ATTENTION = 'solaar-attention'\n\n\ndef _look_for_application_icons():\n    import os.path as _path\n    from os import environ as _environ\n\n    import sys as _sys\n    if _log.isEnabledFor(_DEBUG):\n        _log.debug('sys.path[0] = %s', _sys.path[0])\n    prefix_share = _path.normpath(_path.join(_path.realpath(_sys.path[0]), '..'))\n    src_share = _path.normpath(_path.join(_path.realpath(_sys.path[0]), '..', 'share'))\n    local_share = _environ.get('XDG_DATA_HOME', _path.expanduser(_path.join('~', '.local', 'share')))\n    data_dirs = _environ.get('XDG_DATA_DIRS', '/usr/local/share:/usr/share')\n    repo_share = _path.normpath(_path.join(_path.dirname(__file__), '..', '..', '..', 'share'))\n    setuptools_share = _path.normpath(_path.join(_path.dirname(__file__), '..', '..', 'share'))\n    del _sys\n\n    share_solaar = [prefix_share] + list(\n        _path.join(x, 'solaar') for x in [src_share, local_share, setuptools_share, repo_share] + data_dirs.split(':')\n    )\n    for location in share_solaar:\n        location = _path.join(location, 'icons')\n        if _log.isEnabledFor(_DEBUG):\n            _log.debug('looking for icons in %s', location)\n\n        if _path.exists(_path.join(location, TRAY_ATTENTION + '.svg')):\n            yield location\n\n    del _environ\n    # del _path\n\n\n_default_theme = None\n\n\ndef _init_icon_paths():\n    global _default_theme\n    if _default_theme:\n        return\n\n    _default_theme = Gtk.IconTheme.get_default()\n    for p in _look_for_application_icons():\n        _default_theme.prepend_search_path(p)\n        break  # only prepend one path - that's sufficient\n    if _log.isEnabledFor(_DEBUG):\n        _log.debug('icon theme paths: %s', _default_theme.get_search_path())\n\n    if gtk.battery_icons_style == 'symbolic':\n        if not _default_theme.has_icon('battery-good-symbolic'):\n            _log.warning('failed to detect symbolic icons')\n            gtk.battery_icons_style = 'regular'\n    if gtk.battery_icons_style == 'regular':\n        if not _default_theme.has_icon('battery-good'):\n            _log.warning('failed to detect icons')\n            gtk.battery_icons_style = 'solaar'\n\n\n#\n#\n#\n\n\ndef battery(level=None, charging=False):\n    icon_name = _battery_icon_name(level, charging)\n    if not _default_theme.has_icon(icon_name):\n        _log.warning('icon %s not found in current theme', icon_name)\n        return TRAY_OKAY  # use Solaar icon if battery icon not available\n    elif _log.isEnabledFor(_DEBUG):\n        _log.debug('battery icon for %s:%s = %s', level, charging, icon_name)\n    return icon_name\n\n\n# return first res where val >= guard\n# _first_res(val,((guard,res),...))\ndef _first_res(val, pairs):\n    return next((res for guard, res in pairs if val >= guard), None)\n\n\ndef _battery_icon_name(level, charging):\n    _init_icon_paths()\n\n    if level is None or level < 0:\n        return 'battery-missing' + ('-symbolic' if gtk.battery_icons_style == 'symbolic' else '')\n\n    level_name = _first_res(level, ((90, 'full'), (30, 'good'), (20, 'low'), (5, 'caution'), (0, 'empty')))\n    return 'battery-%s%s%s' % (\n        level_name, '-charging' if charging else '', '-symbolic' if gtk.battery_icons_style == 'symbolic' else ''\n    )\n\n\n#\n#\n#\n\n\ndef lux(level=None):\n    if level is None or level < 0:\n        return 'light_unknown'\n    return 'light_%03d' % (20 * ((level + 50) // 100))\n\n\n#\n#\n#\n\n_ICON_SETS = {}\n\n\ndef device_icon_set(name='_', kind=None):\n    icon_set = _ICON_SETS.get(name)\n    if icon_set is None:\n        icon_set = Gtk.IconSet.new()\n        _ICON_SETS[name] = icon_set\n\n        # names of possible icons, in reverse order of likelihood\n        # the theme will hopefully pick up the most appropriate\n        names = ['preferences-desktop-peripherals']\n        if kind:\n            if str(kind) == 'numpad':\n                names += ('input-keyboard', 'input-dialpad')\n            elif str(kind) == 'touchpad':\n                names += ('input-mouse', 'input-tablet')\n            elif str(kind) == 'trackball':\n                names += ('input-mouse', )\n            elif str(kind) == 'headset':\n                names += ('audio-headphones', 'audio-headset')\n            names += ('input-' + str(kind), )\n        # names += (name.replace(' ', '-'),)\n\n        source = Gtk.IconSource.new()\n        for n in names:\n            source.set_icon_name(n)\n            icon_set.add_source(source)\n        icon_set.names = names\n\n    return icon_set\n\n\ndef device_icon_file(name, kind=None, size=_LARGE_SIZE):\n    _init_icon_paths()\n\n    icon_set = device_icon_set(name, kind)\n    assert icon_set\n    for n in reversed(icon_set.names):\n        if _default_theme.has_icon(n):\n            return _default_theme.lookup_icon(n, size, 0).get_filename()\n\n\ndef device_icon_name(name, kind=None):\n    _init_icon_paths()\n\n    icon_set = device_icon_set(name, kind)\n    assert icon_set\n    for n in reversed(icon_set.names):\n        if _default_theme.has_icon(n):\n            return n\n\n\ndef icon_file(name, size=_LARGE_SIZE):\n    _init_icon_paths()\n\n    # has_icon() somehow returned False while lookup_icon returns non-None.\n    # I guess it happens because share/solaar/icons/ has no hicolor and\n    # resolution subdirs\n    theme_icon = _default_theme.lookup_icon(name, size, 0)\n    if theme_icon:\n        file_name = theme_icon.get_filename()\n        # if _log.isEnabledFor(_DEBUG):\n        #     _log.debug(\"icon %s(%d) => %s\", name, size, file_name)\n        return file_name\n\n    _log.warn('icon %s(%d) not found in current theme', name, size)\n", "path": "lib/solaar/ui/icons.py"}], "after_files": [{"content": "# -*- python-mode -*-\n\n## Copyright (C) 2012-2013  Daniel Pavel\n##\n## This program is free software; you can redistribute it and/or modify\n## it under the terms of the GNU General Public License as published by\n## the Free Software Foundation; either version 2 of the License, or\n## (at your option) any later version.\n##\n## This program is distributed in the hope that it will be useful,\n## but WITHOUT ANY WARRANTY; without even the implied warranty of\n## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n## GNU General Public License for more details.\n##\n## You should have received a copy of the GNU General Public License along\n## with this program; if not, write to the Free Software Foundation, Inc.,\n## 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.\n\nfrom logging import DEBUG as _DEBUG\nfrom logging import getLogger\n\nimport solaar.gtk as gtk\n\nfrom gi.repository import Gtk\n\n_log = getLogger(__name__)\ndel getLogger\n\n#\n#\n#\n\n_LARGE_SIZE = 64\nGtk.IconSize.LARGE = Gtk.icon_size_register('large', _LARGE_SIZE, _LARGE_SIZE)\n# Gtk.IconSize.XLARGE = Gtk.icon_size_register('x-large', _LARGE_SIZE * 2, _LARGE_SIZE * 2)\n# print (\"menu\", int(Gtk.IconSize.MENU), Gtk.icon_size_lookup(Gtk.IconSize.MENU))\n# print (\"small toolbar\", int(Gtk.IconSize.SMALL_TOOLBAR), Gtk.icon_size_lookup(Gtk.IconSize.SMALL_TOOLBAR))\n# print (\"button\", int(Gtk.IconSize.BUTTON), Gtk.icon_size_lookup(Gtk.IconSize.BUTTON))\n# print (\"large toolbar\", int(Gtk.IconSize.LARGE_TOOLBAR), Gtk.icon_size_lookup(Gtk.IconSize.LARGE_TOOLBAR))\n# print (\"dnd\", int(Gtk.IconSize.DND), Gtk.icon_size_lookup(Gtk.IconSize.DND))\n# print (\"dialog\", int(Gtk.IconSize.DIALOG), Gtk.icon_size_lookup(Gtk.IconSize.DIALOG))\n\nTRAY_INIT = 'solaar-init'\nTRAY_OKAY = 'solaar'\nTRAY_ATTENTION = 'solaar-attention'\n\n\ndef _look_for_application_icons():\n    import os.path as _path\n    from os import environ as _environ\n\n    import sys as _sys\n    if _log.isEnabledFor(_DEBUG):\n        _log.debug('sys.path[0] = %s', _sys.path[0])\n    prefix_share = _path.normpath(_path.join(_path.realpath(_sys.path[0]), '..'))\n    src_share = _path.normpath(_path.join(_path.realpath(_sys.path[0]), '..', 'share'))\n    local_share = _environ.get('XDG_DATA_HOME', _path.expanduser(_path.join('~', '.local', 'share')))\n    data_dirs = _environ.get('XDG_DATA_DIRS', '/usr/local/share:/usr/share')\n    repo_share = _path.normpath(_path.join(_path.dirname(__file__), '..', '..', '..', 'share'))\n    setuptools_share = _path.normpath(_path.join(_path.dirname(__file__), '..', '..', 'share'))\n    del _sys\n\n    share_solaar = [prefix_share] + list(\n        _path.join(x, 'solaar') for x in [src_share, local_share, setuptools_share, repo_share] + data_dirs.split(':')\n    )\n    for location in share_solaar:\n        location = _path.join(location, 'icons')\n        if _log.isEnabledFor(_DEBUG):\n            _log.debug('looking for icons in %s', location)\n\n        if _path.exists(_path.join(location, TRAY_ATTENTION + '.svg')):\n            yield location\n\n    del _environ\n    # del _path\n\n\n_default_theme = None\n\n\ndef _init_icon_paths():\n    global _default_theme\n    if _default_theme:\n        return\n\n    _default_theme = Gtk.IconTheme.get_default()\n    for p in _look_for_application_icons():\n        _default_theme.prepend_search_path(p)\n        break  # only prepend one path - that's sufficient\n    if _log.isEnabledFor(_DEBUG):\n        _log.debug('icon theme paths: %s', _default_theme.get_search_path())\n\n    if gtk.battery_icons_style == 'symbolic':\n        global TRAY_OKAY\n        TRAY_OKAY = TRAY_INIT  # use monochrome tray icon\n        if not _default_theme.has_icon('battery-good-symbolic'):\n            _log.warning('failed to detect symbolic icons')\n            gtk.battery_icons_style = 'regular'\n    if gtk.battery_icons_style == 'regular':\n        if not _default_theme.has_icon('battery-good'):\n            _log.warning('failed to detect icons')\n            gtk.battery_icons_style = 'solaar'\n\n\n#\n#\n#\n\n\ndef battery(level=None, charging=False):\n    icon_name = _battery_icon_name(level, charging)\n    if not _default_theme.has_icon(icon_name):\n        _log.warning('icon %s not found in current theme', icon_name)\n        return TRAY_OKAY  # use Solaar icon if battery icon not available\n    elif _log.isEnabledFor(_DEBUG):\n        _log.debug('battery icon for %s:%s = %s', level, charging, icon_name)\n    return icon_name\n\n\n# return first res where val >= guard\n# _first_res(val,((guard,res),...))\ndef _first_res(val, pairs):\n    return next((res for guard, res in pairs if val >= guard), None)\n\n\ndef _battery_icon_name(level, charging):\n    _init_icon_paths()\n\n    if level is None or level < 0:\n        return 'battery-missing' + ('-symbolic' if gtk.battery_icons_style == 'symbolic' else '')\n\n    level_name = _first_res(level, ((90, 'full'), (30, 'good'), (20, 'low'), (5, 'caution'), (0, 'empty')))\n    return 'battery-%s%s%s' % (\n        level_name, '-charging' if charging else '', '-symbolic' if gtk.battery_icons_style == 'symbolic' else ''\n    )\n\n\n#\n#\n#\n\n\ndef lux(level=None):\n    if level is None or level < 0:\n        return 'light_unknown'\n    return 'light_%03d' % (20 * ((level + 50) // 100))\n\n\n#\n#\n#\n\n_ICON_SETS = {}\n\n\ndef device_icon_set(name='_', kind=None):\n    icon_set = _ICON_SETS.get(name)\n    if icon_set is None:\n        icon_set = Gtk.IconSet.new()\n        _ICON_SETS[name] = icon_set\n\n        # names of possible icons, in reverse order of likelihood\n        # the theme will hopefully pick up the most appropriate\n        names = ['preferences-desktop-peripherals']\n        if kind:\n            if str(kind) == 'numpad':\n                names += ('input-keyboard', 'input-dialpad')\n            elif str(kind) == 'touchpad':\n                names += ('input-mouse', 'input-tablet')\n            elif str(kind) == 'trackball':\n                names += ('input-mouse', )\n            elif str(kind) == 'headset':\n                names += ('audio-headphones', 'audio-headset')\n            names += ('input-' + str(kind), )\n        # names += (name.replace(' ', '-'),)\n\n        source = Gtk.IconSource.new()\n        for n in names:\n            source.set_icon_name(n)\n            icon_set.add_source(source)\n        icon_set.names = names\n\n    return icon_set\n\n\ndef device_icon_file(name, kind=None, size=_LARGE_SIZE):\n    _init_icon_paths()\n\n    icon_set = device_icon_set(name, kind)\n    assert icon_set\n    for n in reversed(icon_set.names):\n        if _default_theme.has_icon(n):\n            return _default_theme.lookup_icon(n, size, 0).get_filename()\n\n\ndef device_icon_name(name, kind=None):\n    _init_icon_paths()\n\n    icon_set = device_icon_set(name, kind)\n    assert icon_set\n    for n in reversed(icon_set.names):\n        if _default_theme.has_icon(n):\n            return n\n\n\ndef icon_file(name, size=_LARGE_SIZE):\n    _init_icon_paths()\n\n    # has_icon() somehow returned False while lookup_icon returns non-None.\n    # I guess it happens because share/solaar/icons/ has no hicolor and\n    # resolution subdirs\n    theme_icon = _default_theme.lookup_icon(name, size, 0)\n    if theme_icon:\n        file_name = theme_icon.get_filename()\n        # if _log.isEnabledFor(_DEBUG):\n        #     _log.debug(\"icon %s(%d) => %s\", name, size, file_name)\n        return file_name\n\n    _log.warn('icon %s(%d) not found in current theme', name, size)\n", "path": "lib/solaar/ui/icons.py"}]}