Deskop importer cleanups
This commit is contained in:
@@ -83,6 +83,10 @@ class DesktopSourceIterable(SourceIterable):
|
|||||||
if entry.suffix != ".desktop":
|
if entry.suffix != ".desktop":
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
# Skip Lutris games
|
||||||
|
if str(entry.name).startswith("net.lutris."):
|
||||||
|
continue
|
||||||
|
|
||||||
keyfile = GLib.KeyFile.new()
|
keyfile = GLib.KeyFile.new()
|
||||||
|
|
||||||
try:
|
try:
|
||||||
@@ -94,10 +98,30 @@ class DesktopSourceIterable(SourceIterable):
|
|||||||
continue
|
continue
|
||||||
|
|
||||||
name = keyfile.get_string("Desktop Entry", "Name")
|
name = keyfile.get_string("Desktop Entry", "Name")
|
||||||
executable = keyfile.get_string("Desktop Entry", "Exec")
|
executable = keyfile.get_string("Desktop Entry", "Exec").split(
|
||||||
|
" %"
|
||||||
|
)[0]
|
||||||
except GLib.GError:
|
except GLib.GError:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
# Skip Steam games
|
||||||
|
if "steam://rungameid/" in executable:
|
||||||
|
continue
|
||||||
|
|
||||||
|
# Skip Heroic games
|
||||||
|
if "heroic://launch/" in executable:
|
||||||
|
continue
|
||||||
|
|
||||||
|
# Skip Bottles games
|
||||||
|
if "bottles-cli " in executable:
|
||||||
|
continue
|
||||||
|
|
||||||
|
try:
|
||||||
|
if keyfile.get_boolean("Desktop Entry", "NoDisplay"):
|
||||||
|
continue
|
||||||
|
except GLib.GError:
|
||||||
|
pass
|
||||||
|
|
||||||
try:
|
try:
|
||||||
terminal = keyfile.get_boolean("Desktop Entry", "Terminal")
|
terminal = keyfile.get_boolean("Desktop Entry", "Terminal")
|
||||||
except GLib.GError:
|
except GLib.GError:
|
||||||
@@ -116,7 +140,7 @@ class DesktopSourceIterable(SourceIterable):
|
|||||||
"name": name,
|
"name": name,
|
||||||
"game_id": "desktop_"
|
"game_id": "desktop_"
|
||||||
+ sha3_256(
|
+ sha3_256(
|
||||||
str(path).encode("utf-8"), usedforsecurity=False
|
str(entry).encode("utf-8"), usedforsecurity=False
|
||||||
).hexdigest(),
|
).hexdigest(),
|
||||||
"executable": self.source.executable_format.format(
|
"executable": self.source.executable_format.format(
|
||||||
exec=cd_path
|
exec=cd_path
|
||||||
@@ -130,26 +154,37 @@ class DesktopSourceIterable(SourceIterable):
|
|||||||
game = Game(values)
|
game = Game(values)
|
||||||
|
|
||||||
additional_data = {}
|
additional_data = {}
|
||||||
|
icon_name = None
|
||||||
|
|
||||||
try:
|
try:
|
||||||
if (
|
icon_str = keyfile.get_string("Desktop Entry", "Icon")
|
||||||
icon_path := icon_theme.lookup_icon(
|
if "/" in icon_str:
|
||||||
keyfile.get_string("Desktop Entry", "Icon"),
|
additional_data = {"local_icon_path": Path(icon_str)}
|
||||||
None,
|
|
||||||
512,
|
|
||||||
1,
|
|
||||||
shared.win.get_direction(),
|
|
||||||
0,
|
|
||||||
)
|
|
||||||
.get_file()
|
|
||||||
.get_path()
|
|
||||||
):
|
|
||||||
additional_data = {"local_icon_path": Path(icon_path)}
|
|
||||||
else:
|
else:
|
||||||
pass
|
icon_name = icon_str
|
||||||
except GLib.GError:
|
except GLib.GError:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
if icon_name:
|
||||||
|
try:
|
||||||
|
if (
|
||||||
|
icon_path := icon_theme.lookup_icon(
|
||||||
|
icon_name,
|
||||||
|
None,
|
||||||
|
512,
|
||||||
|
1,
|
||||||
|
shared.win.get_direction(),
|
||||||
|
0,
|
||||||
|
)
|
||||||
|
.get_file()
|
||||||
|
.get_path()
|
||||||
|
):
|
||||||
|
additional_data = {"local_icon_path": Path(icon_path)}
|
||||||
|
else:
|
||||||
|
pass
|
||||||
|
except GLib.GError:
|
||||||
|
pass
|
||||||
|
|
||||||
yield (game, additional_data)
|
yield (game, additional_data)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user