-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlaunchbar.py
38 lines (33 loc) · 1.31 KB
/
launchbar.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import os
from qtile_extras import widget
from xdg.IconTheme import getIconPath
class LaunchBar(widget.LaunchBar):
defaults = [
(
"theme_path",
None,
"Path to icon theme to be used by pyxdg for icons. ``None`` will use default icon theme.",
),
]
def __init__(self, **config):
widget.LaunchBar.__init__(self, **config)
self.add_defaults(LaunchBar.defaults)
def _lookup_icon(self, name):
"""Search for the icon corresponding to one command."""
self.icons_files[name] = None
# if the software_name is directly an absolute path icon file
if os.path.isabs(name):
# name start with '/' thus it's an absolute path
root, ext = os.path.splitext(name)
if ext == ".png":
self.icons_files[name] = name if os.path.isfile(name) else None
else:
# try to add the extension
self.icons_files[name] = (
f"{name}.png" if os.path.isfile(f"{name}.png") else None
)
else:
self.icons_files[name] = getIconPath(name, theme=self.theme_path)
# no search method found an icon, so default icon
if self.icons_files[name] is None:
self.icons_files[name] = self.default_icon