Merge branch 'master' into 3.3

This commit is contained in:
Jacob 2023-08-12 14:38:08 +00:00
commit 8d18633ac0
4 changed files with 21 additions and 8 deletions

View file

@ -20,6 +20,8 @@ void execute_fifo_cmd(void) {
if (!r) { if (!r) {
close(fd); close(fd);
done = 1;
return; return;
} }
@ -115,7 +117,7 @@ void execute_fifo_cmd(void) {
setlines(&arg); setlines(&arg);
} else if (!strcmp(fifot, "setcolumns+")) { } else if (!strcmp(fifot, "setcolumns+")) {
Arg arg; Arg arg;
arg.i = +1; arg.i = 1;
setcolumns(&arg); setcolumns(&arg);
} else if (!strcmp(fifot, "setcolumns-")) { } else if (!strcmp(fifot, "setcolumns-")) {
Arg arg; Arg arg;
@ -183,22 +185,24 @@ void execute_fifo_cmd(void) {
close(fd); close(fd);
remove(fifofile);
mkfifo(fifofile, 0660);
done = 1; done = 1;
} }
void *fifocmd(void *n) { void *fifocmd(void *n) {
for (;;) { for (;;) {
msleep(0.1);
if (done) { if (done) {
execute_fifo_cmd(); execute_fifo_cmd();
} }
msleep(0.1);
} }
} }
void init_fifo(void) { void init_fifo(void) {
mkfifo(fifofile, 0666); mkfifo(fifofile, 0660);
pthread_t tid; pthread_t tid;
pthread_create(&tid, NULL, &fifocmd, NULL); pthread_create(&tid, NULL, &fifocmd, NULL);
} }

View file

@ -162,7 +162,7 @@ exec_cmd() {
[ -z "$EXEC" ] && EXEC=shell [ -z "$EXEC" ] && EXEC=shell
[ "$STDOUT" != "false" ] && printf "%s\n" "$sout" && exit 1 [ "$STDOUT" != "false" ] && printf "%s\n" "$sout" && exit 1
if [ -d "$sout" ]; then if [ -d "$sout" ] && [ ! -f "$(command -v "$sout")" ]; then
load_x "spmenu_fm" load_x "spmenu_fm"
dir="$sout" dir="$sout"
prepare_dirnav prepare_dirnav

View file

@ -874,6 +874,12 @@ Otherwise it will be considered invalid.
It is recommended that you sleep for 0.1 seconds after appending to the It is recommended that you sleep for 0.1 seconds after appending to the
file for performance reasons. file for performance reasons.
.PP .PP
\f[B]NOTE: Please remove /tmp/spmenu.fifo if it exists after usage,
especially in scripts.
Otherwise the FIFO action may be carried over to the user\[cq]s next
spmenu use.
If you love your users, do not ignore this warning.\f[R]
.PP
.TS .TS
tab(@); tab(@);
lw(12.7n) lw(57.3n). lw(12.7n) lw(57.3n).

View file

@ -393,6 +393,10 @@ void cleanup(void) {
} }
#endif #endif
#if FIFO
remove(fifofile);
#endif
free(sel_index); free(sel_index);
} }
@ -555,11 +559,10 @@ void handle(void) {
init_appearance(); // init colorschemes by reading arrays init_appearance(); // init colorschemes by reading arrays
setupdisplay_x11(); // set up display and create window
#if FIFO #if FIFO
init_fifo(); init_fifo();
#endif #endif
setupdisplay_x11(); // set up display and create window
eventloop_x11(); // function is a loop which checks X11 events and calls other functions accordingly eventloop_x11(); // function is a loop which checks X11 events and calls other functions accordingly
#endif #endif
#if WAYLAND #if WAYLAND