DestroyMenu MiscStyles
AddToMenu   MiscStyles "Decor Menu" Title

# Macro to define the decor function
# Arg 0, DecorName, creates a function of the same name that
#                   reads the function when the menu item is selected,
#                   and adds the item to the MiscStyles menu
# Optionally, a Decor can define the function "DecorRemoveHook"
# which is run whenever a new decor is loaded.
DestroyFunc DecorHook
AddToFunc DecorHook I DestroyFunc $0
AddToFunc DecorHook I AddToFunc $0 I DecorRemoveHook
AddToFunc DecorHook I AddToFunc $0 I PipeRead 'rm .fvwm/.DecorCurrent 2>/dev/null'
AddToFunc DecorHook I AddToFunc $0 I PipeRead 'ln -s $0 .fvwm/.DecorCurrent 2>/dev/null'
AddToFunc DecorHook I AddToFunc $0 I read .DecorCurrent
AddToFunc DecorHook I AddToMenu MiscStyles "$1" $0 

# Define an initial DecorRemoveHook:
DestroyFunc DecorRemoveHook
AddToFunc DecorRemoveHook I Nop

# Load up the decor menu:
PipeRead 'sed -n -e "s/\# DecorHook/DecorHook/p" .fvwm/Decor*[!~]'
AddToMenu MiscStyles "&X. Remove current decor" Exec rm .fvwm/.DecorCurrent 2>/dev/null
# Now load the current decor (if any)
read .DecorCurrent quiet
