Skip to content

Commit 4808546

Browse files
Simplify Linux flatpak flow
1 parent 1cf9587 commit 4808546

File tree

9 files changed

+134
-115
lines changed

9 files changed

+134
-115
lines changed

README.md

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
A simple and effective Kodi addon for launching the NVIDIA GeForce NOW app.
88

9-
Updated and fully compatible with Kodi 21.2 (Omega).
9+
Supports both Windows and Linux (via unofficial app - [gfn_electron][gfn_electron]). Updated for and fully compatible with Kodi 21.2 (Omega).
1010

1111
## Which version should I get?
1212

@@ -18,23 +18,29 @@ changes with some Kodi updates.
1818
| Kodi 21.x (Omega) | [Latest Release][latest] |
1919
| Kodi 20.x (Nexus) | [Latest Release][latest] |
2020
| Kodi 19.x (Matrix) | [Latest Release][latest] |
21-
| Older Kodi Versions | [v1.2 Release][v1_2] |
21+
| Older Kodi Versions | [v1.2 Release][v1_2] (supports Windows only)|
2222

2323
[latest]: https://github.com/ZoltePudeleczko/Kodi-GeForceNOW/releases/latest
2424
[v1_2]: https://github.com/ZoltePudeleczko/Kodi-GeForceNOW/releases/tag/v1.2
2525

26-
## Keep in mind
26+
## Requirements
2727

28-
- Supports Windows and Linux (via unofficial Electron app)
29-
- You must have the NVIDIA GeForce NOW app installed
30-
- For Windows you can download it from the official Nvidia website:
31-
[nvidia.com GeForce NOW download][nvidia_download]
32-
- For Linux, as there is no official app yet, you need to install the
33-
unofficial app developed by [@hmlendea][hmlendea] ([gfn-electron][gfn_electron])
34-
- You can override the launcher by enabling `Use custom executable` in the addon
35-
settings
28+
### Windows
29+
30+
- Install official NVIDIA GeForce NOW app from NVIDIA website: [nvidia.com GeForce NOW download][nvidia_download]
31+
32+
Addon automatically detects app installed in the default directory. If it differs for you you can override the launcher in the addon settings.
33+
34+
### Linux
35+
36+
- Make sure you have Flatpak installed - [flatpak.org][flatpak_download]
37+
- Install unofficial Electron NVIDIA GeForce NOW app by [@hmlendea][hmlendea] - [gfn-electron][gfn_electron]
38+
- You can verify that everything is setup correctly by running `flatpak run io.github.hmlendea.geforcenow-electron` command in the terminal
39+
40+
In the addon settings you can provide a custom executable - other app / script that you use for launching GeForce NOW.
3641

3742
[nvidia_download]: https://www.nvidia.com/en-us/geforce-now/download
43+
[flatpak_download]: https://flatpak.org/setup/
3844
[hmlendea]: https://github.com/hmlendea
3945
[gfn_electron]: https://github.com/hmlendea/gfn-electron
4046

script.geforcenow/addon.py

Lines changed: 59 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,19 @@
33
import xbmcgui
44

55
import platform
6+
import os
67
import os.path
78
import subprocess
89
import shutil
910
from typing import Optional
1011
from typing import List
12+
from typing import Callable
1113

1214
ADDON: xbmcaddon.Addon = xbmcaddon.Addon("script.geforcenow")
1315
ADDON_ID: str = ADDON.getAddonInfo("id")
1416
ADDON_NAME: str = ADDON.getAddonInfo("name")
1517
ADDON_VERSION: str = ADDON.getAddonInfo("version")
16-
MSG = ADDON.getLocalizedString
18+
MSG: Callable[[int], str] = ADDON.getLocalizedString
1719

1820
useCustomExecutable: bool = ADDON.getSetting("useCustomExecutable") == "true"
1921
stopMedia: bool = ADDON.getSetting("stopMedia") == "true"
@@ -45,15 +47,6 @@ def showUnsupportedPlatformDetected() -> None:
4547
message: str = MSG(32008)
4648
xbmcgui.Dialog().ok(title, message)
4749

