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

Re: Extending fluxbox menu with a script.



On 23/11/13 06:14, Sharon Kimble wrote:
> On Fri, 22 Nov 2013 12:15:21 +0000
> Sharon Kimble <boudiccas@talktalk.net> wrote:
> 
>> On Fri, 22 Nov 2013 09:09:23 +1100
>> Scott Ferguson <scott.ferguson.debian.user@gmail.com> wrote:
>>
>>> On 22/11/13 08:50, Scott Ferguson wrote:
>>>> On 22/11/13 06:39, Scott Ferguson wrote:
>>> <snipped>
>>>>
>>>> Try #2 :/
>>>
>>> Try #3 (no sleep last night - trees and power lines down across the
>>> property in last nights storms)  Sorry.
>>> This time I remembered to escape those brackets. Please test this -
>>> I can only check the script works, can't check if mmaker likes it.
>>>
>>>>
>>>> Ignore the above - that echo won't reliably create multiple lines,
>>>> printf will.
>>>>
>>>> Try this which will:-
>>>
>>> echo "
>>> #!/bin/bash
>>> # .fmenu
>>> mv ~/.fluxbox/menu{,-$(date +%Y%m%d-%R)}
>>> mmaker fluxbox -f
>>> printf "\t[submenu] \(My
>>> Menu\)\n\t[include]\(~/.fluxbox/usermenu\)\n\t[end]\n\t[separator]"
>>>>> ~/.fluxbox/menu" > ~/.fmenu
>>>
>>>>
>>>>
>>>> The above will:-
>>>> create a script ~./.fmenu
>>>>
>>>> Running ~/.fmenu will:-
>>>> mv your existing ~/.fluxbox/menu to ~/.fluxbox/menu-YYYYmmdd-hh:mm
>>>> create a new ~/.fluxbox/menu
>>>> append your submenu to it
>>>>
>>>>
>>>> If you want to remove the last [end] tag from the main menu (as
>>>> suggested by Linux Fan try this:-
>>>
>>> echo "
>>> #!/bin/bash
>>> # .fmenu
>>> mv ~/.fluxbox/menu{,-$(date +%Y%m%d-%R)}
>>> mmaker fluxbox -f
>>> sed -i 's/\[end]//g' ~/.fluxbox/menu;sed -i '/^\s*$/d'
>>> ~/.fluxbox/menu printf "\t[submenu] \(My
>>> Menu\)\n\t[include]\(~/.fluxbox/usermenu\)\n\t[end]\n\t[separator]"
>>>>> ~/.fluxbox/menu" > ~/.fmenu
>>>
>>>
>>>
>>> Someone more awake than I can probably make that double invocation
>>> of sed into a single call.
>>>
>> Morning Scott.
>> Thanks for this, I hope you slept better? This is what I currently
>> have -
>>
>> #!/bin/bash
>> # .fmenu
>> mv ~/.fluxbox/menu{,-$(date +%Y%m%d-%R)}
>>
>> mmaker fluxbox -f
>>
>> sed -i 's/\[end]//g' ~/.fluxbox/menu;sed -i '/^\s*$/d' ~/.fluxbox/menu
>>
>> printf '\t[submenu] \(My
>> Menu\)\n\t[include]\(~/.fluxbox/usermenu\)\n\t[end]\n\t[separator]'
>>>> ~/.fluxbox/menu" >~/.fmenu
>>
>> and the double sed line works okay, but its failing at the 'printf'
>> line saying -
>> 'tryitout
>> /home/boudiccas/bin/tryitout: line 21: /home/boudiccas/.fluxbox/menu 
>>
>>> ~/.fmenu'
>>
>> NB - my working script is always called 'tryitout', just whilst I'm
>> developing something. 
>>
>> The new menu is created without the two [end] at its end, but there is
>> nothing from 'printf' at all.
>>
>> Sorry
>> Sharon.
>>
> I've got it working with this line -
> mv ~/.fluxbox/menu{,-$(date +%Y%m%d-%R)}; mmaker fluxbox -f;perl -0777
> -pi -e 's/(.*)\[end]/$1/s;s/(.*)\[end]/$1/s;s/^\s*\n//gm'
> ~/.fluxbox/menu


There should be only one [end] tag to strip out at this point - other
than that the perl is fine. It's the next line that adds the second
[end] tag (the one you don't want to remove).

*Tip:* append "-x" to the first line of your script followed by "trap
read debug" to debug the script line-by-line. You'll need to press Enter
to process each line. Use cat and another terminal window and watch the
changes to the relevant files.

e.g.:-
#/bin/bash -x
# ~/bin/tryitout
trap read debug
[script goes here]



>;printf '\t[end]\n\t[separator]\n\t[submenu] (My
> Menu)\n\t[include] (~/.fluxbox/usermenu)\n\t[end]\n\t[end]'
>>> ~/.fluxbox/menu
> 
> Thanks for all those who offered solutions.
> 
> Sharon.
> 


Reply to: