You are not logged in.

#1 2011-09-22 12:35:15

PSW
Member
From: Brighton
Registered: 2011-06-15
Posts: 32

Bash & Zenity in OpenBox's menu.xml

I'm using OpenBox 3.5.0 with PCManFM to manage my desktop, I would like to add "New File" and "New Folder" options in the OpenBox menu. From my terminal the following command works fine, however it does not work in the OpenBox menu. When run from OpenBox the Zenity dialog never shows up.

mkdir ~/Desktop/$(zenity --entry --text="Folder Name:")
<item label="New Folder">
	<action name="Execute">
		<command>
			mkdir ~/Desktop/$(zenity --entry --text="Folder Name:")
		</command>
	</action>
</item>

(I do know I could put it in a script and have OpenBox execute that script, but I would rather it was just a single line in my menu.xml)

Last edited by PSW (2011-09-22 12:36:05)

Offline

#2 2011-09-22 16:20:46

dammannj
Member
Registered: 2009-01-28
Posts: 44

Re: Bash & Zenity in OpenBox's menu.xml

What (I guess) openbox does: content of <command> is taken as a string, broken up in tokens and then executed with some kind of exec function (man 3 exec).
Whay you want: system("<command>"), which gives this stuff to a shell.
So try:

<item label="New Folder">
	<action name="Execute">
		<command>
			sh -c "mkdir ~/Desktop/$(zenity --entry --text="Folder Name:")"
		</command>
	</action>
</item>

Offline

#3 2011-09-23 10:44:07

PSW
Member
From: Brighton
Registered: 2011-06-15
Posts: 32

Re: Bash & Zenity in OpenBox's menu.xml

dammannj wrote:

What (I guess) openbox does: content of <command> is taken as a string, broken up in tokens and then executed with some kind of exec function (man 3 exec).
Whay you want: system("<command>"), which gives this stuff to a shell.
So try:

<item label="New Folder">
	<action name="Execute">
		<command>
			sh -c "mkdir ~/Desktop/$(zenity --entry --text="Folder Name:")"
		</command>
	</action>
</item>

Sadly, this makes no difference.

<item label="New Folder">
	<action name="Execute">
		<command>
			zenity --entry --text="Folder Name:"
		</command>
	</action>
</item>

Works, and mkdir works. It's just when put together they fail =/

Last edited by PSW (2011-09-23 10:44:21)

Offline

#4 2011-09-23 15:21:52

dammannj
Member
Registered: 2009-01-28
Posts: 44

Re: Bash & Zenity in OpenBox's menu.xml

It's the "" inside the $() ...

<item label="New Folder">
	<action name="Execute">
		<command>
			sh -c "mkdir ~/Desktop/$(zenity --entry --text='Folder Name:')"
		</command>
	</action>
</item>

works for me. Normally quoting stuff inside $() is totally ok. So i think this is a bug in openbox.

Offline

#5 2011-09-23 15:27:29

dammannj
Member
Registered: 2009-01-28
Posts: 44

Re: Bash & Zenity in OpenBox's menu.xml

Just confirmed it by using

strace -o foo.bar -f -p $(pidof openbox) -s 1000

In foo.bar you see this:

execve("/bin/sh", ["sh", "-c", "mkdir $(zenity --entry --text=Folder", "Name:)"]

which should be:

execve("/bin/sh", ["sh", "-c", "mkdir $(zenity --entry --text='Folder Name:')"]

Offline

#6 2011-09-23 15:28:49

dammannj
Member
Registered: 2009-01-28
Posts: 44

Re: Bash & Zenity in OpenBox's menu.xml

One other thing: escaping quotes works as well smile
--text=\"Folder Name:\"

Offline

#7 2011-09-26 10:15:24

PSW
Member
From: Brighton
Registered: 2011-06-15
Posts: 32

Re: Bash & Zenity in OpenBox's menu.xml

Thanks guys, all working now.

Offline

Board footer

Powered by FluxBB