From ec14d5f41251fadc03370c9cbe5f2e0bdb5ca9ff Mon Sep 17 00:00:00 2001 From: Harry Jeffery Date: Thu, 15 Aug 2019 21:53:54 +0100 Subject: imv: Add imv_pid environment variable --- doc/imv.1.txt | 3 +++ src/imv.c | 3 +++ 2 files changed, 6 insertions(+) diff --git a/doc/imv.1.txt b/doc/imv.1.txt index 6474036..98b4498 100644 --- a/doc/imv.1.txt +++ b/doc/imv.1.txt @@ -161,6 +161,9 @@ When imv executes a shell command, it provides a number of environment variables exposing imv's state. These environment variables are also available when customising the window's title, or the overlay text. +*$imv_pid*:: + The pid of this instance of imv. Useful for running imv-msg in scripts. + *$imv_current_file*:: Path of currently selected image. diff --git a/src/imv.c b/src/imv.c index 2d948fa..0f42371 100644 --- a/src/imv.c +++ b/src/imv.c @@ -1675,6 +1675,9 @@ static void update_env_vars(struct imv *imv) { char str[64]; + snprintf(str, sizeof str, "%d", getpid()); + setenv("imv_pid", str, 1); + setenv("imv_current_file", imv_navigator_selection(imv->navigator), 1); setenv("imv_scaling_mode", scaling_label[imv->scaling_mode], 1); setenv("imv_loading", imv->loading ? "1" : "0", 1); -- cgit v1.2.3