mirror of
https://github.com/aclist/dztui.git
synced 2026-10-31 23:22:44 +01:00
feat: write desktop file
This commit is contained in:
1 parent
caf071f997
commit
0084af4959
1 file changed
+17
-8
@@ -1,10 +1,15 @@
|
|||||||
|
import stat
|
||||||
import textwrap
|
import textwrap
|
||||||
|
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
|
from dzgui.const.constants import APP_NAME
|
||||||
from dzgui.util.dirs import copy_dzgui_to_xdg_data, find_icon_resource, make_parents
|
from dzgui.util.dirs import copy_dzgui_to_xdg_data, find_icon_resource, make_parents
|
||||||
|
|
||||||
|
|
||||||
|
def get_share_path(exe_path: Path) -> Path:
|
||||||
|
return exe_path.parent.parent
|
||||||
|
|
||||||
def write_desktop_file(exe_path: Path) -> None:
|
def write_desktop_file(exe_path: Path) -> None:
|
||||||
icon = find_icon_resource()
|
icon = find_icon_resource()
|
||||||
|
|
||||||
@@ -21,13 +26,17 @@ def write_desktop_file(exe_path: Path) -> None:
|
|||||||
|
|
||||||
copy_dzgui_to_xdg_data(exe_path)
|
copy_dzgui_to_xdg_data(exe_path)
|
||||||
|
|
||||||
share_path = exe_path.parent.parent
|
share_path = get_share_path(exe_path)
|
||||||
file = share_path.joinpath("applications/dzgui.desktop")
|
desktop_file = share_path.joinpath("applications/dzgui.desktop")
|
||||||
make_parents(file)
|
make_parents(desktop_file)
|
||||||
file.write_text(textwrap.dedent(template))
|
desktop_file.write_text(textwrap.dedent(template))
|
||||||
|
desktop_file.chmod(desktop_file.stat().st_mode | stat.S_IEXEC)
|
||||||
|
return desktop_file
|
||||||
|
|
||||||
|
|
||||||
def write_desktop_shortcut(exe_path: Path) -> None:
|
def write_desktop_shortcut(desktop_file: Path) -> None:
|
||||||
# TODO: symlink the above, /Desktop
|
# NOTE: necessarily depends on the above (UI blocks creation without XDG entry first)
|
||||||
# TODO: dynamically link to prior option in UI
|
link = Path.home().joinpath(f"Desktop/{APP_NAME}.desktop")
|
||||||
pass
|
if link.exists():
|
||||||
|
link.unlink()
|
||||||
|
link.symlink_to(desktop_file)
|
||||||
Reference in new issue
Block a user