mirror of
https://github.com/NikitaIvanovV/ctpv.git
synced 2024-12-18 08:10:38 +01:00
Use ctpvquit instead of cmd on-quit
cmd on-quit is not available in the latest lf release (r27)
This commit is contained in:
parent
2e314e10ea
commit
2bdeb6aad9
9
Makefile
9
Makefile
@ -25,7 +25,7 @@ options:
|
||||
|
||||
install: install.bin install.man
|
||||
|
||||
install.bin: ctpv ctpvclear
|
||||
install.bin: ctpv quit/ctpvquit ctpvclear
|
||||
$(INSTALL) -d $(BINPREFIX)
|
||||
$(INSTALL) $^ $(BINPREFIX)
|
||||
|
||||
@ -34,11 +34,13 @@ install.man: doc/ctpv.1
|
||||
$(INSTALL) -m 0644 $^ $(MANPREFIX)
|
||||
|
||||
uninstall:
|
||||
$(RM) $(BINPREFIX)/ctpv $(BINPREFIX)/ctpvclear $(MANPREFIX)/ctpv.1
|
||||
$(RM) $(BINPREFIX)/ctpv $(BINPREFIX)/ctpvclear $(BINPREFIX)/ctpvquit \
|
||||
$(MANPREFIX)/ctpv.1
|
||||
|
||||
clean:
|
||||
$(RM) ctpv $(OBJ) $(DEP) $(GEN)
|
||||
$(MAKE) -C embed clean
|
||||
$(MAKE) -C quit clean
|
||||
|
||||
docs: README.md doc/ctpv.1
|
||||
deptable/list.awk $(PRE) | deptable/markdown.sed | deptable/insert.awk README.md
|
||||
@ -70,6 +72,9 @@ gen:
|
||||
embed/embed: .force
|
||||
$(MAKE) -C embed
|
||||
|
||||
quit/ctpvquit: .force
|
||||
$(MAKE) -C quit
|
||||
|
||||
-include $(DEP)
|
||||
|
||||
.PHONY: all options install install.bin install.man uninstall \
|
||||
|
@ -96,16 +96,11 @@ yay -S ctpv-git
|
||||
Add these lines to your lf config
|
||||
(usually located at `~/.config/lf/lfrc`).
|
||||
|
||||
Note: `on-quit` command is not a part of
|
||||
[lf r27 release](https://github.com/gokcehan/lf/releases/tag/r27)
|
||||
yet, so I strongly suggest you to install the latest version [from the GitHub page][lf]
|
||||
(or [`lf-git`](https://aur.archlinux.org/packages/lf-git) AUR package if you use Arch Linux).
|
||||
|
||||
```
|
||||
set previewer ctpv
|
||||
set cleaner ctpvclear
|
||||
&ctpv -s $id
|
||||
cmd on-quit $ctpv -e $id
|
||||
&ctpvquit $id
|
||||
```
|
||||
|
||||
## Documentation
|
||||
|
@ -145,7 +145,7 @@ configuration file (usually located at
|
||||
set previewer ctpv
|
||||
set cleaner ctpvclear
|
||||
&ctpv -s $id
|
||||
cmd on-quit $ctpv -e $id
|
||||
&ctpvquit $id
|
||||
.EE
|
||||
.RE
|
||||
.
|
||||
|
6
quit/Makefile
Normal file
6
quit/Makefile
Normal file
@ -0,0 +1,6 @@
|
||||
ctpvquit: ctpvquit.c
|
||||
|
||||
clean:
|
||||
$(RM) ctpvquit
|
||||
|
||||
.PHONY: clean
|
48
quit/ctpvquit.c
Normal file
48
quit/ctpvquit.c
Normal file
@ -0,0 +1,48 @@
|
||||
#include <errno.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <signal.h>
|
||||
#include <unistd.h>
|
||||
|
||||
int main (int argc, char *argv[])
|
||||
{
|
||||
if (argc <= 1) {
|
||||
fprintf(stderr, "id not given\n");
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
char *pid_s = argv[1];
|
||||
|
||||
char *endptr;
|
||||
|
||||
errno = 0;
|
||||
long pid = strtol(pid_s, &endptr, 10);
|
||||
|
||||
if (errno != 0) {
|
||||
perror("strtol");
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
if (endptr == pid_s) {
|
||||
fprintf(stderr, "%s: invalid number\n", pid_s);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
while (1) {
|
||||
sleep(5);
|
||||
|
||||
if (kill(pid, 0) == -1) {
|
||||
if (errno != ESRCH) {
|
||||
perror("kill");
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
execlp("ctpv", "ctpv", "-e", pid_s, NULL);
|
||||
perror("execlp");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return EXIT_FAILURE;
|
||||
}
|
Loading…
Reference in New Issue
Block a user