48-
49-
def showCustomExecutableNotFoundDialog() -> None:
50-
"""Show dialog when custom executable is not found and offer to open settings."""
51-
title: str = MSG(32009)
52-
message: str = MSG(32010)
53-
xbmcgui.Dialog().ok(title, message)
54-
showOpenSettingsDialog()
55-
56-
5750
def stopMediaPlayback() -> None:
5851
"""Stop any currently playing media in Kodi."""
5952
player: xbmc.Player = xbmc.Player()
@@ -75,28 +68,42 @@ def showGeForceNowFlatpakNotInstalledDialog() -> None:
7568
xbmcgui.Dialog().ok(title, message)
7669
showOpenSettingsDialog()
7770

71+
def showFlatpakPermissionRequiredDialog() -> None:
72+
"""Show dialog when Kodi Flatpak lacks permission to control host Flatpak."""
73+
title: str = MSG(32025)
74+
message: str = MSG(32026)
75+
xbmcgui.Dialog().ok(title, message)
76+
showOpenSettingsDialog()
7877

79-
def is_flatpak_available() -> bool:
80-
return shutil.which("flatpak") is not None
81-
82-
83-
def is_flatpak_app_installed(app_id: str) -> bool:
84-
"""Check whether a Flatpak app is installed by calling `flatpak info`."""
85-
try:
86-
result = subprocess.run(
87-
["flatpak", "info", app_id],
88-
check=False,
89-
stdout=subprocess.DEVNULL,
90-
stderr=subprocess.DEVNULL,
91-
)
92-
return result.returncode == 0
93-
except Exception as e:
94-
log(f"Error while checking flatpak app installation: {e}", xbmc.LOGERROR)
95-
return False
78+
def _resolve_flatpak_path() -> Optional[str]:
79+
"""
80+
Resolve an absolute path to `flatpak` on the current filesystem.
81+
"""
82+
found: Optional[str] = shutil.which("flatpak")
83+
if found:
84+
return found
85+
for candidate in ("/usr/bin/flatpak", "/bin/flatpak", "/usr/local/bin/flatpak"):
86+
if os.path.isfile(candidate):
87+
return candidate
88+
return None
9689

90+
def _flatpak_base_command() -> Optional[List[str]]:
91+
"""
92+
Return the argv prefix to invoke host flatpak.
93+
- If Kodi runs as Flatpak, use `flatpak-spawn --host flatpak`
94+
- Otherwise use `flatpak`
95+
"""
96+
if os.path.exists("/.flatpak-info"):
97+
# Avoid hardcoding /usr/bin/flatpak on the host; let the host PATH resolve it.
98+
return ["flatpak-spawn", "--host", "flatpak"]
99+
else:
100+
flatpak_path = _resolve_flatpak_path()
101+
if flatpak_path is None:
102+
return None
103+
return [flatpak_path]
97104

98105
def resolve_launch_command() -> Optional[List[str]]:
99-
"""Resolve the command to launch GeForce NOW based on platform and settings."""
106+
"""Resolve the command to launch GeForce NOW."""
100107
system: str = platform.system()
101108

102109
if useCustomExecutable:
@@ -107,7 +114,7 @@ def resolve_launch_command() -> Optional[List[str]]:
107114
"Executable not found on the custom location provided by user",
108115
xbmc.LOGERROR,
109116
)
110-
showCustomExecutableNotFoundDialog()
117+
showExecutableNotFoundDialog()
111118
return None
112119

113120
if system == "Windows":
@@ -121,41 +128,47 @@ def resolve_launch_command() -> Optional[List[str]]:
121128
return None
122129

123130
if system == "Linux":
124-
app_id: str = "io.github.hmlendea.geforcenow-electron"
125-
if not is_flatpak_available():
126-
log("Flatpak not found in PATH", xbmc.LOGERROR)
131+
base_cmd: Optional[List[str]] = _flatpak_base_command()
132+
if base_cmd is None:
133+
log(
134+
f"Flatpak not found/available (PATH={os.environ.get('PATH', '')})",
135+
xbmc.LOGERROR,
136+
)
127137
showFlatpakNotFoundDialog()
128138
return None
129-
if not is_flatpak_app_installed(app_id):
130-
log(f"Required Flatpak app not installed: {app_id}", xbmc.LOGERROR)
131-
showGeForceNowFlatpakNotInstalledDialog()
132-
return None
133-
return ["flatpak", "run", app_id]
139+
140+
app_id: str = "io.github.hmlendea.geforcenow-electron"
141+
return base_cmd + ["run", app_id]
134142

