diff --git a/CMakeLists.txt b/CMakeLists.txt index a2708c2..5003e8f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -25,7 +25,7 @@ if (UNIX AND NOT APPLE) endif() include(FetchContent) -FetchContent_Declare(quartz GIT_REPOSITORY https://github.com/vimpostor/quartz.git GIT_TAG 9f1ac6cce6b338c6613aa195cffe6f0bb5c965df) +FetchContent_Declare(quartz GIT_REPOSITORY https://github.com/vimpostor/quartz.git GIT_TAG v0.7) FetchContent_MakeAvailable(quartz) list(APPEND LINK_LIBS ${PKGCONFIG_MODULES}) diff --git a/doc/man/man1/blobdrop.1 b/doc/man/man1/blobdrop.1 index a649f01..b1d5d5e 100644 --- a/doc/man/man1/blobdrop.1 +++ b/doc/man/man1/blobdrop.1 @@ -119,6 +119,22 @@ Using this option causes blobdrop to quit after the first drag operation has fin .SS "all" With this option blobdrop keeps track of which items have been dragged already. It quits when all paths have been dragged at least once. +.SH DEFAULT ARGUMENTS +The +.B $BLOBDROP_ARGS +environment variable can be used to provide default arguments. The default arguments will be prepended to the actually passed arguments, for example: +.PP +.in +2n +.EX +$ \fBBLOBDROP_ARGS\fP=\fI"\-f gui \-p"\fP \fBblobdrop\fP \-x \fInever\fP image.png +$ # is equivalent to: +$ \fBblobdrop\fP \-f \fIgui\fP \-p \-x \fInever\fP image.png +.EE +.in +.PP + +This can be useful to change the default value of some options permanently. + .SH EXAMPLES Here are some example usecases. diff --git a/flake.nix b/flake.nix index 3939f87..77b3d4e 100644 --- a/flake.nix +++ b/flake.nix @@ -15,7 +15,7 @@ owner = "vimpostor"; repo = "quartz"; rev = builtins.head (builtins.match ".*FetchContent_Declare\\(.*GIT_TAG ([[:alnum:]\\.]+).*" (builtins.readFile ./CMakeLists.txt)); - hash = "sha256-UacYQ5c+MGUK4saLohnZs4691CBGI59JpkdgCaYbPUk="; + hash = "sha256-cANBwVXcnWPaFE58lfbi53DUJ1mAmJL/p1hxoS5cX7s="; }; makeStdenvPkg = env: env.mkDerivation { pname = "blobdrop"; diff --git a/src/getopts.cpp b/src/getopts.cpp index d1fbf60..8f9e5e7 100644 --- a/src/getopts.cpp +++ b/src/getopts.cpp @@ -5,7 +5,12 @@ namespace Getopts { -bool parse(QCoreApplication &app) { +QStringList setup_args(int argc, char *argv[]) { + const auto *env = std::getenv("BLOBDROP_ARGS"); + return quartz::getopts::prepend_args(argc, argv, env); +} + +bool parse(const QStringList &args) { QCommandLineParser p; p.setApplicationDescription("Quickly drag and drop files from the terminal to applications."); p.addHelpOption(); @@ -49,7 +54,7 @@ bool parse(QCoreApplication &app) { "behaviour"); p.addOptions({frameless_opt, cursor_opt, frontend_opt, intercept_opt, keep_opt, persistent_opt, remote_opt, ontop_opt, auto_quit_opt}); - p.process(app); + p.process(args); if (p.isSet(auto_quit_opt)) { const auto opt = p.value(auto_quit_opt); @@ -90,5 +95,4 @@ bool parse(QCoreApplication &app) { std::ranges::for_each(p.positionalArguments(), [](auto i) { PathRegistry::get()->add_path(i.toStdString()); }); return true; } - } diff --git a/src/getopts.hpp b/src/getopts.hpp index 3450dce..cdaee6f 100644 --- a/src/getopts.hpp +++ b/src/getopts.hpp @@ -2,10 +2,13 @@ #include #include +#include #include "path_registry.hpp" #include "settings.hpp" namespace Getopts { -bool parse(QCoreApplication &app); + +QStringList setup_args(int argc, char *argv[]); +bool parse(const QStringList &args); } diff --git a/src/main.cpp b/src/main.cpp index 7e9b20d..d77fd5f 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -24,7 +24,8 @@ int main(int argc, char *argv[]) { quartz::Signals signal_handler {{SIGINT, SIGHUP, SIGTERM, SIGQUIT}, [](int) { Backend::get()->quit_delayed(0ms); }}; #endif - if (!Getopts::parse(app)) { + const auto &args = Getopts::setup_args(argc, argv); + if (!Getopts::parse(args)) { return EXIT_FAILURE; }