feat: generate shortcuts

This commit is contained in:
aclist committed 2026-07-11 15:33:52 +09:00
1 parent b50d061e1f
commit caf071f997
13 files changed
+380 -40

No files matched your search

+19 -4
View File
@@ -1,18 +1,33 @@
import textwrap
from pathlib import Path
from dzgui.util.dirs import copy_dzgui_to_xdg_data, find_icon_resource, make_parents
def write_desktop_file(exe_path: Path) -> None:
icon = find_icon_resource()
def write_desktop_file(share_path: Path) -> None:
template = f"""\
[Desktop Entry]
Version=1.0
Type=Application
Terminal=false
Exec={share_path}/launch.sh
Exec={exe_path}
Name=DZGUI
Comment=dzgui
Icon={share_path}/dzgui
Icon={icon}
Categories=Game"""
file = share_path / "dzgui.desktop"
copy_dzgui_to_xdg_data(exe_path)
share_path = exe_path.parent.parent
file = share_path.joinpath("applications/dzgui.desktop")
make_parents(file)
file.write_text(textwrap.dedent(template))
def write_desktop_shortcut(exe_path: Path) -> None:
# TODO: symlink the above, /Desktop
# TODO: dynamically link to prior option in UI
pass
+6 -1
View File
@@ -18,6 +18,7 @@ class Xdg:
debug: Path
ips: Path
filters: Path
shortcut: Path
def is_writeable(path_str: str) -> bool:
@@ -67,6 +68,7 @@ def get_xdg_paths() -> dict:
def parse_filepaths(xdg: dict) -> Xdg:
config = xdg["XDG_CONFIG_HOME"]
state = xdg["XDG_STATE_HOME"]
share = xdg["XDG_DATA_HOME"]
config = config / "config.json"
@@ -81,6 +83,8 @@ def parse_filepaths(xdg: dict) -> Xdg:
ips = state / "ips.csv"
filters = state / "dzg.filters.json"
shortcut = share / APP_NAME_LOWER
return Xdg(
config,
columns,
@@ -91,5 +95,6 @@ def parse_filepaths(xdg: dict) -> Xdg:
system,
debug,
ips,
filters
filters,
shortcut,
)