From 9f04d824b78fb39d03d00dfc68860216857c7d97 Mon Sep 17 00:00:00 2001 From: Yuxuan Shui Date: Sun, 21 Aug 2022 14:57:39 +0100 Subject: [PATCH 1/2] Rename COMPTON_VERSION to PICOM_VERSION Signed-off-by: Yuxuan Shui --- meson.build | 2 +- src/dbus.c | 2 +- src/diagnostic.c | 2 +- src/options.c | 4 ++-- src/picom.c | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/meson.build b/meson.build index e333c317..0150a37c 100644 --- a/meson.build +++ b/meson.build @@ -15,7 +15,7 @@ if git.found() endif endif -add_global_arguments('-DCOMPTON_VERSION="'+version+'"', language: 'c') +add_global_arguments('-DPICOM_VERSION="'+version+'"', language: 'c') if get_option('buildtype') == 'release' add_global_arguments('-DNDEBUG', language: 'c') diff --git a/src/dbus.c b/src/dbus.c index e0371671..8b17b30d 100644 --- a/src/dbus.c +++ b/src/dbus.c @@ -1153,7 +1153,7 @@ static bool cdbus_process_opts_get(session_t *ps, DBusMessage *msg) { // version if (!strcmp("version", target)) { - cdbus_reply_string(ps, msg, COMPTON_VERSION); + cdbus_reply_string(ps, msg, PICOM_VERSION); return true; } diff --git a/src/diagnostic.c b/src/diagnostic.c index d275b1a1..79ac5ac8 100644 --- a/src/diagnostic.c +++ b/src/diagnostic.c @@ -12,7 +12,7 @@ #include "common.h" void print_diagnostics(session_t *ps, const char *config_file, bool compositor_running) { - printf("**Version:** " COMPTON_VERSION "\n"); + printf("**Version:** " PICOM_VERSION "\n"); //printf("**CFLAGS:** %s\n", "??"); printf("\n### Extensions:\n\n"); printf("* Shape: %s\n", ps->shape_exists ? "Yes" : "No"); diff --git a/src/options.c b/src/options.c index 9f6888ff..9ec6e81b 100644 --- a/src/options.c +++ b/src/options.c @@ -26,7 +26,7 @@ static void usage(const char *argv0, int ret) { #define WARNING_DISABLED " (DISABLED AT COMPILE TIME)" static const char *usage_text = - "picom (" COMPTON_VERSION ")\n" + "picom (" PICOM_VERSION ")\n" "Please report bugs to https://github.com/yshui/picom\n\n" "usage: %s [options]\n" "Options:\n" @@ -495,7 +495,7 @@ bool get_early_config(int argc, char *const *argv, char **config_file, bool *all } else if (o == 314) { *all_xerrors = true; } else if (o == 318) { - printf("%s\n", COMPTON_VERSION); + printf("%s\n", PICOM_VERSION); return true; } else if (o == '?' || o == ':') { usage(argv[0], 1); diff --git a/src/picom.c b/src/picom.c index e4a56077..fd693fc9 100644 --- a/src/picom.c +++ b/src/picom.c @@ -1092,7 +1092,7 @@ static int register_cm(session_t *ps) { ps->c, xcb_change_property_checked( ps->c, XCB_PROP_MODE_REPLACE, ps->reg_win, get_atom(ps->atoms, "COMPTON_VERSION"), XCB_ATOM_STRING, 8, - (uint32_t)strlen(COMPTON_VERSION), COMPTON_VERSION)); + (uint32_t)strlen(PICOM_VERSION), PICOM_VERSION)); if (e) { log_error_x_error(e, "Failed to set COMPTON_VERSION."); free(e); From 59de702ea8b1d4e7376c1fe01a9bbf7e841c9684 Mon Sep 17 00:00:00 2001 From: Yuxuan Shui Date: Sun, 21 Aug 2022 15:07:44 +0100 Subject: [PATCH 2/2] options: improve usage message printing Laying the usage message out by hand is tedious, also error prone because the option names are duplicated at 2 places and have to be consistent. Create a struct to hold the option names and help messages, and do layout programmatically. Signed-off-by: Yuxuan Shui --- src/options.c | 713 +++++++++++++++++++------------------------------- 1 file changed, 272 insertions(+), 441 deletions(-) diff --git a/src/options.c b/src/options.c index 9ec6e81b..ba7485dd 100644 --- a/src/options.c +++ b/src/options.c @@ -7,6 +7,8 @@ #include #include #include +#include +#include #include #include // for xcb_render_fixed_t, XXX @@ -20,460 +22,289 @@ #pragma GCC diagnostic error "-Wunused-parameter" +struct picom_option { + const char *long_name; + int has_arg; + int val; + const char *arg_name; + const char *help; +}; + +// clang-format off +static const struct option *longopts = NULL; +static const struct picom_option picom_options[] = { +#ifdef CONFIG_LIBCONFIG + {"config" , required_argument, 256, NULL , "Path to the configuration file."}, +#endif + {"help" , no_argument , 'h', NULL , "Print this help message and exit."}, + {"shadow-radius" , required_argument, 'r', NULL , "The blur radius for shadows. (default 12)"}, + {"shadow-opacity" , required_argument, 'o', NULL , "The translucency for shadows. (default .75)"}, + {"shadow-offset-x" , required_argument, 'l', NULL , "The left offset for shadows. (default -15)"}, + {"shadow-offset-y" , required_argument, 't', NULL , "The top offset for shadows. (default -15)"}, + {"fade-in-step" , required_argument, 'I', NULL , "Opacity change between steps while fading in. (default 0.028)"}, + {"fade-out-step" , required_argument, 'O', NULL , "Opacity change between steps while fading out. (default 0.03)"}, + {"fade-delta" , required_argument, 'D', NULL , "The time between steps in a fade in milliseconds. (default 10)"}, + {"menu-opacity" , required_argument, 'm', NULL , "The opacity for menus. (default 1.0)"}, + {"shadow" , no_argument , 'c', NULL , "Enabled client-side shadows on windows."}, + {"clear-shadow" , no_argument , 'z', NULL , "Don't dreaw shadow behind the window."}, + {"fading" , no_argument , 'f', NULL , "Fade windows in/out when opening/closing and when opacity changes, " + "unless --no-fading-openclose is used."}, + {"inactive-opacity" , required_argument, 'i', NULL , "Opacity of inactive windows. (0.1 - 1.0)"}, + {"frame-opacity" , required_argument, 'e', NULL , "Opacity of window titlebars and borders. (0.1 - 1.0)"}, + {"daemon" , no_argument , 'b', NULL , "Daemonize process."}, + {"shadow-red" , required_argument, 257, NULL , "Red color value of shadow (0.0 - 1.0, defaults to 0)."}, + {"shadow-green" , required_argument, 258, NULL , "Green color value of shadow (0.0 - 1.0, defaults to 0)."}, + {"shadow-blue" , required_argument, 259, NULL , "Blue color value of shadow (0.0 - 1.0, defaults to 0)."}, + {"inactive-opacity-override" , no_argument , 260, NULL , "Inactive opacity set by -i overrides value of _NET_WM_WINDOW_OPACITY."}, + {"inactive-dim" , required_argument, 261, NULL , "Dim inactive windows. (0.0 - 1.0, defaults to 0)"}, + {"mark-wmwin-focused" , no_argument , 262, NULL , "Try to detect WM windows and mark them as active."}, + {"shadow-exclude" , required_argument, 263, NULL , "Exclude conditions for shadows."}, + {"mark-ovredir-focused" , no_argument , 264, NULL , "Mark windows that have no WM frame as active."}, + {"no-fading-openclose" , no_argument , 265, NULL , "Do not fade on window open/close."}, + {"shadow-ignore-shaped" , no_argument , 266, NULL , "Do not paint shadows on shaped windows. (Deprecated, use --shadow-exclude " + "\'bounding_shaped\' or --shadow-exclude \'bounding_shaped && " + "!rounded_corners\' instead.)"}, + {"detect-rounded-corners" , no_argument , 267, NULL , "Try to detect windows with rounded corners and don't consider them shaped " + "windows. Affects --shadow-ignore-shaped, --unredir-if-possible, and " + "possibly others. You need to turn this on manually if you want to match " + "against rounded_corners in conditions."}, + {"detect-client-opacity" , no_argument , 268, NULL , "Detect _NET_WM_WINDOW_OPACITY on client windows, useful for window " + "managers not passing _NET_WM_WINDOW_OPACITY of client windows to frame"}, + {"refresh-rate" , required_argument, 269, NULL , NULL}, + {"vsync" , optional_argument, 270, NULL , "Enable VSync"}, + {"sw-opti" , no_argument , 274, NULL , NULL}, + {"vsync-aggressive" , no_argument , 275, NULL , NULL}, + {"use-ewmh-active-win" , no_argument , 276, NULL , "Use _NET_WM_ACTIVE_WINDOW on the root window to determine which window is " + "focused instead of using FocusIn/Out events"}, + {"respect-prop-shadow" , no_argument , 277, NULL , NULL}, + {"unredir-if-possible" , no_argument , 278, NULL , "Unredirect all windows if a full-screen opaque window is detected, to " + "maximize performance for full-screen applications."}, + {"focus-exclude" , required_argument, 279, "COND" , "Specify a list of conditions of windows that should always be considered focused."}, + {"inactive-dim-fixed" , no_argument , 280, NULL , "Use fixed inactive dim value."}, + {"detect-transient" , no_argument , 281, NULL , "Use WM_TRANSIENT_FOR to group windows, and consider windows in the same " + "group focused at the same time."}, + {"detect-client-leader" , no_argument , 282, NULL , "Use WM_CLIENT_LEADER to group windows, and consider windows in the same group " + "focused at the same time. This usually means windows from the same application " + "will be considered focused or unfocused at the same time. WM_TRANSIENT_FOR has " + "higher priority if --detect-transient is enabled, too."}, + {"blur-background" , no_argument , 283, NULL , "Blur background of semi-transparent / ARGB windows. May impact performance"}, + {"blur-background-frame" , no_argument , 284, NULL , "Blur background of windows when the window frame is not opaque. Implies " + "--blur-background."}, + {"blur-background-fixed" , no_argument , 285, NULL , "Use fixed blur strength instead of adjusting according to window opacity."}, +#ifdef CONFIG_DBUS + {"dbus" , no_argument , 286, NULL , "Enable remote control via D-Bus. See the D-BUS API section in the man page " + "for more details."}, +#endif + {"logpath" , required_argument, 287, NULL , NULL}, + {"invert-color-include" , required_argument, 288, "COND" , "Specify a list of conditions of windows that should be painted with " + "inverted color."}, + {"opengl" , no_argument , 289, NULL , NULL}, + {"backend" , required_argument, 290, NULL , "Backend. Possible values are: xrender" +#ifdef CONFIG_OPENGL + ", glx" +#endif + }, + {"glx-no-stencil" , no_argument , 291, NULL , NULL}, + {"benchmark" , required_argument, 293, NULL , "Benchmark mode. Repeatedly paint until reaching the specified cycles."}, + {"benchmark-wid" , required_argument, 294, NULL , "Specify window ID to repaint in benchmark mode. If omitted or is 0, the whole" + " screen is repainted."}, + {"blur-background-exclude" , required_argument, 296, "COND" , "Exclude conditions for background blur."}, + {"active-opacity" , required_argument, 297, NULL , "Default opacity for active windows. (0.0 - 1.0)"}, + {"glx-no-rebind-pixmap" , no_argument , 298, NULL , NULL}, + {"glx-swap-method" , required_argument, 299, NULL , NULL}, + {"fade-exclude" , required_argument, 300, "COND" , "Exclude conditions for fading."}, + {"blur-kern" , required_argument, 301, NULL , "Specify the blur convolution kernel, see man page for more details"}, + {"resize-damage" , required_argument, 302, NULL , NULL}, // only used by legacy backends + {"glx-use-gpushader4" , no_argument , 303, NULL , NULL}, + {"opacity-rule" , required_argument, 304, "OPACITY:COND", "Specify a list of opacity rules, see man page for more details"}, + {"shadow-exclude-reg" , required_argument, 305, NULL , NULL}, + {"paint-exclude" , required_argument, 306, NULL , NULL}, + {"xinerama-shadow-crop" , no_argument , 307, NULL , "Crop shadow of a window fully on a particular Xinerama screen to the screen."}, + {"unredir-if-possible-exclude" , required_argument, 308, "COND" , "Conditions of windows that shouldn't be considered full-screen for " + "unredirecting screen."}, + {"unredir-if-possible-delay" , required_argument, 309, NULL, "Delay before unredirecting the window, in milliseconds. Defaults to 0."}, + {"write-pid-path" , required_argument, 310, "PATH" , "Write process ID to a file."}, + {"vsync-use-glfinish" , no_argument , 311, NULL , NULL}, + {"xrender-sync-fence" , no_argument , 313, NULL , "Additionally use X Sync fence to sync clients' draw calls. Needed on " + "nvidia-drivers with GLX backend for some users."}, + {"show-all-xerrors" , no_argument , 314, NULL , NULL}, + {"no-fading-destroyed-argb" , no_argument , 315, NULL , "Do not fade destroyed ARGB windows with WM frame. Workaround bugs in Openbox, " + "Fluxbox, etc."}, + {"force-win-blend" , no_argument , 316, NULL , "Force all windows to be painted with blending. Useful if you have a custom " + "shader that could turn opaque pixels transparent."}, + {"glx-fshader-win" , required_argument, 317, NULL , NULL}, + {"version" , no_argument , 318, NULL , "Print version number and exit."}, + {"no-x-selection" , no_argument , 319, NULL , NULL}, + {"log-level" , required_argument, 321, NULL , "Log level, possible values are: trace, debug, info, warn, error"}, + {"log-file" , required_argument, 322, NULL , "Path to the log file."}, + {"use-damage" , no_argument , 323, NULL , "Render only the damaged (changed) part of the screen"}, + {"no-use-damage" , no_argument , 324, NULL , "Disable the use of damage information. This cause the whole screen to be" + "redrawn everytime, instead of the part of the screen that has actually " + "changed. Potentially degrades the performance, but might fix some artifacts."}, + {"no-vsync" , no_argument , 325, NULL , "Disable VSync"}, + {"max-brightness" , required_argument, 326, NULL , "Dims windows which average brightness is above this threshold. Requires " + "--no-use-damage. (default: 1.0, meaning no dimming)"}, + {"transparent-clipping" , no_argument , 327, NULL , "Make transparent windows clip other windows like non-transparent windows do, " + "instead of blending on top of them"}, + {"transparent-clipping-exclude", required_argument, 338, "COND" , "Specify a list of conditions of windows that should never have " + "transparent clipping applied. Useful for screenshot tools, where you " + "need to be able to see through transparent parts of the window."}, + {"blur-method" , required_argument, 328, NULL , "The algorithm used for background bluring. Available choices are: 'none' to " + "disable, 'gaussian', 'box' or 'kernel' for custom convolution blur with " + "--blur-kern. Note: 'gaussian' and 'box' is not supported by --legacy-backends."}, + {"blur-size" , required_argument, 329, NULL , "The radius of the blur kernel for 'box' and 'gaussian' blur method."}, + {"blur-deviation" , required_argument, 330, NULL , "The standard deviation for the 'gaussian' blur method."}, + {"blur-strength" , required_argument, 331, NULL , "The strength level of the 'dual_kawase' blur method."}, + {"shadow-color" , required_argument, 332, NULL , "Color of shadow, as a hex RGB string (defaults to #000000)"}, + {"corner-radius" , required_argument, 333, NULL , "Sets the radius of rounded window corners. When > 0, the compositor will " + "round the corners of windows. (defaults to 0)."}, + {"rounded-corners-exclude" , required_argument, 334, "COND" , "Exclude conditions for rounded corners."}, + {"clip-shadow-above" , required_argument, 335, NULL , "Specify a list of conditions of windows to not paint a shadow over, such " + "as a dock window."}, + {"window-shader-fg" , required_argument, 336, "PATH" , "Specify GLSL fragment shader path for rendering window contents. Does not" + " work when `--legacy-backends` is enabled. See man page for more details."}, + {"window-shader-fg-rule" , required_argument, 337, "PATH:COND" , "Specify GLSL fragment shader path for rendering window contents using " + "patterns. Pattern should be in the format of SHADER_PATH:PATTERN, " + "similar to --opacity-rule. SHADER_PATH can be \"default\", in which case " + "the default shader will be used. Does not work when --legacy-backends is " + "enabled. See man page for more details"}, + {"legacy-backends" , no_argument , 733, NULL , "Use deprecated version of the backends."}, + {"monitor-repaint" , no_argument , 800, NULL , "Highlight the updated area of the screen. For debugging."}, + {"diagnostics" , no_argument , 801, NULL , "Print diagnostic information"}, + {"debug-mode" , no_argument , 802, NULL , "Render into a separate window, and don't take over the screen. Useful when " + "you want to attach a debugger to picom"}, + {"no-ewmh-fullscreen" , no_argument , 803, NULL , "Do not use EWMH to detect fullscreen windows. Reverts to checking if a " + "window is fullscreen based only on its size and coordinates."}, +}; +// clang-format on + +static void setup_longopts(void) { + auto opts = ccalloc(ARR_SIZE(picom_options) + 1, struct option); + for (size_t i = 0; i < ARR_SIZE(picom_options); i++) { + opts[i].name = picom_options[i].long_name; + opts[i].has_arg = picom_options[i].has_arg; + opts[i].flag = NULL; + opts[i].val = picom_options[i].val; + } + longopts = opts; +} + +void print_help(const char *help, size_t indent, size_t curr_indent, size_t line_wrap, + FILE *f) { + if (curr_indent > indent) { + fputs("\n", f); + curr_indent = 0; + } + + if (line_wrap - indent <= 1) { + line_wrap = indent + 2; + } + + size_t pos = 0; + size_t len = strlen(help); + while (pos < len) { + fprintf(f, "%*s", (int)(indent - curr_indent), ""); + curr_indent = 0; + size_t towrite = line_wrap - indent; + while (help[pos] == ' ') { + pos++; + } + if (pos + towrite > len) { + towrite = len - pos; + fwrite(help + pos, 1, towrite, f); + } else { + auto space_break = towrite; + while (space_break > 0 && help[pos + space_break - 1] != ' ') { + space_break--; + } + + bool print_hyphen = false; + if (space_break == 0) { + print_hyphen = true; + towrite--; + } else { + towrite = space_break; + } + + fwrite(help + pos, 1, towrite, f); + + if (print_hyphen) { + fputs("-", f); + } + } + + fputs("\n", f); + pos += towrite; + } +} + /** * Print usage text. */ static void usage(const char *argv0, int ret) { -#define WARNING_DISABLED " (DISABLED AT COMPILE TIME)" - static const char *usage_text = - "picom (" PICOM_VERSION ")\n" - "Please report bugs to https://github.com/yshui/picom\n\n" - "usage: %s [options]\n" - "Options:\n" - "\n" - "-r radius\n" - " The blur radius for shadows. (default 12)\n" - "\n" - "-o opacity\n" - " The translucency for shadows. (default .75)\n" - "\n" - "-l left-offset\n" - " The left offset for shadows. (default -15)\n" - "\n" - "-t top-offset\n" - " The top offset for shadows. (default -15)\n" - "\n" - "-I fade-in-step\n" - " Opacity change between steps while fading in. (default 0.028)\n" - "\n" - "-O fade-out-step\n" - " Opacity change between steps while fading out. (default 0.03)\n" - "\n" - "-D fade-delta-time\n" - " The time between steps in a fade in milliseconds. (default 10)\n" - "\n" - "-m opacity\n" - " The opacity for menus. (default 1.0)\n" - "\n" - "-c\n" - " Enabled client-side shadows on windows.\n" - "\n" - "-C\n" - " Avoid drawing shadows on dock/panel windows.\n" - "\n" - "-z\n" - " Zero the part of the shadow's mask behind the window.\n" - "\n" - "-f\n" - " Fade windows in/out when opening/closing and when opacity\n" - " changes, unless --no-fading-openclose is used.\n" - "\n" - "-F\n" - " Equals to -f. Deprecated.\n" - "\n" - "-i opacity\n" - " Opacity of inactive windows. (0.1 - 1.0)\n" - "\n" - "-e opacity\n" - " Opacity of window titlebars and borders. (0.1 - 1.0)\n" - "\n" - "-G\n" - " Don't draw shadows on DND windows\n" - "\n" - "-b\n" - " Daemonize process.\n" - "\n" - "--show-all-xerrors\n" - " Show all X errors (for debugging).\n" - "\n" - "--config path\n" - " Look for configuration file at the path. Use /dev/null to avoid\n" - " loading configuration file." -#ifndef CONFIG_LIBCONFIG - WARNING_DISABLED -#endif - "\n\n" - "--write-pid-path path\n" - " Write process ID to a file.\n" - "\n" - "--shadow-color color\n" - " Color of shadow, as a hex RGB string (defaults to #000000)\n" - "\n" - "--shadow-red value\n" - " Red color value of shadow (0.0 - 1.0, defaults to 0).\n" - "\n" - "--shadow-green value\n" - " Green color value of shadow (0.0 - 1.0, defaults to 0).\n" - "\n" - "--shadow-blue value\n" - " Blue color value of shadow (0.0 - 1.0, defaults to 0).\n" - "\n" - "--inactive-opacity-override\n" - " Inactive opacity set by -i overrides value of _NET_WM_WINDOW_OPACITY.\n" - "\n" - "--inactive-dim value\n" - " Dim inactive windows. (0.0 - 1.0, defaults to 0)\n" - "\n" - "--active-opacity opacity\n" - " Default opacity for active windows. (0.0 - 1.0)\n" - "\n" - "--corner-radius value\n" - " Sets the radius of rounded window corners. When > 0, the compositor\n" - " will round the corners of windows. (defaults to 0).\n" - "\n" - "--rounded-corners-exclude condition\n" - " Exclude conditions for rounded corners.\n" - "\n" - "--mark-wmwin-focused\n" - " Try to detect WM windows and mark them as active.\n" - "\n" - "--shadow-exclude condition\n" - " Exclude conditions for shadows.\n" - "\n" - "--fade-exclude condition\n" - " Exclude conditions for fading.\n" - "\n" - "--mark-ovredir-focused\n" - " Mark windows that have no WM frame as active.\n" - "\n" - "--no-fading-openclose\n" - " Do not fade on window open/close.\n" - "\n" - "--no-fading-destroyed-argb\n" - " Do not fade destroyed ARGB windows with WM frame. Workaround of bugs\n" - " in Openbox, Fluxbox, etc.\n" - "\n" - "--shadow-ignore-shaped\n" - " Do not paint shadows on shaped windows. (Deprecated, use\n" - " --shadow-exclude \'bounding_shaped\' or\n" - " --shadow-exclude \'bounding_shaped && !rounded_corners\' instead.)\n" - "\n" - "--detect-rounded-corners\n" - " Try to detect windows with rounded corners and don't consider\n" - " them shaped windows. Affects --shadow-ignore-shaped,\n" - " --unredir-if-possible, and possibly others. You need to turn this\n" - " on manually if you want to match against rounded_corners in\n" - " conditions.\n" - "\n" - "--detect-client-opacity\n" - " Detect _NET_WM_WINDOW_OPACITY on client windows, useful for window\n" - " managers not passing _NET_WM_WINDOW_OPACITY of client windows to frame\n" - " windows.\n" - "\n" - "--vsync\n" - " Enable VSync\n" - "\n" - "--use-ewmh-active-win\n" - " Use _NET_WM_ACTIVE_WINDOW on the root window to determine which\n" - " window is focused instead of using FocusIn/Out events.\n" - "\n" - "--unredir-if-possible\n" - " Unredirect all windows if a full-screen opaque window is\n" - " detected, to maximize performance for full-screen windows.\n" - "\n" - "--unredir-if-possible-delay ms\n" - " Delay before unredirecting the window, in milliseconds.\n" - " Defaults to 0.\n" - "\n" - "--unredir-if-possible-exclude condition\n" - " Conditions of windows that shouldn't be considered full-screen\n" - " for unredirecting screen.\n" - "\n" - "--focus-exclude condition\n" - " Specify a list of conditions of windows that should always be\n" - " considered focused.\n" - "\n" - "--inactive-dim-fixed\n" - " Use fixed inactive dim value.\n" - "\n" - "--max-brightness\n" - " Dims windows which average brightness is above this threshold.\n" - " Requires --no-use-damage.\n" - " Default: 1.0 or no dimming.\n" - "\n" - "--detect-transient\n" - " Use WM_TRANSIENT_FOR to group windows, and consider windows in\n" - " the same group focused at the same time.\n" - "\n" - "--detect-client-leader\n" - " Use WM_CLIENT_LEADER to group windows, and consider windows in\n" - " the same group focused at the same time. This usually means windows\n" - " from the same application will be considered focused or unfocused at\n" - " the same time. WM_TRANSIENT_FOR has higher priority if\n" - " --detect-transient is enabled, too.\n" - "\n" - "--blur-method\n" - " The algorithm used for background bluring. Available choices are:\n" - " 'none' to disable, 'gaussian', 'box' or 'kernel' for custom\n" - " convolution blur with --blur-kern.\n" - " Note: 'gaussian' and 'box' is not supported by --legacy-backends.\n" - "\n" - "--blur-size\n" - " The radius of the blur kernel for 'box' and 'gaussian' blur method.\n" - "\n" - "--blur-deviation\n" - " The standard deviation for the 'gaussian' blur method.\n" - "\n" - "--blur-strength\n" - " The strength level of the 'dual_kawase' blur method.\n" - "\n" - "--blur-background\n" - " Blur background of semi-transparent / ARGB windows. Bad in\n" - " performance. The switch name may change without prior\n" - " notifications.\n" - "\n" - "--blur-background-frame\n" - " Blur background of windows when the window frame is not opaque.\n" - " Implies --blur-background. Bad in performance. The switch name\n" - " may change.\n" - "\n" - "--blur-background-fixed\n" - " Use fixed blur strength instead of adjusting according to window\n" - " opacity.\n" - "\n" - "--blur-kern matrix\n" - " Specify the blur convolution kernel, with the following format:\n" - " WIDTH,HEIGHT,ELE1,ELE2,ELE3,ELE4,ELE5...\n" - " The element in the center must not be included, it will be forever\n" - " 1.0 or changing based on opacity, depending on whether you have\n" - " --blur-background-fixed.\n" - " A 7x7 Gaussian blur kernel looks like:\n" - " --blur-kern " - "'7,7,0.000003,0.000102,0.000849,0.001723,0.000849,0.000102,0.000003,0." - "000102,0.003494,0.029143,0.059106,0.029143,0.003494,0.000102,0.000849,0." - "029143,0.243117,0.493069,0.243117,0.029143,0.000849,0.001723,0.059106,0." - "493069,0.493069,0.059106,0.001723,0.000849,0.029143,0.243117,0.493069,0." - "243117,0.029143,0.000849,0.000102,0.003494,0.029143,0.059106,0.029143,0." - "003494,0.000102,0.000003,0.000102,0.000849,0.001723,0.000849,0.000102,0." - "000003'\n" - " Up to 4 blur kernels may be specified, separated with semicolon, for\n" - " multi-pass blur.\n" - " May also be one the predefined kernels: 3x3box (default), 5x5box,\n" - " 7x7box, 3x3gaussian, 5x5gaussian, 7x7gaussian, 9x9gaussian,\n" - " 11x11gaussian.\n" - "\n" - "--blur-background-exclude condition\n" - " Exclude conditions for background blur.\n" - "\n" - "--resize-damage integer\n" - " Resize damaged region by a specific number of pixels. A positive\n" - " value enlarges it while a negative one shrinks it. Useful for\n" - " fixing the line corruption issues of blur. May or may not\n" - " work with --glx-no-stencil. Shrinking doesn't function correctly.\n" - "\n" - "--invert-color-include condition\n" - " Specify a list of conditions of windows that should be painted with\n" - " inverted color. Resource-hogging, and is not well tested.\n" - "\n" - "--opacity-rule opacity:condition\n" - " Specify a list of opacity rules, in the format \"PERCENT:PATTERN\",\n" - " like \'50:name *= \"Firefox\"'. picom-trans is recommended over\n" - " this. Note we do not distinguish 100%% and unset, and we don't make\n" - " any guarantee about possible conflicts with other programs that set\n" - " _NET_WM_WINDOW_OPACITY on frame or client windows.\n" - "\n" - "--shadow-exclude-reg geometry\n" - " Specify a X geometry that describes the region in which shadow\n" - " should not be painted in, such as a dock window region.\n" - " Use --shadow-exclude-reg \'x10+0-0\', for example, if the 10 pixels\n" - " on the bottom of the screen should not have shadows painted on.\n" - "\n" - "--clip-shadow-above condition\n" - " Specify a list of conditions of windows to not paint a shadow over,\n" - " such as a dock window.\n" - "\n" - "--xinerama-shadow-crop\n" - " Crop shadow of a window fully on a particular Xinerama screen to the\n" - " screen.\n" - "\n" - "--backend backend\n" - " Choose backend. Possible choices are xrender, glx, and\n" - " xr_glx_hybrid." -#ifndef CONFIG_OPENGL - " (GLX BACKENDS DISABLED AT COMPILE TIME)" -#endif - "\n\n" - "--glx-no-stencil\n" - " GLX backend: Avoid using stencil buffer. Might cause issues\n" - " when rendering transparent content. My tests show a 15%% performance\n" - " boost.\n" - "\n" - "--glx-no-rebind-pixmap\n" - " GLX backend: Avoid rebinding pixmap on window damage. Probably\n" - " could improve performance on rapid window content changes, but is\n" - " known to break things on some drivers (LLVMpipe, xf86-video-intel,\n" - " etc.).\n" - "\n" - "--no-use-damage\n" - " Disable the use of damage information. This cause the whole screen to\n" - " be redrawn everytime, instead of the part of the screen that has\n" - " actually changed. Potentially degrades the performance, but might fix\n" - " some artifacts.\n" - "\n" - "--xrender-sync-fence\n" - " Additionally use X Sync fence to sync clients' draw calls. Needed\n" - " on nvidia-drivers with GLX backend for some users.\n" - "\n" - "--force-win-blend\n" - " Force all windows to be painted with blending. Useful if you have a\n" - " --glx-fshader-win that could turn opaque pixels transparent.\n" - "\n" - "--dbus\n" - " Enable remote control via D-Bus. See the D-BUS API section in the\n" - " man page for more details." -#ifndef CONFIG_DBUS - WARNING_DISABLED -#endif - "\n\n" - "--benchmark cycles\n" - " Benchmark mode. Repeatedly paint until reaching the specified cycles.\n" - "\n" - "--benchmark-wid window-id\n" - " Specify window ID to repaint in benchmark mode. If omitted or is 0,\n" - " the whole screen is repainted.\n" - "\n" - "--monitor-repaint\n" - " Highlight the updated area of the screen. For debugging the xrender\n" - " backend only.\n" - "\n" - "--debug-mode\n" - " Render into a separate window, and don't take over the screen. Useful\n" - " when you want to attach a debugger to picom\n" - "\n" - "--no-ewmh-fullscreen\n" - " Do not use EWMH to detect fullscreen windows. Reverts to checking\n" - " if a window is fullscreen based only on its size and coordinates.\n" - "\n" - "--transparent-clipping\n" - " Make transparent windows clip other windows like non-transparent windows\n" - " do, instead of blending on top of them\n" - "\n" - "--transparent-clipping-exclude condition\n" - " Specify a list of conditions of windows that should never have\n" - " transparent clipping applied. Useful for screenshot tools, where you\n" - " need to be able to see through transparent parts of the window.\n" - "\n" - "--window-shader-fg shader\n" - " Specify GLSL fragment shader path for rendering window contents. Does\n" - " not work when `--legacy-backends` is enabled.\n" - "\n" - "--window-shader-fg-rule shader:condition\n" - " Specify GLSL fragment shader path for rendering window contents using\n" - " patterns. Pattern should be in the format of `SHADER_PATH:PATTERN`,\n" - " similar to `--opacity-rule`. `SHADER_PATH` can be \"default\", in which\n" - " case the default shader will be used. Does not work when\n" - " `--legacy-backends` is enabled.\n"; FILE *f = (ret ? stderr : stdout); - fprintf(f, usage_text, argv0); -#undef WARNING_DISABLED + fprintf(f, "picom (%s)\n", PICOM_VERSION); + fprintf(f, "Standalone X11 compositor\n"); + fprintf(f, "Please report bugs to https://github.com/yshui/picom\n\n"); + + fprintf(f, "Usage: %s [OPTION]...\n\n", argv0); + fprintf(f, "OPTIONS:\n"); + + int line_wrap = 80; + struct winsize window_size = {0}; + if (ioctl(fileno(f), TIOCGWINSZ, &window_size) != -1) { + line_wrap = window_size.ws_col; + } + + size_t help_indent = 0; + for (size_t i = 0; i < ARR_SIZE(picom_options); i++) { + if (picom_options[i].help == NULL) { + // Hide options with no help message. + continue; + } + auto option_len = strlen(picom_options[i].long_name) + 2 + 4; + if (picom_options[i].arg_name) { + option_len += strlen(picom_options[i].arg_name) + 1; + } + if (option_len > help_indent && option_len < 30) { + help_indent = option_len; + } + } + help_indent += 6; + + for (size_t i = 0; i < ARR_SIZE(picom_options); i++) { + if (picom_options[i].help == NULL) { + continue; + } + size_t option_len = 8; + fprintf(f, " "); + if ((picom_options[i].val > 'a' && picom_options[i].val < 'z') || + (picom_options[i].val > 'A' && picom_options[i].val < 'Z')) { + fprintf(f, "-%c, ", picom_options[i].val); + } else { + fprintf(f, " "); + } + fprintf(f, "--%s", picom_options[i].long_name); + option_len += strlen(picom_options[i].long_name) + 2; + if (picom_options[i].arg_name) { + fprintf(f, "=%s", picom_options[i].arg_name); + option_len += strlen(picom_options[i].arg_name) + 1; + } + fprintf(f, " "); + option_len += 2; + print_help(picom_options[i].help, help_indent, option_len, + (size_t)line_wrap, f); + } } static const char *shortopts = "D:I:O:r:o:m:l:t:i:e:hscnfFCazGb"; -static const struct option longopts[] = { - {"help", no_argument, NULL, 'h'}, - {"config", required_argument, NULL, 256}, - {"shadow-radius", required_argument, NULL, 'r'}, - {"shadow-opacity", required_argument, NULL, 'o'}, - {"shadow-offset-x", required_argument, NULL, 'l'}, - {"shadow-offset-y", required_argument, NULL, 't'}, - {"fade-in-step", required_argument, NULL, 'I'}, - {"fade-out-step", required_argument, NULL, 'O'}, - {"fade-delta", required_argument, NULL, 'D'}, - {"menu-opacity", required_argument, NULL, 'm'}, - {"shadow", no_argument, NULL, 'c'}, - {"clear-shadow", no_argument, NULL, 'z'}, - {"fading", no_argument, NULL, 'f'}, - {"inactive-opacity", required_argument, NULL, 'i'}, - {"frame-opacity", required_argument, NULL, 'e'}, - {"daemon", no_argument, NULL, 'b'}, - {"shadow-red", required_argument, NULL, 257}, - {"shadow-green", required_argument, NULL, 258}, - {"shadow-blue", required_argument, NULL, 259}, - {"inactive-opacity-override", no_argument, NULL, 260}, - {"inactive-dim", required_argument, NULL, 261}, - {"mark-wmwin-focused", no_argument, NULL, 262}, - {"shadow-exclude", required_argument, NULL, 263}, - {"mark-ovredir-focused", no_argument, NULL, 264}, - {"no-fading-openclose", no_argument, NULL, 265}, - {"shadow-ignore-shaped", no_argument, NULL, 266}, - {"detect-rounded-corners", no_argument, NULL, 267}, - {"detect-client-opacity", no_argument, NULL, 268}, - {"refresh-rate", required_argument, NULL, 269}, - {"vsync", optional_argument, NULL, 270}, - {"sw-opti", no_argument, NULL, 274}, - {"vsync-aggressive", no_argument, NULL, 275}, - {"use-ewmh-active-win", no_argument, NULL, 276}, - {"respect-prop-shadow", no_argument, NULL, 277}, - {"unredir-if-possible", no_argument, NULL, 278}, - {"focus-exclude", required_argument, NULL, 279}, - {"inactive-dim-fixed", no_argument, NULL, 280}, - {"detect-transient", no_argument, NULL, 281}, - {"detect-client-leader", no_argument, NULL, 282}, - {"blur-background", no_argument, NULL, 283}, - {"blur-background-frame", no_argument, NULL, 284}, - {"blur-background-fixed", no_argument, NULL, 285}, - {"dbus", no_argument, NULL, 286}, - {"logpath", required_argument, NULL, 287}, - {"invert-color-include", required_argument, NULL, 288}, - {"opengl", no_argument, NULL, 289}, - {"backend", required_argument, NULL, 290}, - {"glx-no-stencil", no_argument, NULL, 291}, - {"benchmark", required_argument, NULL, 293}, - {"benchmark-wid", required_argument, NULL, 294}, - {"blur-background-exclude", required_argument, NULL, 296}, - {"active-opacity", required_argument, NULL, 297}, - {"glx-no-rebind-pixmap", no_argument, NULL, 298}, - {"glx-swap-method", required_argument, NULL, 299}, - {"fade-exclude", required_argument, NULL, 300}, - {"blur-kern", required_argument, NULL, 301}, - {"resize-damage", required_argument, NULL, 302}, - {"glx-use-gpushader4", no_argument, NULL, 303}, - {"opacity-rule", required_argument, NULL, 304}, - {"shadow-exclude-reg", required_argument, NULL, 305}, - {"paint-exclude", required_argument, NULL, 306}, - {"xinerama-shadow-crop", no_argument, NULL, 307}, - {"unredir-if-possible-exclude", required_argument, NULL, 308}, - {"unredir-if-possible-delay", required_argument, NULL, 309}, - {"write-pid-path", required_argument, NULL, 310}, - {"vsync-use-glfinish", no_argument, NULL, 311}, - {"xrender-sync-fence", no_argument, NULL, 313}, - {"show-all-xerrors", no_argument, NULL, 314}, - {"no-fading-destroyed-argb", no_argument, NULL, 315}, - {"force-win-blend", no_argument, NULL, 316}, - {"glx-fshader-win", required_argument, NULL, 317}, - {"version", no_argument, NULL, 318}, - {"no-x-selection", no_argument, NULL, 319}, - {"log-level", required_argument, NULL, 321}, - {"log-file", required_argument, NULL, 322}, - {"use-damage", no_argument, NULL, 323}, - {"no-use-damage", no_argument, NULL, 324}, - {"no-vsync", no_argument, NULL, 325}, - {"max-brightness", required_argument, NULL, 326}, - {"transparent-clipping", no_argument, NULL, 327}, - {"blur-method", required_argument, NULL, 328}, - {"blur-size", required_argument, NULL, 329}, - {"blur-deviation", required_argument, NULL, 330}, - {"blur-strength", required_argument, NULL, 331}, - {"shadow-color", required_argument, NULL, 332}, - {"corner-radius", required_argument, NULL, 333}, - {"rounded-corners-exclude", required_argument, NULL, 334}, - {"clip-shadow-above", required_argument, NULL, 335}, - {"window-shader-fg", required_argument, NULL, 336}, - {"window-shader-fg-rule", required_argument, NULL, 337}, - {"transparent-clipping-exclude", required_argument, NULL, 338}, - {"legacy-backends", no_argument, NULL, 733}, - {"monitor-repaint", no_argument, NULL, 800}, - {"diagnostics", no_argument, NULL, 801}, - {"debug-mode", no_argument, NULL, 802}, - {"no-ewmh-fullscreen", no_argument, NULL, 803}, - // Must terminate with a NULL entry - {NULL, 0, NULL, 0}, -}; /// Get config options that are needed to parse the rest of the options /// Return true if we should quit bool get_early_config(int argc, char *const *argv, char **config_file, bool *all_xerrors, bool *fork, int *exit_code) { + setup_longopts(); + int o = 0, longopt_idx = -1; // Pre-parse the commandline arguments to check for --config and invalid