Skip to content

Commit

Permalink
Fix Desktop links (Appimages, wrong path)
Browse files Browse the repository at this point in the history
  • Loading branch information
Dummerle committed Aug 17, 2021
1 parent 363fda6 commit ea78aa7
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 7 deletions.
4 changes: 1 addition & 3 deletions AppImageBuilder.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
# appimage-builder recipe see https://appimage-builder.readthedocs.io for details
version: 1


script:
# Remove any previous build
- rm -rf AppDir Rare | true
- rm -rf AppDir Rare | true
# Make usr and icons dirs
- mkdir -p AppDir/usr/src
- mkdir -p AppDir/usr/share/icons/hicolor/256x256/apps/
Expand All @@ -16,7 +15,6 @@ script:
# Install application dependencies
- python3 -m pip install --system --ignore-installed --prefix=/usr --root=AppDir -r Rare/requirements.txt


AppDir:
path: AppDir
app_info:
Expand Down
2 changes: 1 addition & 1 deletion rare/components/tabs/settings/rare.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ def create_start_menu_link(self):

def create_desktop_link(self):
if not os.path.exists(self.desktop_file):
utils.create_rare_desktop_link("start_menu")
utils.create_rare_desktop_link("desktop")
self.desktop_link.setText(self.tr("Remove Desktop link"))
else:
os.remove(self.desktop_file)
Expand Down
14 changes: 11 additions & 3 deletions rare/utils/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -223,18 +223,22 @@ def create_rare_desktop_link(type_of_link):
# Linux
if platform.system() == "Linux":
if type_of_link == "desktop":
path = os.path.expanduser(f"~/Desktop/")
path = os.path.expanduser("~/Desktop/")
elif type_of_link == "start_menu":
path = os.path.expanduser("~/.local/share/applications/")
else:
return

if p := os.environ.get("APPIMAGE"):
executable = p
else:
executable = f"{sys.executable} {os.path.abspath(sys.argv[0])}"
with open(os.path.join(path, "Rare.desktop"), "w") as desktop_file:
desktop_file.write("[Desktop Entry]\n"
f"Name=Rare\n"
f"Type=Application\n"
f"Icon={os.path.join(resources_path, 'images', 'Rare.png')}\n"
f"Exec={os.path.abspath(sys.argv[0])}\n"
f"Exec={executable}\n"
"Terminal=false\n"
"StartupWMClass=rare\n"
)
Expand Down Expand Up @@ -293,12 +297,16 @@ def create_desktop_link(app_name, core: LegendaryCore, type_of_link="desktop") -
return False
if not os.path.exists(path):
return False
if p := os.environ.get("APPIMAGE"):
executable = p
else:
executable = f"{sys.executable} {os.path.abspath(sys.argv[0])}"
with open(f"{path}{igame.title}.desktop", "w") as desktop_file:
desktop_file.write("[Desktop Entry]\n"
f"Name={igame.title}\n"
f"Type=Application\n"
f"Icon={icon}.png\n"
f"Exec=rare launch {app_name}\n"
f"Exec={executable} launch {app_name}\n"
"Terminal=false\n"
"StartupWMClass=rare-game\n"
)
Expand Down

0 comments on commit ea78aa7

Please sign in to comment.