diff options
author | Jaakko Keränen <jaakko.keranen@iki.fi> | 2021-08-02 14:59:15 +0300 |
---|---|---|
committer | Jaakko Keränen <jaakko.keranen@iki.fi> | 2021-08-02 14:59:15 +0300 |
commit | 037ff0807f92ebc650c02846ac2bc6ce3cdecdf4 (patch) | |
tree | ae1a5b323136b043e59aa8298fdfe68c2ef1638d /src | |
parent | eb2a59e2506ba77799d381420aba2ddedaaaa9b8 (diff) |
Added --tab-url option to print active tab's URL
IssueID #319
Diffstat (limited to 'src')
-rw-r--r-- | src/app.c | 10 | ||||
-rw-r--r-- | src/ipc.c | 2 |
2 files changed, 12 insertions, 0 deletions
@@ -581,6 +581,9 @@ static void communicateWithRunningInstance_App_(iApp *d, iProcessId instance, | |||
581 | else if (equal_CommandLineConstIterator(&i, "close-tab")) { | 581 | else if (equal_CommandLineConstIterator(&i, "close-tab")) { |
582 | appendCStr_String(cmds, "tabs.close\n"); | 582 | appendCStr_String(cmds, "tabs.close\n"); |
583 | } | 583 | } |
584 | else if (equal_CommandLineConstIterator(&i, "tab-url")) { | ||
585 | appendFormat_String(cmds, "ipc.active.url pid:%d\n", pid); | ||
586 | } | ||
584 | else if (equal_CommandLineConstIterator(&i, listTabUrls_CommandLineOption)) { | 587 | else if (equal_CommandLineConstIterator(&i, listTabUrls_CommandLineOption)) { |
585 | appendFormat_String(cmds, "ipc.list.urls pid:%d\n", pid); | 588 | appendFormat_String(cmds, "ipc.list.urls pid:%d\n", pid); |
586 | } | 589 | } |
@@ -658,6 +661,7 @@ static void init_App_(iApp *d, int argc, char **argv) { | |||
658 | defineValues_CommandLine(&d->args, listTabUrls_CommandLineOption, 0); | 661 | defineValues_CommandLine(&d->args, listTabUrls_CommandLineOption, 0); |
659 | defineValues_CommandLine(&d->args, openUrlOrSearch_CommandLineOption, 1); | 662 | defineValues_CommandLine(&d->args, openUrlOrSearch_CommandLineOption, 1); |
660 | defineValuesN_CommandLine(&d->args, "new-tab", 0, 1); | 663 | defineValuesN_CommandLine(&d->args, "new-tab", 0, 1); |
664 | defineValues_CommandLine(&d->args, "tab-url", 0); | ||
661 | defineValues_CommandLine(&d->args, "sw", 0); | 665 | defineValues_CommandLine(&d->args, "sw", 0); |
662 | defineValues_CommandLine(&d->args, "version;V", 0); | 666 | defineValues_CommandLine(&d->args, "version;V", 0); |
663 | } | 667 | } |
@@ -2772,6 +2776,12 @@ iBool handleCommand_App(const char *cmd) { | |||
2772 | } | 2776 | } |
2773 | return iTrue; | 2777 | return iTrue; |
2774 | } | 2778 | } |
2779 | else if (equal_Command(cmd, "ipc.active.url")) { | ||
2780 | write_Ipc(argLabel_Command(cmd, "pid"), | ||
2781 | collectNewFormat_String("%s\n", cstr_String(url_DocumentWidget(document_App()))), | ||
2782 | response_IpcWrite); | ||
2783 | return iTrue; | ||
2784 | } | ||
2775 | else if (equal_Command(cmd, "ipc.signal")) { | 2785 | else if (equal_Command(cmd, "ipc.signal")) { |
2776 | if (argLabel_Command(cmd, "raise")) { | 2786 | if (argLabel_Command(cmd, "raise")) { |
2777 | if (d->window && d->window->win) { | 2787 | if (d->window && d->window->win) { |
@@ -172,6 +172,7 @@ static void handleSignal_IpcResponse_(int sig) { | |||
172 | } | 172 | } |
173 | 173 | ||
174 | iBool write_Ipc(iProcessId pid, const iString *input, enum iIpcWrite type) { | 174 | iBool write_Ipc(iProcessId pid, const iString *input, enum iIpcWrite type) { |
175 | if (!pid) return iFalse; | ||
175 | iBool ok = iFalse; | 176 | iBool ok = iFalse; |
176 | iFile *f = newCStr_File(inputFilePath_(&ipc_, pid)); | 177 | iFile *f = newCStr_File(inputFilePath_(&ipc_, pid)); |
177 | if (open_File(f, text_FileMode | append_FileMode)) { | 178 | if (open_File(f, text_FileMode | append_FileMode)) { |
@@ -281,6 +282,7 @@ void listen_Ipc(void) { | |||
281 | } | 282 | } |
282 | 283 | ||
283 | iBool write_Ipc(iProcessId pid, const iString *input, enum iIpcWrite type) { | 284 | iBool write_Ipc(iProcessId pid, const iString *input, enum iIpcWrite type) { |
285 | if (!pid) return iFalse; | ||
284 | iUnused(type); | 286 | iUnused(type); |
285 | HANDLE slot = CreateFile(slotName_(pid), | 287 | HANDLE slot = CreateFile(slotName_(pid), |
286 | GENERIC_WRITE, | 288 | GENERIC_WRITE, |