diff options
| author | Nathan Reiner <nathan@nathanreiner.xyz> | 2023-01-28 18:11:42 +0100 |
|---|---|---|
| committer | Nathan Reiner <nathan@nathanreiner.xyz> | 2023-01-28 18:11:42 +0100 |
| commit | e651d2636724cd6c5a55f3847d275f9be620db47 (patch) | |
| tree | 0622875cce0aa2ec85feb7060471eeedb2a28bdc | |
| parent | 8227a8d984a7d2e18acf70ff20d4dd30880ecc77 (diff) | |
add download capability
| -rw-r--r-- | config.hpp | 5 | ||||
| -rw-r--r-- | sb.cpp | 8 |
2 files changed, 13 insertions, 0 deletions
@@ -3,6 +3,11 @@ const char search_engine[] = "https://search.nathanreiner.xyz/search? const char dmenu_args[] = "-s 0 -b"; const unsigned scroll_speed = 100; +/* DOWNLOAD(URI) */ +#define DOWNLOAD(u) \ + const char *a[] = { "st", "-e", "curl", "-g", "-L", "-J", "-O", u, NULL }; \ + execvp(a[0], (char*const*)a); + #define MODIFIER Qt::ALT void register_shortcuts(QWidget *view) { @@ -166,6 +166,7 @@ void help(char *arg0) { exit(-1); } + int main(int argc, char **argv) { QApplication app(argc, argv); @@ -238,6 +239,13 @@ main(int argc, char **argv) { url_label.setText(url.toString()); }); + profile.connect(&profile, &QWebEngineProfile::downloadRequested, [&](QWebEngineDownloadItem *download) { + if (fork() == 0) { + std::string url = download->url().toString().toStdString(); + DOWNLOAD(url.c_str()); + } + }); + register_shortcuts(view); return app.exec(); |