Use correct sys.platform convention
This commit is contained in:
@@ -76,7 +76,7 @@ class Source(Iterable):
|
|||||||
|
|
||||||
@property
|
@property
|
||||||
def is_available(self) -> bool:
|
def is_available(self) -> bool:
|
||||||
return sys.platform in self.available_on
|
return any(sys.platform.startswith(platform) for platform in self.available_on)
|
||||||
|
|
||||||
def make_executable(self, *args, **kwargs) -> str:
|
def make_executable(self, *args, **kwargs) -> str:
|
||||||
"""
|
"""
|
||||||
@@ -120,14 +120,15 @@ class URLExecutableSource(ExecutableFormatSource):
|
|||||||
|
|
||||||
@property
|
@property
|
||||||
def executable_format(self) -> str:
|
def executable_format(self) -> str:
|
||||||
match sys.platform:
|
if sys.platform.startswith("win32"):
|
||||||
case "win32":
|
return f"start {self.url_format}"
|
||||||
return "start " + self.url_format
|
|
||||||
case "linux":
|
if sys.platform.startswith("linux"):
|
||||||
return "xdg-open " + self.url_format
|
return f"xdg-open {self.url_format}"
|
||||||
case "darwin":
|
|
||||||
return "open " + self.url_format
|
if sys.platform.startswith("darwin"):
|
||||||
case other:
|
return f"open {self.url_format}"
|
||||||
raise NotImplementedError(
|
|
||||||
f"No URL handler command available for {other}"
|
raise NotImplementedError(
|
||||||
)
|
f"No URL handler command available for {sys.platform}"
|
||||||
|
)
|
||||||
|
|||||||
@@ -58,7 +58,7 @@ from cartridges.store.store import Store
|
|||||||
from cartridges.utils.run_executable import run_executable
|
from cartridges.utils.run_executable import run_executable
|
||||||
from cartridges.window import CartridgesWindow
|
from cartridges.window import CartridgesWindow
|
||||||
|
|
||||||
if sys.platform == "darwin":
|
if sys.platform.startswith("darwin"):
|
||||||
from AppKit import NSApp # type: ignore
|
from AppKit import NSApp # type: ignore
|
||||||
from PyObjCTools import AppHelper
|
from PyObjCTools import AppHelper
|
||||||
|
|
||||||
@@ -94,7 +94,7 @@ class CartridgesApplication(Adw.Application):
|
|||||||
|
|
||||||
self.add_main_option_entries((search, launch))
|
self.add_main_option_entries((search, launch))
|
||||||
|
|
||||||
if sys.platform == "darwin":
|
if sys.platform.startswith("darwin"):
|
||||||
if settings := Gtk.Settings.get_default():
|
if settings := Gtk.Settings.get_default():
|
||||||
settings.props.gtk_decoration_layout = "close,minimize,maximize:"
|
settings.props.gtk_decoration_layout = "close,minimize,maximize:"
|
||||||
|
|
||||||
@@ -405,7 +405,7 @@ class CartridgesApplication(Adw.Application):
|
|||||||
f"app.{action[0]}" if scope == self else f"win.{action[0]}",
|
f"app.{action[0]}" if scope == self else f"win.{action[0]}",
|
||||||
(
|
(
|
||||||
tuple(s.replace("<primary>", "<meta>") for s in action[1])
|
tuple(s.replace("<primary>", "<meta>") for s in action[1])
|
||||||
if sys.platform == "darwin"
|
if sys.platform.startswith("darwin")
|
||||||
else action[1]
|
else action[1]
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user