[i3-discuss] Re: Spawning a background process from i3blocks

  • From: Ingo Bürk <admin@xxxxxxxxxxxx>
  • To: i3-discuss@xxxxxxxxxxxxx
  • Date: Tue, 14 Jun 2016 19:19:49 +0200

Hi Jean-Pierre,

xrandr-notify was a very short-lived tool I wrote and instantly deleted
again once I had a full night of sleep and realized that `xev -root
-event randr` would do the same. :-)

Basically, what I want to do is add a small block that lets me manage an
external output on click. I know there's autorandr and what not, but I
don't want to use that. I just want to have a simple click to activate
or deactivate the external monitor (and set it up correctly). You can
find my current, first (and draft) version at [1]. On top of that
script, I now have this in my i3 config:

exec_always --no-startup-id "pgrep --exact xev || xev -root -event randr
| grep --line-buffered ScreenChangeNotify | while read change; do pkill
-RTMIN+4 i3blocks; done"

But I'd just much rather have this be part of monitor.sh itself.


[1]
https://github.com/Airblader/dotfiles-manjaro/blob/master/scripts/monitor.sh


Ingo


On 06/14/2016 11:08 AM, Jean-Pierre Rivière wrote:

Hi,

I cannot help you but I'd like to know more essentially what you are
trying to achieve (not the technical details, but yous real life
goal). I cant find xrand-notify and xrandr has not a -notify option.

Thank you in advance,


2016-06-12 12:53 GMT+02:00 Ingo Bürk <admin@xxxxxxxxxxxx
<mailto:admin@xxxxxxxxxxxx>>:

    Hi,

    I am using i3blocks and want to write a blocklet for output
    management.
    In order to have the block be responsive, I use signals; and in
    order to
    send those signals, I need to start a background process:

      xrandr-notify | while read x; do pkill -RTMIN+4 i3blocks; done

    I would like to start this process from the also periodically executed
    block script itself (rather than, e.g., my i3 config), but of
    course it
    needs to be in the background. This is where I keep running into a
    wall:
    nothing seems to work. I've tried a variety of "… &", "nohup … &",
    "( …
    ) &", "{ … } &", "disown", … in all imaginable combinations.

    The problem is that when the script does background, the statusline in
    i3bar just freezes up. It has to be an i3bar problem because manually
    running i3blocks from the terminal still updates the output correctly.

    I'm hoping that maybe someone has a good idea of what's causing
    i3bar to
    freeze up when the executed statusline program spawns another child
    process and how I can fix it. Or perhaps it is an i3blocks issue
    afterall (though I don't expect it to be for the above reasons)?

    For reference, the blocklet script is structured something like this:

    if ! pgrep xrandr-notify; then

        xrandr-notify | while read x; do pkill -RTMIN+4 i3blocks; done &

    fi

    echo "lots of logic here"

    Any input is welcome. Thanks!


    Ingo





-- 
Jean-Pierre

Other related posts: