[fix][web] not informing StartupWMClass on generated desktop entries

This commit is contained in:
Vinícius Moreira
2020-03-06 12:20:04 -03:00
parent a16b64740a
commit 1a2d97bf46
3 changed files with 30 additions and 12 deletions

View File

@@ -3,11 +3,12 @@ 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/).
## [0.8.5] - 2020-03-06
## [0.8.5] - 2020-03
### Fixes
- Web
- not able to inject javascript fixes ( WhatsApp Web not working) [#74](https://github.com/vinifmor/bauh/issues/74)
- not informing StartupWMClass on generated desktop entries ( prevents Gnome to link the Favorite shortcut with the app instance [#76](https://github.com/vinifmor/bauh/issues/76) )
### Improvements
- AUR

View File

@@ -1,4 +1,5 @@
import glob
import json
import locale
import os
import re
@@ -688,6 +689,15 @@ class WebApplicationManager(SoftwareManager):
watcher.change_substatus(self.i18n['web.install.substatus.shortcut'])
try:
package_info_path = '{}/resources/app/package.json'.format(pkg.installation_dir)
with open(package_info_path) as f:
package_info_path = json.loads(f.read())
pkg.package_name = package_info_path['name']
except:
self.logger.info("Could not read the the package info from '{}'".format(package_info_path))
traceback.print_exc()
desktop_entry_path = self._gen_desktop_entry_path(app_id)
entry_content = self._gen_desktop_entry_content(pkg)
@@ -720,9 +730,11 @@ class WebApplicationManager(SoftwareManager):
Icon={icon}
Exec={exec_path}
{categories}
{wmclass}
""".format(name=pkg.name, exec_path=pkg.get_command(),
desc=pkg.description or pkg.url, icon=pkg.get_disk_icon_path(),
categories='Categories={}'.format(';'.join(pkg.categories)) if pkg.categories else '')
categories='Categories={}'.format(';'.join(pkg.categories)) if pkg.categories else '',
wmclass="StartupWMClass={}".format(pkg.package_name) if pkg.package_name else '')
def is_enabled(self) -> bool:
return self.enabled

View File

@@ -13,7 +13,7 @@ class WebApplication(SoftwarePackage):
def __init__(self, id: str = None, url: str = None, name: str = None, description: str = None, icon_url: str = None,
installation_dir: str = None, desktop_entry: str = None, installed: bool = False, version: str = None,
categories: List[str] = None, custom_icon: str = None, preset_options: List[str] = None, save_icon: bool = True,
options_set: List[str] = None):
options_set: List[str] = None, package_name: str = None):
super(WebApplication, self).__init__(id=id if id else url, name=name, description=description,
icon_url=icon_url, installed=installed, version=version,
categories=categories)
@@ -24,6 +24,7 @@ class WebApplication(SoftwarePackage):
self.preset_options = preset_options
self.save_icon = save_icon # if the icon_url should be used instead of the one retrieved by nativefier
self.options_set = options_set
self.package_name = package_name
def set_version(self, version: str):
self.version = str(version) if version else None
@@ -38,7 +39,7 @@ class WebApplication(SoftwarePackage):
@staticmethod
def _get_cached_attrs() -> tuple:
return 'id', 'name', 'version', 'url', 'description', 'icon_url', 'installation_dir', \
'desktop_entry', 'categories', 'custom_icon', 'options_set', 'save_icon'
'desktop_entry', 'categories', 'custom_icon', 'options_set', 'save_icon', 'package_name'
def can_be_downgraded(self):
return False
@@ -123,13 +124,17 @@ class WebApplication(SoftwarePackage):
self.icon_url = custom_icon
def get_config_dir(self) -> str:
if self.installation_dir:
config_path = '{}/.config'.format(Path.home())
if self.package_name:
config_dir = '{}/.config/{}'.format(str(Path.home()), self.package_name)
if os.path.exists(config_path):
config_dirs = glob.glob('{}/{}-nativefier-*'.format(config_path, self.installation_dir.split('/')[-1]))
if config_dirs:
return config_dirs[0]
if os.path.exists(config_dir):
return config_dir
else:
if self.installation_dir:
config_path = '{}/.config'.format(str(Path.home()))
if os.path.exists(config_path):
config_dirs = glob.glob('{}/{}-nativefier-*'.format(config_path, self.installation_dir.split('/')[-1]))
if config_dirs:
return config_dirs[0]