5

This is the weirdest thing. The script works when run from the shell with no problems. When I run it as an Openbox pipe-menu I get the error "Invalid output from pipe-menu". After playing around with the script I found that it has specifically to do with printing the 5th column.

To make matters even more confusing, this only happens with the month of July. All other months will show up correctly running the script.

Here is the script as it should be. It works when executed from a terminal:

#!/bin/bash
echo "<openbox_pipe_menu>"
cal | while read i;do
echo "<item label=\"$i\"/>"
done
echo "</openbox_pipe_menu>"
echo "</openbox_pipe_menu>"

The output of the script:

$ ./date-menu.sh 
<openbox_pipe_menu>
<item label="July 2014"/>
<item label="Su Mo Tu We Th Fr Sa"/>
<item label="1  2  3  4  5"/>
<item label="6  7  8  9 10 11 12"/>
<item label="13 14 15 16 17 18 19"/>
<item label="20 21 22 23 24 25 26"/>
<item label="27 28 29 30 31"/>
<item label=""/>
</openbox_pipe_menu>

Here is the simplified version that still fails when running as a pipe-menu:

#!/bin/bash
calRow () {
cal | gawk -v row=$1 '{ if (NR==row) { print $0 } }'
}
echo "<openbox_pipe_menu>"
echo "<item label=\"`calRow 5`\"/>"
echo "</openbox_pipe_menu>"

BUT...If I do the same script with any number but 5 it works like a charm:

#!/bin/bash
calRow () {
cal | gawk -v row=$1 '{ if (NR==row) { print $0 } }'
}
echo "<openbox_pipe_menu>"
echo "<item label=\"`calRow 2`\"/>"
echo "<item label=\"`calRow 3`\"/>"
echo "<item label=\"`calRow 4`\"/>"
echo "<item label=\"`calRow 6`\"/>"
echo "<item label=\"`calRow 7`\"/>"
echo "<item label=\"`calRow 8`\"/>"
echo "</openbox_pipe_menu>"

Here is the menu.xml file in case anyone wants to see it:

<?xml version="1.0" encoding="utf-8"?>
<openbox_menu xmlns="http://openbox.org/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://openbox.org/                 file:///usr/share/openbox/menu.xsd">
    <menu id="root-menu" label="Openbox 3">
        <item label="Terminal emulator">
            <action name="Execute">
                <execute>x-terminal-emulator</execute>
            </action>
        </item>
        <item label="Browser">
            <action name="Execute">
                <execute>x-www-browser</execute>
            </action>
        </item>
        <item label="Virtualbox">
            <action name="Execute">
                <execute>virtualbox</execute>
            </action>
        </item>
        <!-- This requires the presence of the 'menu' package to work -->
        <menu id="/Debian"/>
        <separator/>
        <item label="obmenu">
            <action name="Execute">
                <execute>obmenu</execute>
            </action>
        </item>
        <item label="ObConf">
            <action name="Execute">
                <execute>obconf</execute>
            </action>
        </item>
        <item label="Reconfigure">
            <action name="Reconfigure"/>
        </item>
        <item label="Restart">
            <action name="Restart"/>
        </item>
        <separator/>
        <menu execute="obpipes/sysinfo.sh" id="pipe-sysinfo" label="System Info"/>
        <menu execute="obpipes/date-menu.sh" id="pipe-datemenu" label="Date"/>
        <menu id="client-list-menu"/>
        <separator/>
        <item label="Exit">
            <action name="Exit"/>
        </item>
    </menu>
</openbox_menu>
2
  • 2
    Turns out it was the highlighted day causing the problem. I was able to fix it by turning highlighting off (cal -h)
    – Jeight
    Jul 17, 2014 at 10:37
  • Could you answer your own question, so it will be marked as solved. Jul 18, 2014 at 7:35

1 Answer 1

2

It turns out it was the current day being highlighted causing the problem. I was able to fix it by turning highlighting off (cal -h)

1
  • I wonder if it's any highlighting or just the one from cal which is problematic...
    – user44370
    Jul 18, 2014 at 23:20

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .