Skip to content

Commit

Permalink
added support for configurable prefix
Browse files Browse the repository at this point in the history
  • Loading branch information
TanninOne committed Jan 22, 2022
1 parent d834538 commit 51c8e4e
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 3 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ move it to the `InstalledPackage` folder located at:

## Change Log

### v1.6
* made prefix for catalog items configurable

### v1.5
* fixed: steam game names not supporting utf8
* fixed: game not added to catalog if reading icon failed
Expand Down
11 changes: 9 additions & 2 deletions src/allmygames.ini
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,15 @@


[main]
# Plugin's main configuration section

# catalog prefix, can be empty
# prefix =
prefix = AMG

# include the game store in catalog entries
# with: "AMG Steam: foobar"
# without: "AMG: foobar"
# store_prefix = no
store_prefix = yes

[Steam]
enabled = yes
Expand Down
13 changes: 12 additions & 1 deletion src/allmygames.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,11 +116,22 @@ def make_item(self, repo: str, item: dict):
icon_handle = None
valid_parameters = set(['category', 'label', 'target', 'short_desc', 'args_hint', 'hit_hint'])
item = {k: v for k, v in item.items() if k in valid_parameters}

prefix = self.__settings.get("prefix", "main", "AMG")
store_prefix = self.__settings.get_bool("store_prefix", "main", True)
fmt = ": {name}" if (store_prefix or prefix != "") else "{name}"
sep = ""
if store_prefix:
fmt = "{store}" + fmt
sep = " "
if prefix != "":
fmt = prefix + sep + fmt

item = {
**self.__item_base,
"short_desc": "Launch via {0}".format(repo),
**item,
"label": "AMG {}: {}".format(repo, item["label"]),
"label": fmt.format(store=repo, name=item["label"]),
"data_bag": repo + "|" + item["target"],
"icon_handle": icon_handle,
}
Expand Down

0 comments on commit 51c8e4e

Please sign in to comment.