135143
log(f"Unsupported platform detected: {system}", xbmc.LOGERROR)
136144
showUnsupportedPlatformDetected()
137145
return None
138146

139-
140-
def execute(command: List[str]) -> None:
147+
def execute(argv: List[str]) -> None:
141148
"""Execute the GeForce NOW application.
142149
143150
Args:
144-
command: Command (argv list) to execute.
151+
argv: Command argv to execute (e.g. ["flatpak", "run", "io.github.hmlendea.geforcenow-electron"]).
145152
"""
146-
log(f"Calling command: {command}")
153+
log(f"Calling command: {' '.join(argv)}")
147154

148155
if stopMedia:
149156
stopMediaPlayback()
150157

151158
try:
152-
subprocess.run(command, check=True)
159+
subprocess.run(argv, check=True)
160+
except FileNotFoundError as e:
161+
log(f"Executable not found while executing command ({e})", xbmc.LOGERROR)
162+
# Most common on Linux is missing flatpak/flatpak-spawn inside the runtime.
163+
showFlatpakNotFoundDialog()
153164
except subprocess.CalledProcessError as e:
154-
log(f"Error executing command {command}: {e}", xbmc.LOGERROR)
165+
log(f"Error executing command {' '.join(argv)}: {e}", xbmc.LOGERROR)
155166

156167

157168
log("Starting GeForceNOW launcher addon")
158169

159-
command: Optional[List[str]] = resolve_launch_command()
160-
if command:
161-
execute(command)
170+
argv: Optional[List[str]] = resolve_launch_command()
171+
if argv:
172+
execute(argv)
173+
else:
174+
log("Failed to resolve launch command", xbmc.LOGERROR)

script.geforcenow/resources/language/resource.language.de_de/strings.po

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -48,14 +48,6 @@ msgctxt "#32008"
4848
msgid "This Add-on currently works only on Windows and Linux platforms."
4949
msgstr "Dieses Add-on funktioniert derzeit nur auf Windows- und Linux-Plattformen."
5050

51-
msgctxt "#32009"
52-
msgid "Custom executable not found"
53-
msgstr "Benutzerdefiniertes Programm nicht gefunden"
54-
55-
msgctxt "#32010"
56-
msgid "The custom executable was not found. Please select a new location for it on the Addon Settings."
57-
msgstr "Das benutzerdefinierte Programm wurde nicht gefunden. Bitte wählen Sie in den Addon-Einstellungen einen neuen Speicherort."
58-
5951
msgctxt "#32011"
6052
msgid "Stop all media playback on start"
6153
msgstr "Alle Medienwiedergaben beim Start stoppen"
@@ -75,3 +67,11 @@ msgstr "GeForce NOW-Flatpak nicht installiert"
7567
msgctxt "#32015"
7668
msgid "The Flatpak 'io.github.hmlendea.geforcenow-electron' is not installed. Install it or configure a custom executable in the Addon Settings."
7769
msgstr "Das Flatpak „io.github.hmlendea.geforcenow-electron“ ist nicht installiert. Installieren Sie es oder konfigurieren Sie ein benutzerdefiniertes Programm in den Addon-Einstellungen."
70+
71+
msgctxt "#32025"
72+
msgid "Flatpak permission required"
73+
msgstr "Flatpak-Berechtigung erforderlich"
74+
75+
msgctxt "#32026"
76+
msgid "Kodi is running as Flatpak so it cannot start GeForce NOW.\n\nRecommended fix: install Kodi natively (not via Flatpak).\n\nAdvanced: you can try allowing Kodi to talk to Flatpak and restart Kodi:\nflatpak override --user --talk-name=org.freedesktop.Flatpak tv.kodi.Kodi\n\nAlternatively, configure a custom executable in the Addon Settings."
77+
msgstr "Kodi wird als Flatpak ausgeführt und kann GeForce NOW daher nicht starten.\n\nEmpfohlene Lösung: Kodi nativ installieren (nicht via Flatpak).\n\nErweitert: Sie können versuchen, Kodi die Kommunikation mit Flatpak zu erlauben und Kodi neu zu starten:\nflatpak override --user --talk-name=org.freedesktop.Flatpak tv.kodi.Kodi\n\nAlternativ können Sie ein benutzerdefiniertes Programm in den Addon-Einstellungen konfigurieren."

