Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion Apps/apps.ini
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@
# * Default: yes
#auto_terminal = yes


# Custom Commands
#
# As a slightly more flexible port of Launchy's Runner plugin to Keypirinha, the
Expand Down Expand Up @@ -105,6 +104,20 @@
# elevated privileges? (default is "no")
# * item_label:
# See the 'item_label' setting from the [custom_commands] section above.
# *icon_name:
# A icon name that is used to set the icon of the custom command, These icons
# need to be added to tha packaged zip file, by default this is under
# "default\Packages\Apps.keypirinha-package"
# Icon Package structure should follow the bellow, please try to add all 4 icons
# for best visuals
# Apps.keypirinha-package
# ->apps.py
# ->icons
# ->{iconName}
# ->{iconName-16.ico}
# ->{iconName-32.ico}
# ->{iconName-48.ico}
# ->{iconName-256.ico}
# * Placeholders:
# * Format: "{{x}}"
# * Where "x" can be:
Expand Down
29 changes: 28 additions & 1 deletion Apps/apps.py
Original file line number Diff line number Diff line change
Expand Up @@ -525,6 +525,14 @@ def _read_config(self):
cmd_elevated = settings.get_bool(
"elevated", section=section, fallback=False)

icon_name = settings.get(
"icon_name", section=section, fallback=False)

if icon_name:
icon = self._config_icon(icon_name)
else:
icon = self._customcmd_icon(cmd_lines)

cmd_has_placeholders = any(map(
lambda s: self.REGEX_PLACEHOLDER.search(s) is not None,
cmd_lines))
Expand All @@ -539,10 +547,29 @@ def _read_config(self):
'item_label': cmd_item_label,
'args_hint': cmd_args_hint,
'hit_hint': cmd_hit_hint,
'icon_handle': self._customcmd_icon(cmd_lines),
'icon_handle': icon,
'auto_terminal': cmd_auto_terminal,
'elevated': cmd_elevated}

def _config_icon(self, icon_name):
initFilePath = f"res://{self.package_full_name()}/"
resources = self.find_resources("*")
try:
location = []
sizes = [16, 32, 48, 256]
for size in sizes:
file_part_path = f"icons/{icon_name}/{icon_name}-{size}.ico"
if file_part_path in resources:
location.append(f"{initFilePath}{file_part_path}")
else:
self.info(f"Icon for file size {size} does not exist in path {file_part_path}")
return self.load_icon(location)

except ValueError:
self.info(f"No Icon files found for icon {icon_name}")
self.info(f"Please Read configuration which explains how to load icons")
return None

def _customcmd_icon(self, cmd_lines):
#for cmdline in cmd_lines:
# try:
Expand Down