Remove Steam shortcut, completely remove games with no playtime, remove update_all_artwork

This commit is contained in:
Mathieu Comandon 2023-10-17 16:24:01 -07:00
parent 8c5e6d7264
commit 3a27de7a94
2 changed files with 4 additions and 19 deletions

View file

@ -30,6 +30,7 @@ from lutris.util.graphics.xrandr import turn_off_except
from lutris.util.log import LOG_BUFFERS, logger
from lutris.util.process import Process
from lutris.util.savesync import sync_saves
from lutris.util.steam.shortcut import remove_shortcut as remove_steam_shortcut
from lutris.util.timer import Timer
from lutris.util.yaml import write_yaml_to_file
@ -382,6 +383,7 @@ class Game(GObject.Object):
if self.config:
self.config.remove()
xdgshortcuts.remove_launcher(self.slug, self.id, desktop=True, menu=True)
remove_steam_shortcut(self)
if delete_files and self.runner:
# self.directory here, not self.resolve_game_path; no guessing at
# directories when we delete them
@ -394,6 +396,8 @@ class Game(GObject.Object):
log_buffer = LOG_BUFFERS[str(self.id)]
log_buffer.delete(log_buffer.get_start_iter(), log_buffer.get_end_iter())
if not self.playtime:
return self.delete(no_signal=no_signal)
if no_signal:
return
self.emit("game-removed")

View file

@ -6,7 +6,6 @@ import shlex
import shutil
from lutris.api import format_installer_url
from lutris.game import Game
from lutris.util import resources, system
from lutris.util.log import logger
from lutris.util.steam import vdf
@ -191,21 +190,3 @@ def set_artwork(game):
logger.debug("Copied %s cover to %s", game, target_banner)
except FileNotFoundError as ex:
logger.error("Failed to copy banner to %s: %s", target_banner, ex)
def update_all_artwork():
try:
shortcut_path = get_shortcuts_vdf_path()
if not system.path_exists(shortcut_path):
return
with open(shortcut_path, "rb") as shortcut_file:
shortcuts = vdf.binary_loads(shortcut_file.read())['shortcuts'].values()
for shortcut in shortcuts:
id_match = re.match(r".*lutris:rungameid/(\d+)", shortcut["LaunchOptions"])
if not id_match:
continue
game_id = int(id_match.groups()[0])
game = Game(game_id)
set_artwork(game)
except Exception as ex:
logger.error("Failed to update steam shortcut artwork: %s", ex)