Add a lot more FIFO options

This commit is contained in:
Jacob 2023-08-09 20:33:17 +02:00
parent d3798b90ff
commit 3be3e38be6
3 changed files with 140 additions and 1 deletions

View file

@ -756,10 +756,25 @@ for performance reasons.
| match | Match entries again, useful if you're loading items from file | | match | Match entries again, useful if you're loading items from file |
| update | Match and then draw the menu. Both drawmenu and match one after another | | update | Match and then draw the menu. Both drawmenu and match one after another |
| output | Output selected item text | | output | Output selected item text |
| output_index | Output selected item index | output_index | Output selected item index |
| loadconfig | Reload config | | loadconfig | Reload config |
| test | Print out 'Test print' to standard output | | test | Print out 'Test print' to standard output |
| die | Print out 'FIFO told me to die.' using the die() function | | die | Print out 'FIFO told me to die.' using the die() function |
| toggleinput | Toggle input |
| togglelarrow | Toggle left arrow |
| togglerarrow | Toggle right arrow |
| toggleitem | Toggle item |
| toggleprompt | Toggle prompt |
| togglecaps | Toggle caps lock indicator |
| togglepowerline | Toggle powerline |
| togglecaret | Toggle caret |
| togglehighlight | Toggle highlighting |
| togglematchcount | Toggle match count |
| togglemode | Toggle mode indicator |
| toggleregex | Toggle regex |
| togglefuzzy | Toggle fuzzy |
| toggleimg | Toggle images |
| toggleimgtype | Toggle image type |
| exit_0 | Exit with exit code 0 | | exit_0 | Exit with exit code 0 |
| exit_1 | Exit with exit code 1 | | exit_1 | Exit with exit code 1 |

View file

@ -23,6 +23,9 @@ void execute_fifo_cmd(void) {
return; return;
} }
/* These are the different commands that we can run
* by outputting text to the FIFO.
*/
if (!strcmp(fifot, "drawmenu")) { if (!strcmp(fifot, "drawmenu")) {
drawmenu(); drawmenu();
} else if (!strcmp(fifot, "match")) { } else if (!strcmp(fifot, "match")) {
@ -51,6 +54,51 @@ void execute_fifo_cmd(void) {
if (printindex && selecteditem) { if (printindex && selecteditem) {
fprintf(stdout, "%d\n", selecteditem->index); fprintf(stdout, "%d\n", selecteditem->index);
} }
} else if (!strcmp(fifot, "toggleinput")) {
Arg *arg;
toggleinput(arg);
} else if (!strcmp(fifot, "togglelarrow")) {
Arg *arg;
togglelarrow(arg);
} else if (!strcmp(fifot, "togglerarrow")) {
Arg *arg;
togglerarrow(arg);
} else if (!strcmp(fifot, "toggleitem")) {
Arg *arg;
toggleitem(arg);
} else if (!strcmp(fifot, "toggleprompt")) {
Arg *arg;
toggleprompt(arg);
} else if (!strcmp(fifot, "togglecaps")) {
Arg *arg;
togglecaps(arg);
} else if (!strcmp(fifot, "togglepowerline")) {
Arg *arg;
togglepowerline(arg);
} else if (!strcmp(fifot, "togglecaret")) {
Arg *arg;
togglecaret(arg);
} else if (!strcmp(fifot, "togglehighlight")) {
Arg *arg;
togglehighlight(arg);
} else if (!strcmp(fifot, "togglematchcount")) {
Arg *arg;
togglematchcount(arg);
} else if (!strcmp(fifot, "togglemode")) {
Arg *arg;
togglemode(arg);
} else if (!strcmp(fifot, "toggleregex")) {
Arg *arg;
toggleregex(arg);
} else if (!strcmp(fifot, "togglefuzzy")) {
Arg *arg;
togglefuzzy(arg);
} else if (!strcmp(fifot, "toggleimg")) {
Arg *arg;
toggleimg(arg);
} else if (!strcmp(fifot, "toggleimgtype")) {
Arg *arg;
toggleimgtype(arg);
} else if (!strcmp(fifot, "exit_0")) { } else if (!strcmp(fifot, "exit_0")) {
exit(0); exit(0);
} else if (!strcmp(fifot, "exit_1")) { } else if (!strcmp(fifot, "exit_1")) {
@ -75,6 +123,7 @@ void *fifocmd(void *n) {
} }
void init_fifo(void) { void init_fifo(void) {
remove(fifofile);
mkfifo(fifofile, 0666); mkfifo(fifofile, 0666);
pthread_t tid; pthread_t tid;

View file

@ -925,6 +925,81 @@ T}@T{
Print out `FIFO told me to die.' using the die() function Print out `FIFO told me to die.' using the die() function
T} T}
T{ T{
toggleinput
T}@T{
Toggle input
T}
T{
togglelarrow
T}@T{
Toggle left arrow
T}
T{
togglerarrow
T}@T{
Toggle right arrow
T}
T{
toggleitem
T}@T{
Toggle item
T}
T{
toggleprompt
T}@T{
Toggle prompt
T}
T{
togglecaps
T}@T{
Toggle caps lock indicator
T}
T{
togglepowerline
T}@T{
Toggle powerline
T}
T{
togglecaret
T}@T{
Toggle caret
T}
T{
togglehighlight
T}@T{
Toggle highlighting
T}
T{
togglematchcount
T}@T{
Toggle match count
T}
T{
togglemode
T}@T{
Toggle mode indicator
T}
T{
toggleregex
T}@T{
Toggle regex
T}
T{
togglefuzzy
T}@T{
Toggle fuzzy
T}
T{
toggleimg
T}@T{
Toggle images
T}
T{
toggleimgtype
T}@T{
Toggle image type
T}
T{
exit_0 exit_0
T}@T{ T}@T{
Exit with exit code 0 Exit with exit code 0