You are not logged in.

#1 2016-08-01 14:56:45

aanastasiou
Member
Registered: 2016-05-05
Posts: 14

Strange behaviour for pipe menus

Hello everyone

I am having a bit of difficulty with pipe-menus which I cannot figure out the source of.

At the moment, I have a simple but slightly long menu structure for providing a set of applications to my users. In the future, parts of it are likely to become dynamic. Therefore, my immediate reaction was to create an XML template and have a Python script render it to stdout using jinja2.

So far so good. Now, the freaky part. If I render the template using

sys.stdout.write(myRenderedXMLContent)

, openbox complains that the script did not return a valid output. If i

print("<openbox_pipe_menu>")

(and so on), then the menu is rendered properly.

For more information, including an extensive list of things I have tried so far, please see this link

All the best
AA

Offline

#2 2016-08-01 15:34:56

xaos52
The Good Doctor
From: Planet of the @pes
Registered: 2015-09-30
Posts: 695

Re: Strange behaviour for pipe menus

Probably a problem with characters that need to be escaped:
See /usr/lib/bunsen/common/bl-include.cfg for how it is done in BL.

Offline

#3 2016-08-01 16:16:08

aanastasiou
Member
Registered: 2016-05-05
Posts: 14

Re: Strange behaviour for pipe menus

Thank you for the quick response. I have even added a bash script with

cat theTemplate.xml

and even

echo `cat theTemplate.xml`

and even that fails hmm I have diffed the files produced by each version and they differ only in one extra linefeed. Is there anything else that could be going out through stdout when openbox runs the process?

Offline

#4 2016-08-01 16:19:09

damo
....moderator....
Registered: 2015-08-20
Posts: 6,734

Re: Strange behaviour for pipe menus

Is there any difference in the way each method looks if the pipemenu is run on the commandline?


Be Excellent to Each Other...
The Bunsenlabs Lithium Desktop » Here
FORUM RULES and posting guidelines «» Help page for forum post formatting
Artwork on DeviantArt  «» BunsenLabs on DeviantArt

Offline

#5 2016-08-01 16:42:45

xaos52
The Good Doctor
From: Planet of the @pes
Registered: 2015-09-30
Posts: 695

Re: Strange behaviour for pipe menus

Can you run your script on the command line, and post the output here or give us a link to a pasteboard?

Here is a snippet of the output of an BL pipemenu (bl-kb-pipemenu):

            </action>
        </item>
        <item label="W-m                  bl-media-player">
            <action name="Execute">
                <command>
                    bl-media-player
                </command>
            </action>
        </item>
        <item label="W-h                  x-terminal-emulator -T &apos;htop task manager&apos; -e htop">
            <action name="Execute">
                <command>
                    x-terminal-emulator -T &apos;htop task manager&apos; -e htop
                </command>
            </action>
        </item>
        <item label="W-v                  pavucontrol">
            <action name="Execute">
                <command>
                    pavucontrol
                </command>
            </action>
        </item>
        <item label="W-x                  bl-exit">
            <action name="Execute">
                <command>
                    bl-exit
                </command>
            </action>
        </item>
    </menu>
    </openbox_pipe_menu>

Notice that the [data] portions - e.g. thet data between <command> and </command> - needs to have some characters escaped. Like ' has to be &apos;

Offline

#6 2016-08-02 03:04:29

johnraff
nullglob
From: Nagoya, Japan
Registered: 2015-09-09
Posts: 12,552
Website

Re: Strange behaviour for pipe menus

xaos52 wrote:

Probably a problem with characters that need to be escaped:
See /usr/lib/bunsen/common/bl-include.cfg for how it is done in BL.

That file contains a couple of small bash functions for escaping special xml characters: XMLescape() and OBlabelEscape()


...elevator in the Brain Hotel, broken down but just as well...
( a boring Japan blog (currently paused), now on Bluesky, there's also some GitStuff )

Introduction to the Bunsenlabs Boron Desktop

Offline

#7 2016-08-02 08:02:55

aanastasiou
Member
Registered: 2016-05-05
Posts: 14

Re: Strange behaviour for pipe menus

Many thanks to everyone for your replies and pointers. Yes, I got that, no worries, I don't have "special" characters, just a few dummy strings (Not even "Execute"), which is what makes this whole thing so frustrating smile
(I am worried about control characters though).

Here are hex dumps of the outputs from the two different ways.
https://s31.postimg.org/yjye50bl7/trouble.png

Here is the "trigger" line from openbox' menu.

https://s31.postimg.org/6x6v5hq0b/menu.png

Actual code

The template file

Just a note, the latest latest thing that I did, was to remove a nested menu that I had in there. So, there was the top level menu, submenu and then you came across this "blah" label. Doesn't work though, so the problem was not the extra menu level.

Any ideas?

Mod Note: Oversized images replaced with links, please limit images to ~250x250px.
-HoaS

Last edited by Head_on_a_Stick (2016-08-02 08:05:21)

Offline

#8 2016-08-02 09:54:36

xaos52
The Good Doctor
From: Planet of the @pes
Registered: 2015-09-30
Posts: 695

Re: Strange behaviour for pipe menus

Hah, simple..., but it had me puzzlzd too smile

In your script replace "./resourcesMenu.xml" by the absolute pathname to your xml file.

Offline

#9 2016-08-02 11:16:56

aanastasiou
Member
Registered: 2016-05-05
Posts: 14

Re: Strange behaviour for pipe menus

xaos52 wrote:

Hah, simple..., but it had me puzzlzd too smile

In your script replace "./resourcesMenu.xml" by the absolute pathname to your xml file.

LOL!...Thanks xaos52, I am framing a printout of this thread for the office.

Many thanks to everyone, madoromi thanks for the pointer to the xrandr script, might come handy later on.

Offline

Board footer

Powered by FluxBB