[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[RP] PID support for format_string
From: |
Antti Nykänen |
Subject: |
[RP] PID support for format_string |
Date: |
Thu, 26 Jun 2008 16:57:16 +0300 |
User-agent: |
Mutt/1.5.17 (2007-11-01) |
Works for me(tm). %p expands to the contents of _NET_WM_PID, or if it
isn't set, to a single '?'.
- Antti
---
doc/ratpoison.1 | 2 ++
doc/ratpoison.texi | 2 ++
src/format.c | 14 ++++++++++++++
3 files changed, 18 insertions(+), 0 deletions(-)
diff --git a/doc/ratpoison.1 b/doc/ratpoison.1
index a110baf..aa0c806 100644
--- a/doc/ratpoison.1
+++ b/doc/ratpoison.1
@@ -655,6 +655,8 @@ The following substitutions happen in format:
.br
%i by the X Window ID,
.br
+%p by the process ID,
+.br
%l by the last access number,
.br
%M by the string \fBMaxsize\fP, if it specifies a maximum size,
diff --git a/doc/ratpoison.texi b/doc/ratpoison.texi
index a275c18..1f5891d 100644
--- a/doc/ratpoison.texi
+++ b/doc/ratpoison.texi
@@ -386,6 +386,8 @@ A unique number based on when the window was last accessed.
The higher
the number, the more recently it was accessed.
@item %n
The window number
address@hidden %p
+Process ID ('?' if _NET_WM_PID isn't set)
@item %s
Window status (current window, last window, etc)
@item %S
diff --git a/src/format.c b/src/format.c
index a5bbd64..0706f21 100644
--- a/src/format.c
+++ b/src/format.c
@@ -44,6 +44,7 @@ RP_FMT(screen);
RP_FMT(xinescreen);
RP_FMT(transient);
RP_FMT(maxsize);
+RP_FMT(pid);
struct fmt_item {
/* The format character */
@@ -63,6 +64,7 @@ struct fmt_item fmt_items[] = {
{ 'i', fmt_windowid },
{ 'l', fmt_lastaccess },
{ 'n', fmt_number },
+ { 'p', fmt_pid },
{ 's', fmt_status },
{ 'S', fmt_screen },
{ 't', fmt_name },
@@ -298,3 +300,15 @@ fmt_maxsize (rp_window_elem *elem, struct sbuf *buf)
if (elem->win->hints->flags & PMaxSize)
sbuf_concat (buf, "Maxsize");
}
+
+static void
+fmt_pid (rp_window_elem *elem, struct sbuf *buf)
+{
+ struct rp_child_info *info;
+
+ info = get_child_info (elem->win->w);
+ if (info)
+ sbuf_printf_concat (buf, "%d", info->pid);
+ else
+ sbuf_concat (buf, "?");
+}
--
1.5.6
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [RP] PID support for format_string,
Antti Nykänen <=