feat: validate whether geeqie is installed
This commit is contained in:
@@ -1,8 +1,17 @@
|
|||||||
import os
|
import os
|
||||||
import pathlib
|
import pathlib
|
||||||
|
import shutil
|
||||||
import subprocess
|
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:
|
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.
|
Open the specified file path with the default application associated with its file type.
|
||||||
|
|||||||
@@ -16,12 +16,19 @@ from textual.binding import BindingType
|
|||||||
from textual.widgets import Footer, Header, Label
|
from textual.widgets import Footer, Header, Label
|
||||||
|
|
||||||
from random_file_picker.core import collect_files, move_file_to_move_folder, upload_file
|
from random_file_picker.core import collect_files, move_file_to_move_folder, upload_file
|
||||||
from random_file_picker.openers import open_file_in_dolphin, open_file_with_default_app, open_file_with_geeqie
|
from random_file_picker.openers import (
|
||||||
|
is_geeqie_available,
|
||||||
|
open_file_in_dolphin,
|
||||||
|
open_file_with_default_app,
|
||||||
|
open_file_with_geeqie,
|
||||||
|
)
|
||||||
|
|
||||||
IMG_EXTENSIONS = [
|
IMG_EXTENSIONS = [
|
||||||
".jpg", ".jpeg", ".webp", ".png", ".gif",
|
".jpg", ".jpeg", ".webp", ".png", ".gif",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
GEEQIE_AVAILABLE = is_geeqie_available()
|
||||||
|
|
||||||
class Args(tap.TypedArgs):
|
class Args(tap.TypedArgs):
|
||||||
file_size: int = tap.arg("-s", default=10, help="Maximum file size in MB")
|
file_size: int = tap.arg("-s", default=10, help="Maximum file size in MB")
|
||||||
directory: str = tap.arg("-d", default=".", help="Directory to search for files")
|
directory: str = tap.arg("-d", default=".", help="Directory to search for files")
|
||||||
@@ -219,6 +226,10 @@ class MenuApp(App[None]):
|
|||||||
|
|
||||||
|
|
||||||
def main_with_tap(args: Args) -> None:
|
def main_with_tap(args: Args) -> None:
|
||||||
|
if args.use_geeqie and not GEEQIE_AVAILABLE:
|
||||||
|
print("❌ Geeqie is not available on this system. Please install it or run without --use-geeqie.")
|
||||||
|
return
|
||||||
|
|
||||||
app = MenuApp(
|
app = MenuApp(
|
||||||
directory=args.directory,
|
directory=args.directory,
|
||||||
file_limit=args.file_size,
|
file_limit=args.file_size,
|
||||||
|
|||||||
Reference in New Issue
Block a user