You are not logged in.

#1 2014-12-03 17:20:19

easysid
Member
From: India
Registered: 2013-01-01
Posts: 256

[SOLVED] Why are there two instances of this script

Maybe this question belongs in the bspwm thread, but to me this seems the right place to ask it.

Why does the panel script (bspwm_panel.sh) show two instances?

Here is the pstree branch

        ├─bspwm_panel.sh─┬─bar
        │                ├─bspc
        │                ├─bspwm_panel.sh   <-- this one
        │                ├─bspwm_panel_bar
        │                ├─conky───3*[{conky}]
        │                └─xtitle

The bspwm_panel.sh is the script to launch the panel, and bspwm_panel_bar.sh is the parser script for bar aint recursive.

here is bspwm_panel.sh. It gets launched from bspwmrc

#! /bin/sh

source $(dirname $0)/panel_config

if [ $(pgrep -cx bspwm_panel.sh) -gt 1 ] ; then
    printf "%s\n" "The panel is already running." >&2
    exit 1
fi

trap 'trap - TERM; kill 0' INT TERM QUIT EXIT

[ -e "$PANEL_FIFO" ] && rm "$PANEL_FIFO"
mkfifo "$PANEL_FIFO"

bspc control --subscribe > "$PANEL_FIFO" &
xtitle -sf 'T%s' > "$PANEL_FIFO" &
conky -c ~/Conky/bspwm_dec_conkyrc > "$PANEL_FIFO" &

bspwm_panel_bar.sh < "$PANEL_FIFO" \
     | bar -p \
           -g "$geometry" \
           -f "$FONT1","$FONT2" \
           -B "$BAR_BG" \
           -F "$BAR_FG" \
           | while read line; do eval "$line"; done &

wait

There shouls be one instance each of bspwm_panel.sh, and the bspwm_panel_bar.sh. What I do not get is where the second instance of panel script is coming from.

pgrep output

1617 /bin/sh /home/easysid/.scripts/bspwm_panel.sh
1624 /bin/sh /home/easysid/.scripts/bspwm_panel_bar.sh
1626 /bin/sh /home/easysid/.scripts/bspwm_panel.sh

Maybe its some aspect of wait that I am not familiar with.

Last edited by easysid (2014-12-03 18:34:14)

Offline

#2 2014-12-03 17:53:14

progandy
Member
Registered: 2012-05-17
Posts: 5,280

Re: [SOLVED] Why are there two instances of this script

You run a new subshell for the while-loop. This manifests as a forked thread in the pstree output. If you don't need that, remove the "&" and the "wait".

Last edited by progandy (2014-12-03 17:54:09)


| alias CUTF='LANG=en_XX.UTF-8@POSIX ' |

Offline

#3 2014-12-03 18:32:53

easysid
Member
From: India
Registered: 2013-01-01
Posts: 256

Re: [SOLVED] Why are there two instances of this script

Ah, ok

 while read line; do eval "$line"; done 

This pipe creates the second process. I guess it derives its name from the parent process.
Removing "&" and "wait" doesn't work, because the while-loop still shows up as a process. Removing the while-loop works and I get only two instances.
I need the while loop though, for clickable areas on bar. Thanks for resolving it.

I'll mark it as solved.

Offline

Board footer

Powered by FluxBB