49 lines
1.4 KiB
Python
49 lines
1.4 KiB
Python
import os
|
|
import pathlib
|
|
import shutil
|
|
import subprocess
|
|
|
|
|
|
def is_geeqie_available() -> bool:
|
|
"""
|
|
Check if the Geeqie image viewer is available on the system.
|
|
|
|
:return: True if Geeqie is available, False otherwise.
|
|
"""
|
|
return shutil.which("geeqie") is not None
|
|
|
|
def open_file_with_default_app(file_path: pathlib.Path) -> bool:
|
|
"""
|
|
Open the specified file path with the default application associated with its file type.
|
|
|
|
:param file_path: The path of the file to be opened.
|
|
"""
|
|
process = subprocess.Popen(["/usr/bin/xdg-open", str(file_path)]) # noqa: S603
|
|
return process.wait() == 0 # xdg-open should instantly return, so we can check if it was successful
|
|
|
|
def open_file_with_geeqie(file_path: pathlib.Path):
|
|
"""
|
|
Open the specified file path with the Geeqie image viewer.
|
|
|
|
:param file_path: The path of the file to be opened.
|
|
"""
|
|
my_env = os.environ.copy()
|
|
my_env["GQ_DISABLE_CLUTTER"] = "y"
|
|
_ = subprocess.Popen(
|
|
[
|
|
"/usr/bin/geeqie",
|
|
# "-t",
|
|
"--file",
|
|
str(file_path),
|
|
],
|
|
env=my_env,
|
|
)
|
|
|
|
def open_file_in_dolphin(file_path: pathlib.Path):
|
|
"""
|
|
Open the specified file path in the Dolphin file manager and select the file.
|
|
|
|
:param file_path: The path of the file to be opened in Dolphin.
|
|
"""
|
|
subprocess.Popen(["/usr/bin/dolphin", "--select", str(file_path)])
|