diff options
author | Antti Nykänen <aon@iki.fi> | 2008-06-26 16:57:16 +0300 |
---|---|---|
committer | Shawn <sabetts@juicebox.(none)> | 2008-10-12 17:29:27 -0700 |
commit | 9ec3e80ad828e3eb35ce800b78fa73176d0d7c02 (patch) | |
tree | 5c9888f9b7e32744a4c88c39bc9a833765e47137 | |
parent | 656481bd1b052137826d041347bd0a93592b96a0 (diff) | |
download | ratpoison-9ec3e80ad828e3eb35ce800b78fa73176d0d7c02.zip |
PID support for format_string
-rw-r--r-- | doc/ratpoison.1 | 2 | ||||
-rw-r--r-- | doc/ratpoison.texi | 2 | ||||
-rw-r--r-- | src/format.c | 14 |
3 files changed, 18 insertions, 0 deletions
diff --git a/doc/ratpoison.1 b/doc/ratpoison.1 index c1cfc6d..d953965 100644 --- a/doc/ratpoison.1 +++ b/doc/ratpoison.1 @@ -660,6 +660,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 788c7f0..75a5e7a 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 +@item %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, "?"); +} |