[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Extending fluxbox menu with a script.



On 11/21/2013 07:15 PM, Sharon Kimble wrote:
> I am trying to write a bash script which has this line in it - 
> 
> mv ~/.fluxbox/menu ~/.fluxbox/menu-$(/bin/date +%Y%m%d-%R); mmaker
> fluxbox -f;;
> 
> This line is creating a fluxbox menu which ends with these lines -
> '		[restart] (Restart)
> 		[separator]
> 		[exit] (Exit)
> 	[end]
> [end]'
> 
> What I want to do is to add this script onto the end of the first
> command, and it is -
> #!/bin/bash
> # title - submenu
> 
> echo		[submenu] (My Menu)
> echo		[include] (~/.fluxbox/usermenu)
> echo		[end]
> echo		[separator]
> 
> So the final running command will look like this - 
> 'mv ~/.fluxbox/menu ~/.fluxbox/menu-$(/bin/date +%Y%m%d-%R); mmaker
> fluxbox -f; submenu;;'
> 
> and the main menu will look like this at the end -
> 		[restart] (Restart)
> 		[separator]
> 		[exit] (Exit)
> 	[end]
> 		[submenu] (My Menu)
> 		[include] (~/.fluxbox/usermenu)
> 		[end]
> 		[separator]
> 
> But how do I do it please?
> 
> Thanks
> Sharon.

After invoking mmaker copy the generated file (~/.fluxbox/menu) to a
$temporary_file and do this:

cat "$temporary_file" | head -n -1 | (
	cat
	# invoke your script here (or do the echos directly)
) > "$HOME/.fluxbox/menu"
rm "$temporary_file"

The head command will strip off the tailing "[end]", cat will repeat the
content of stdin and your script will be invoked after that. Finally,
the result is written to your configuration file.

HTH
Linux-Fan

-- 
http://masysma.ohost.de/

Attachment: signature.asc
Description: OpenPGP digital signature


Reply to: