scripts/waybar/toggle-visibility.c

31 lines
608 B
C
Raw Normal View History

#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <signal.h>
#include <ctype.h>
int main(int argc, char*argv[])
{
int pid;
if (argc <= 1) {
2023-01-06 19:41:31 +00:00
printf("No PID given\n");
return(1);
} else if (argc > 2) {
2023-01-06 19:41:31 +00:00
printf("Too many arguments\n");
return(1);
} else {
2023-01-06 19:41:31 +00:00
long val;
char *next;
val = strtol(argv[1], &next, 10);
if ((next == argv[1]) || (*next != '\0')) {
printf("Argument '%s' is not a number\n", argv[1]);
return(1);
} else {
pid = val;
}
}
kill(pid, SIGUSR1);
return(0);
}