script.geforcenow/resources/language/resource.language.en_gb/strings.po

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -48,14 +48,6 @@ msgctxt "#32008"
4848
msgid "This Add-on currently works only on Windows and Linux platforms."
4949
msgstr ""
5050

51-
msgctxt "#32009"
52-
msgid "Custom executable not found"
53-
msgstr ""
54-
55-
msgctxt "#32010"
56-
msgid "The custom executable was not found. Please select a new location for it on the Addon Settings."
57-
msgstr ""
58-
5951
msgctxt "#32011"
6052
msgid "Stop all media playback on start"
6153
msgstr ""
@@ -74,4 +66,12 @@ msgstr ""
7466

7567
msgctxt "#32015"
7668
msgid "The Flatpak 'io.github.hmlendea.geforcenow-electron' is not installed. Install it or configure a custom executable in the Addon Settings."
69+
msgstr ""
70+
71+
msgctxt "#32025"
72+
msgid "Flatpak permission required"
73+
msgstr ""
74+
75+
msgctxt "#32026"
76+
msgid "Kodi is running as Flatpak so it cannot start GeForce NOW.\n\nRecommended fix: install Kodi natively (not via Flatpak).\n\nAdvanced: you can try allowing Kodi to talk to Flatpak and restart Kodi:\nflatpak override --user --talk-name=org.freedesktop.Flatpak tv.kodi.Kodi\n\nAlternatively, configure a custom executable in the Addon Settings."
7777
msgstr ""

script.geforcenow/resources/language/resource.language.es_es/strings.po

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -48,14 +48,6 @@ msgctxt "#32008"
4848
msgid "This Add-on currently works only on Windows and Linux platforms."
4949
msgstr "Este complemento actualmente solo funciona en plataformas Windows y Linux."
5050

51-
msgctxt "#32009"
52-
msgid "Custom executable not found"
53-
msgstr "Ejecutable personalizado no encontrado"
54-
55-
msgctxt "#32010"
56-
msgid "The custom executable was not found. Please select a new location for it on the Addon Settings."
57-
msgstr "No se encontró el ejecutable personalizado. Por favor, seleccione una nueva ubicación para él en la configuración del complemento."
58-
5951
msgctxt "#32011"
6052
msgid "Stop all media playback on start"
6153
msgstr "Detener toda la reproducción de medios al iniciar"
@@ -74,4 +66,12 @@ msgstr "Flatpak de GeForce NOW no instalado"
7466

7567
msgctxt "#32015"
7668
msgid "The Flatpak 'io.github.hmlendea.geforcenow-electron' is not installed. Install it or configure a custom executable in the Addon Settings."
77-
msgstr "El Flatpak 'io.github.hmlendea.geforcenow-electron' no está instalado. Instálelo o configure un ejecutable personalizado en la configuración del complemento."
69+
msgstr "El Flatpak 'io.github.hmlendea.geforcenow-electron' no está instalado. Instálelo o configure un ejecutable personalizado en la configuración del complemento."
70+
71+
msgctxt "#32025"
72+
msgid "Flatpak permission required"
73+
msgstr "Permiso de Flatpak requerido"
74+
75+
msgctxt "#32026"
76+
msgid "Kodi is running as Flatpak so it cannot start GeForce NOW.\n\nRecommended fix: install Kodi natively (not via Flatpak).\n\nAdvanced: you can try allowing Kodi to talk to Flatpak and restart Kodi:\nflatpak override --user --talk-name=org.freedesktop.Flatpak tv.kodi.Kodi\n\nAlternatively, configure a custom executable in the Addon Settings."
77+
msgstr "Kodi se está ejecutando como Flatpak, por lo que no puede iniciar GeForce NOW.\n\nSolución recomendada: instalar Kodi de forma nativa (no vía Flatpak).\n\nAvanzado: puede intentar permitir que Kodi hable con Flatpak y reiniciar Kodi:\nflatpak override --user --talk-name=org.freedesktop.Flatpak tv.kodi.Kodi\n\nAlternativamente, configure un ejecutable personalizado en la configuración del complemento."

