mirror of
https://github.com/spalencsar/bearhub.git
synced 2026-07-07 01:14:15 +02:00
[gems.appimage] fix: manual installation is not generating desktop entries for AppImage files providing empty .desktop files
This commit is contained in:
@@ -4,6 +4,11 @@ All notable changes to this project will be documented in this file.
|
|||||||
|
|
||||||
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
|
||||||
|
|
||||||
|
## [0.9.19]
|
||||||
|
### Fixes
|
||||||
|
- AppImage
|
||||||
|
- manual installation: not generating desktop entries for AppImage files providing empty .desktop files (https://github.com/vinifmor/bauh/issues/186)[#186]
|
||||||
|
|
||||||
## [0.9.18] 2021-06-18
|
## [0.9.18] 2021-06-18
|
||||||
### Fixes
|
### Fixes
|
||||||
- Arch
|
- Arch
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
__version__ = '0.9.18'
|
__version__ = '0.9.19'
|
||||||
__app_name__ = 'bauh'
|
__app_name__ = 'bauh'
|
||||||
|
|
||||||
import os
|
import os
|
||||||
|
|||||||
@@ -561,18 +561,24 @@ class AppImageManager(SoftwareManager):
|
|||||||
with open('{}/{}'.format(extracted_folder, desktop_entry)) as f:
|
with open('{}/{}'.format(extracted_folder, desktop_entry)) as f:
|
||||||
de_content = f.read()
|
de_content = f.read()
|
||||||
|
|
||||||
de_content = replace_desktop_entry_exec_command(desktop_entry=de_content,
|
if de_content:
|
||||||
appname=pkg.name,
|
de_content = replace_desktop_entry_exec_command(desktop_entry=de_content,
|
||||||
file_path=file_path)
|
appname=pkg.name,
|
||||||
|
file_path=file_path)
|
||||||
extracted_icon = self._find_icon_file(extracted_folder)
|
extracted_icon = self._find_icon_file(extracted_folder)
|
||||||
|
|
||||||
if extracted_icon:
|
if extracted_icon:
|
||||||
icon_path = out_dir + '/logo.' + extracted_icon.split('/')[-1].split('.')[-1]
|
icon_path = out_dir + '/logo.' + extracted_icon.split('/')[-1].split('.')[-1]
|
||||||
shutil.copy(extracted_icon, icon_path)
|
shutil.copy(extracted_icon, icon_path)
|
||||||
de_content = RE_DESKTOP_ICON.sub('Icon={}\n'.format(icon_path), de_content)
|
|
||||||
|
if de_content:
|
||||||
|
de_content = RE_DESKTOP_ICON.sub('Icon={}\n'.format(icon_path), de_content)
|
||||||
|
|
||||||
pkg.icon_path = icon_path
|
pkg.icon_path = icon_path
|
||||||
|
|
||||||
|
if not de_content:
|
||||||
|
de_content = pkg.to_desktop_entry()
|
||||||
|
|
||||||
Path(DESKTOP_ENTRIES_PATH).mkdir(parents=True, exist_ok=True)
|
Path(DESKTOP_ENTRIES_PATH).mkdir(parents=True, exist_ok=True)
|
||||||
|
|
||||||
with open(self._gen_desktop_entry_path(pkg), 'w+') as f:
|
with open(self._gen_desktop_entry_path(pkg), 'w+') as f:
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import re
|
import re
|
||||||
|
from io import StringIO
|
||||||
from typing import List, Optional
|
from typing import List, Optional
|
||||||
|
|
||||||
from bauh.api.abstract.model import SoftwarePackage, CustomSoftwareAction
|
from bauh.api.abstract.model import SoftwarePackage, CustomSoftwareAction
|
||||||
@@ -127,3 +128,20 @@ class AppImage(SoftwarePackage):
|
|||||||
def get_clean_name(self) -> Optional[str]:
|
def get_clean_name(self) -> Optional[str]:
|
||||||
if self.name:
|
if self.name:
|
||||||
return RE_MANY_SPACES.sub('-', self.name.lower().strip())
|
return RE_MANY_SPACES.sub('-', self.name.lower().strip())
|
||||||
|
|
||||||
|
def to_desktop_entry(self) -> str:
|
||||||
|
de = StringIO()
|
||||||
|
de.write("[Desktop Entry]\nType=Application\nName={}\n".format(self.name))
|
||||||
|
|
||||||
|
if self.install_dir and self.local_file_path:
|
||||||
|
de.write('Exec="{}/{}"\n'.format(self.install_dir, self.local_file_path.split('/')[-1]))
|
||||||
|
|
||||||
|
if self.icon_path:
|
||||||
|
de.write('Icon={}\n'.format(self.icon_path))
|
||||||
|
|
||||||
|
if self.categories:
|
||||||
|
de.write('Categories={};\n'.format(';'.join((c for c in self.categories if c.lower() != 'imported'))))
|
||||||
|
|
||||||
|
de.write('Terminal=false')
|
||||||
|
de.seek(0)
|
||||||
|
return de.read()
|
||||||
|
|||||||
Reference in New Issue
Block a user