Xfce Forum

Sub domains
 

You are not logged in.

#1 2019-11-07 08:36:36

Skaperen
Member
From: surface of planet Earth
Registered: 2013-06-15
Posts: 455

how to determine when the panel is running

i would like to have a way for a script that continues to run after executing "dm-tool switch-to-user $auser" to determine when the xfce panel for that user is finally running and doing its thing.  if i can have the panel run another specified script, the latter could create a sentinel, such as a file of an agreed name.  the intent is to then repeat the process for the next user in a list until all such users are started.

i have been using fixed sleep times and guessing how long to sleep.  if the sleep time is too short, all of the various programs get hung during startup and unhung only when i switch to that user, again.  the result is that every window starts in the same workspace.  if i wait until the panel has started, i can switch away and everything starts slowly so workspace assignments work ok.  i think the exact need is to not switch away until the panel has set up the workspaces. the script is running under a different non-root user.

Offline

#2 2019-11-07 11:38:11

ToZ
Moderator
From: Canada
Registered: 2011-06-02
Posts: 5,969

Re: how to determine when the panel is running

How about something like:

while ! pgrep -f "xfce4-panel">/dev/null; do sleep 1s; done

This will loop, waiting, until xfce4-panel is registered as a running process.

Offline

#3 2019-11-08 05:44:56

Misko_2083
Member
Registered: 2015-10-13
Posts: 120
Website

Re: how to determine when the panel is running

I think this will do.
It will check if the _NET_WM_STRUT_PARTIAL of the each panel is set.

# Find Xwindow id's of all the window with named "xfce4-panel", skip the panel with the size +-9999+-9999
for XID in $(xwininfo -root -tree -children |  awk '/[Xx]fce4-[Pp]anel.*[Xx]fce4-[Pp]anel/ {if ($6!="+-9999+-9999") print $1}'); do

     # check if the window is the panel aka of type dock
    if [[ "$(xprop -id $XID _NET_WM_WINDOW_TYPE)" =~ "_NET_WM_WINDOW_TYPE_DOCK" ]]; then

        # check if the maximum size is set in the WM_NORMAL_HINTS, just in case the panel auto-hides
        # this check could be better
        xprop -id $XID WM_NORMAL_HINTS | grep -q 'program specified maximum size:' \
        && while [[ "$(xprop -id $XID _NET_WM_STRUT_PARTIAL)" == "_NET_WM_STRUT_PARTIAL:  not found." ]]; do
                  # sleep while STRUT_PARTIAL is "not found"
                   #Zzzzz
                   sleep 1
              done
    fi
done

On second thought, if you disabled the panel struts,
which is possible with the xfce4-panel, it would loop forever.

Maybe if it will work if you grep the ouput from xlsclients.
Checking if the panel is registered with X is simpler.

while ! xlsclients | grep -q xfce4-panel; do sleep 1;done

It all depends on timing when the panel struts are set.

Offline

Board footer

Powered by FluxBB