script.geforcenow/resources/language/resource.language.fr_fr/strings.po

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -48,14 +48,6 @@ msgctxt "#32008"
4848
msgid "This Add-on currently works only on Windows and Linux platforms."
4949
msgstr "Cette extension fonctionne actuellement uniquement sur les plateformes Windows et Linux."
5050

51-
msgctxt "#32009"
52-
msgid "Custom executable not found"
53-
msgstr "Exécutable personnalisé introuvable"
54-
55-
msgctxt "#32010"
56-
msgid "The custom executable was not found. Please select a new location for it on the Addon Settings."
57-
msgstr "L'exécutable personnalisé est introuvable. Veuillez sélectionner un nouvel emplacement dans les paramètres de l'extension."
58-
5951
msgctxt "#32011"
6052
msgid "Stop all media playback on start"
6153
msgstr "Arrêter toute lecture multimédia au démarrage"
@@ -75,3 +67,11 @@ msgstr "Flatpak GeForce NOW non installé"
7567
msgctxt "#32015"
7668
msgid "The Flatpak 'io.github.hmlendea.geforcenow-electron' is not installed. Install it or configure a custom executable in the Addon Settings."
7769
msgstr "Le Flatpak 'io.github.hmlendea.geforcenow-electron' n'est pas installé. Installez-le ou configurez un exécutable personnalisé dans les paramètres de l'extension."
70+
71+
msgctxt "#32025"
72+
msgid "Flatpak permission required"
73+
msgstr "Autorisation Flatpak requise"
74+
75+
msgctxt "#32026"
76+
msgid "Kodi is running as Flatpak so it cannot start GeForce NOW.\n\nRecommended fix: install Kodi natively (not via Flatpak).\n\nAdvanced: you can try allowing Kodi to talk to Flatpak and restart Kodi:\nflatpak override --user --talk-name=org.freedesktop.Flatpak tv.kodi.Kodi\n\nAlternatively, configure a custom executable in the Addon Settings."
77+
msgstr "Kodi s'exécute en tant que Flatpak, il ne peut donc pas démarrer GeForce NOW.\n\nCorrectif recommandé : installer Kodi nativement (pas via Flatpak).\n\nAvancé : vous pouvez essayer d'autoriser Kodi à communiquer avec Flatpak puis redémarrer Kodi :\nflatpak override --user --talk-name=org.freedesktop.Flatpak tv.kodi.Kodi\n\nSinon, configurez un exécutable personnalisé dans les paramètres de l'extension."

script.geforcenow/resources/language/resource.language.it_it/strings.po

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -48,14 +48,6 @@ msgctxt "#32008"
4848
msgid "This Add-on currently works only on Windows and Linux platforms."
4949
msgstr "Questo add-on attualmente funziona solo su piattaforme Windows e Linux."
5050

