Restructure project
This commit is contained in:
18
stable/pid/Makefile
Normal file
18
stable/pid/Makefile
Normal file
@@ -0,0 +1,18 @@
|
||||
UNAME_S := $(shell uname -s)
|
||||
ifeq ($(UNAME_S),Darwin)
|
||||
LINK_FLAGS := -fno-common -flat_namespace -bundle -undefined suppress
|
||||
else
|
||||
LINK_FLAGS := -shared -fpic
|
||||
endif
|
||||
|
||||
all: pid.so
|
||||
|
||||
%.so:%.o
|
||||
$(CC) $(LINK_FLAGS) -lprofanity -o $@ $^
|
||||
|
||||
%.o:%.c
|
||||
$(CC) $(INCLUDE) -D_GNU_SOURCE -D_BSD_SOURCE -fpic -g3 -O0 -std=c99 \
|
||||
-Wextra -pedantic -c -o $@ $<
|
||||
|
||||
clean:
|
||||
$(RM) pid.so
|
||||
39
stable/pid/pid.c
Normal file
39
stable/pid/pid.c
Normal file
@@ -0,0 +1,39 @@
|
||||
/*
|
||||
Simple plugin to display the PID of the Profanity process and its parent
|
||||
|
||||
Theme example in ~/.local/share/profanity/plugin_themes
|
||||
|
||||
[pid]
|
||||
self=bold_white
|
||||
parent=white
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <sys/types.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include <profapi.h>
|
||||
|
||||
void
|
||||
cmd_pid(char **args)
|
||||
{
|
||||
pid_t pid = getpid();
|
||||
pid_t ppid = getppid();
|
||||
char buf[50];
|
||||
sprintf(buf, "PID: %d", pid);
|
||||
prof_cons_show_themed("pid", "self", NULL, buf);
|
||||
sprintf(buf, "Parent PID: %d", ppid);
|
||||
prof_cons_show_themed("pid", "parent", NULL, buf);
|
||||
prof_cons_alert();
|
||||
}
|
||||
|
||||
void
|
||||
prof_init(const char * const version, const char * const status, const char *const account_name, const char *const fulljid)
|
||||
{
|
||||
char *synopsis[] = { "/pid", NULL };
|
||||
char *description = "Show process ID and parent Process ID in the console window.";
|
||||
char *args[][2] = { { NULL, NULL } };
|
||||
char *examples[] = { NULL };
|
||||
|
||||
prof_register_command("/pid", 0, 0, synopsis, description, args, examples, cmd_pid);
|
||||
}
|
||||
Reference in New Issue
Block a user