From b6987e0e5f5e780a69406bdf170befa251ae366f Mon Sep 17 00:00:00 2001 From: jialeens Date: Wed, 16 Sep 2020 15:35:35 +0800 Subject: [PATCH] Accept write-pid-path option from the config file Signed-off-by: jialeens --- man/picom.1.asciidoc | 2 +- src/config_libconfig.c | 9 +++++++++ src/options.c | 4 ++++ 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/man/picom.1.asciidoc b/man/picom.1.asciidoc index f4a53d03..01ebeeb8 100644 --- a/man/picom.1.asciidoc +++ b/man/picom.1.asciidoc @@ -86,7 +86,7 @@ OPTIONS Look for configuration file at the path. See *CONFIGURATION FILES* section below for where picom looks for a configuration file by default. Use `/dev/null` to avoid loading configuration file. *--write-pid-path* 'PATH':: - Write process ID to a file. + Write process ID to a file. it is recommended to use an absolute path. *--shadow-red* 'VALUE':: Red color value of shadow (0.0 - 1.0, defaults to 0). diff --git a/src/config_libconfig.c b/src/config_libconfig.c index 659ff867..f18a44ee 100644 --- a/src/config_libconfig.c +++ b/src/config_libconfig.c @@ -634,6 +634,15 @@ char *parse_config_libconfig(options_t *opt, const char *config_file, bool *shad config_setting_lookup_float(blur_cfg, "deviation", &opt->blur_deviation); } + // --write-pid-path + if (config_lookup_string(&cfg, "write-pid-path", &sval)) { + if (*sval != '/') { + log_warn("The write-pid-path in your configuration file is not" + " an absolute path"); + } + opt->write_pid_path = strdup(sval); + } + // Wintype settings // XXX ! Refactor all the wintype_* arrays into a struct diff --git a/src/options.c b/src/options.c index 436b82d6..81189e2e 100644 --- a/src/options.c +++ b/src/options.c @@ -782,7 +782,11 @@ bool get_cfg(options_t *opt, int argc, char *const *argv, bool shadow_enable, P_CASELONG(309, unredir_if_possible_delay); case 310: // --write-pid-path + free(opt->write_pid_path); opt->write_pid_path = strdup(optarg); + if (*opt->write_pid_path != '/') { + log_warn("--write-pid-path is not an absolute path"); + } break; P_CASEBOOL(311, vsync_use_glfinish); case 312: