1
0
Fork 0
mirror of https://github.com/davatorium/rofi.git synced 2024-11-18 13:54:36 -05:00

[ROFI] -e '-' reads from stdin

This commit is contained in:
Dave Davenport 2023-06-15 22:29:03 +02:00
parent 635fbd0464
commit 7814da7ee4
3 changed files with 25 additions and 2 deletions

View file

@ -1142,6 +1142,9 @@ cause slowdowns when set too high)
Pops up a message dialog (used internally for showing errors) with \fImessage\fP\&. Pops up a message dialog (used internally for showing errors) with \fImessage\fP\&.
Message can be multi-line. Message can be multi-line.
.PP
Passing \fB\fC-e -\fR reads (blocking) from standard in and displays this.
.SS File browser settings .SS File browser settings
.PP .PP
File browser behavior can be controlled via the following options: File browser behavior can be controlled via the following options:

View file

@ -740,6 +740,8 @@ cause slowdowns when set too high)
Pops up a message dialog (used internally for showing errors) with *message*. Pops up a message dialog (used internally for showing errors) with *message*.
Message can be multi-line. Message can be multi-line.
Passing `-e -` reads (blocking) from standard in and displays this.
### File browser settings ### File browser settings
File browser behavior can be controlled via the following options: File browser behavior can be controlled via the following options:

View file

@ -797,9 +797,27 @@ static gboolean startup(G_GNUC_UNUSED gpointer data) {
if (find_arg("-markup") >= 0) { if (find_arg("-markup") >= 0) {
markup = TRUE; markup = TRUE;
} }
// When we pass -, we read from stdin.
if (g_strcmp0(msg, "-") == 0) {
size_t index = 0, i = 0;
size_t length = 1024;
msg = malloc(length * sizeof(char));
while ((i = fread(&msg[index], 1, 1024, stdin))>0) {
index+=i;
length+=i;
msg = realloc(msg,length * sizeof(char));
}
if (!rofi_view_error_dialog(msg, markup)) { if (!rofi_view_error_dialog(msg, markup)) {
g_main_loop_quit(main_loop); g_main_loop_quit(main_loop);
} }
g_free(msg);
} else {
// Normal version
if (!rofi_view_error_dialog(msg, markup)) {
g_main_loop_quit(main_loop);
}
}
} else if (find_arg_str("-show", &sname) == TRUE) { } else if (find_arg_str("-show", &sname) == TRUE) {
int index = mode_lookup(sname); int index = mode_lookup(sname);
if (index < 0) { if (index < 0) {