Menu

#332 RFE: implement YAD_GEOMETRY environment variable.

New
nobody
None
High
Enhancement
2021-01-20
2021-01-20
No

Provide the current dialog's geometry for its children in a form of an environment variable, YAD_GEOMETRY=WxH-X-Y. (Certainly the value will match the start time of a child process only).

It is possible to obtain the info using YAD_XID variable and xwininfo command. But this way is suitable for x11 systems only, and is a bit complex (an extra command run etc.), whereas most cases for me when YAD_XID is used are just the calculation of some geometry of the parent window.

Such a variable cannot reflect the geometry changes (if any) during the life time of the child, but on practice such cases seem rare (but then YAD_XID/xwininfo can be used, as for now).

Unlike other YAD_ , the YAD_GEOMETRY must be calculated immediately before the run of a child command. It requires some changes in src/util.c:run_command_(a)sync() logic.

Discussion

  • Dmitry Butskoy

    Dmitry Butskoy - 2021-01-20

    Proposed patch.

    There is a recommendation not to use g_setenv() function directly, and use a proper envp array for g_spawn_(sync|async)(). The current code uses g_spawn_command_line_(sync|async)(), which do not handle envp argument. Fortunately, both functions are actually simple wrappers in glib2 code, which can be easy ported as needed.

    Thus in src/util.c there is new static function do_run_command(), and run_command_(sync|async) become just wrappers for it. (Note, last "if (!retval)" statement handles both possible cases).

    There is global src/main.c:yad_putenv_geometry(), to obtain the geometry info.

    The mention in manpage included as well.

     
  • Dmitry Butskoy

    Dmitry Butskoy - 2021-01-20

    Simple test case:

    ./yad --text=foo --use-interp='bash -c "%s"' --button='bar:echo $YAD_GEOMETRY'
    
     

Log in to post a comment.