51-
msgctxt "#32009"
52-
msgid "Custom executable not found"
53-
msgstr "Eseguibile personalizzato non trovato"
54-
55-
msgctxt "#32010"
56-
msgid "The custom executable was not found. Please select a new location for it on the Addon Settings."
57-
msgstr "L'eseguibile personalizzato non è stato trovato. Seleziona una nuova posizione nelle impostazioni dell'add-on."
58-
5951
msgctxt "#32011"
6052
msgid "Stop all media playback on start"
6153
msgstr "Interrompi la riproduzione dei contenuti multimediali all'avvio"
@@ -75,3 +67,11 @@ msgstr "Flatpak di GeForce NOW non installato"
7567
msgctxt "#32015"
7668
msgid "The Flatpak 'io.github.hmlendea.geforcenow-electron' is not installed. Install it or configure a custom executable in the Addon Settings."
7769
msgstr "Il Flatpak 'io.github.hmlendea.geforcenow-electron' non è installato. Installalo o configura un eseguibile personalizzato nelle impostazioni dell'add-on."
70+
71+
msgctxt "#32025"
72+
msgid "Flatpak permission required"
73+
msgstr "Permesso Flatpak richiesto"
74+
75+
msgctxt "#32026"
76+
msgid "Kodi is running as Flatpak so it cannot start GeForce NOW.\n\nRecommended fix: install Kodi natively (not via Flatpak).\n\nAdvanced: you can try allowing Kodi to talk to Flatpak and restart Kodi:\nflatpak override --user --talk-name=org.freedesktop.Flatpak tv.kodi.Kodi\n\nAlternatively, configure a custom executable in the Addon Settings."
77+
msgstr "Kodi è in esecuzione come Flatpak, quindi non può avviare GeForce NOW.\n\nCorrezione consigliata: installare Kodi in modo nativo (non tramite Flatpak).\n\nAvanzato: puoi provare a consentire a Kodi di comunicare con Flatpak e riavviare Kodi:\nflatpak override --user --talk-name=org.freedesktop.Flatpak tv.kodi.Kodi\n\nIn alternativa, configura un eseguibile personalizzato nelle impostazioni dell'add-on."

script.geforcenow/resources/language/resource.language.pl_pl/strings.po

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -48,14 +48,6 @@ msgctxt "#32008"
4848
msgid "This Add-on currently works only on Windows and Linux platforms."
4949
msgstr "Ta wtyczka działa obecnie tylko na platformach Windows i Linux."
5050

51-
msgctxt "#32009"
52-
msgid "Custom executable not found"
53-
msgstr "Nie znaleziono podanego pliku .exe"
54-
55-
msgctxt "#32010"
56-
msgid "The custom executable was not found. Please select a new location for it on the Addon Settings."
57-
msgstr "Nie znaleziono podanego pliku .exe. Proszę wybrać nową lokalizację w ustawieniach wtyczki."
58-
5951
msgctxt "#32011"
6052
msgid "Stop all media playback on start"
6153
msgstr "Zatrzymaj wszystkie odtwarzane media przy starcie"
@@ -74,4 +66,12 @@ msgstr "Flatpak GeForce NOW nie jest zainstalowany"
7466

7567
msgctxt "#32015"
7668
msgid "The Flatpak 'io.github.hmlendea.geforcenow-electron' is not installed. Install it or configure a custom executable in the Addon Settings."
77-
msgstr "Flatpak 'io.github.hmlendea.geforcenow-electron' nie jest zainstalowany. Zainstaluj go lub skonfiguruj własny plik wykonywalny w ustawieniach wtyczki."
69+
msgstr "Flatpak 'io.github.hmlendea.geforcenow-electron' nie jest zainstalowany. Zainstaluj go lub skonfiguruj własny plik wykonywalny w ustawieniach wtyczki."
70+
71+
msgctxt "#32025"
72+
msgid "Flatpak permission required"
73+
msgstr "Wymagane uprawnienia Flatpak"
74+
75+
msgctxt "#32026"
76+
msgid "Kodi is running as Flatpak so it cannot start GeForce NOW.\n\nRecommended fix: install Kodi natively (not via Flatpak).\n\nAdvanced: you can try allowing Kodi to talk to Flatpak and restart Kodi:\nflatpak override --user --talk-name=org.freedesktop.Flatpak tv.kodi.Kodi\n\nAlternatively, configure a custom executable in the Addon Settings."
77+
msgstr "Kodi działa jako Flatpak, więc nie może uruchomić GeForce NOW.\n\nZalecane rozwiązanie: zainstaluj Kodi natywnie (nie przez Flatpaka).\n\nZaawansowane: możesz spróbować zezwolić Kodi na komunikację z Flatpakiem i zrestartować Kodi:\nflatpak override --user --talk-name=org.freedesktop.Flatpak tv.kodi.Kodi\n\nAlternatywnie skonfiguruj własny plik wykonywalny w ustawieniach wtyczki."

0 commit comments

Comments
 (0)