Menu with CD covers

Hi,

I wanted to make a menu to navigate into my music directories with album CD cover used as icon for each Submenu entry, but I didn’t want to patch my fvwm-menu-directory file (Zenites’ site proposes one…) because I don’t know Perl and I do want to understand what I’m doing !!
So I used awk to make this little function that modify the output of the fvwm-menu-directory command.

Some script features :
[list][]Only display files which extension is in a list.[/:m]
[]My directory sructure is : “Artist/Year - Album/Songs…”, so the script deletes the "Year - " part of directories names, also delete the files extension and every " item +100 c" occurences.[/:m]
[]If the script detects a file named .cover.png (40x40 pixels) in the subdirectory, it replaces the base icon for folders by this file.[/:m][/list:u]

Here is the code :

FVWM Config :

[code]SetEnv current_theme $[FVWM_USERDIR]/current
SetEnv scripts_dir $[current_theme]/Scripts
SetEnv icons_dir $[current_theme]/Icons
SetEnv music_dir $[HOME]/Music/Artists
SetEnv music_program “audacious -p -e”
SetEnv songs_extensions=“mp3 wav ogg flac wma”

DestroyMenu MenuMusic
AddToMenu MenuMusic

  • MissingSubmenuFunction FuncFvwmMenuDirectory
  • %$[icons_dir]/music_folder.png%“Songs” Popup “$[music_dir]”

DestroyFunc FuncFvwmMenuDirectory
AddToFunc FuncFvwmMenuDirectory

  • I PipeRead “$[scripts_dir]/browsers.sh “$0” $[desk.n]”[/code]
    ($[desk.n] is only here because my script is also used with other directories such as wallpapers tree, and I need this option to change the wallpaper on the current desk)

browsers.sh :

[code]program="$music_program"
icon_file="$icons_dir/music.png"
icon_folder="$icons_dir/music_folder.png"

extensions_regex=$(echo $songs_extensions | sed -e ‘s/^/./’ -e ‘s/\s+/|./g’)
extensions_all="$(echo $songs_extensions | sed -e ‘s/^/./’ -e ‘s/\s+/ ./g’)"
extensions_all_regex="$(echo $songs_extensions | sed -e 's/^/\
\./’ -e 's/\s+/ \
\./g’)"

test -f “$1/.cover.png” && icon_title="$1/.cover.png" || icon_title="$icon_folder.png"

fvwm-menu-directory
–icon-title “$icon_title”
–title “%d”
–icon-file “$icon_file”
–icon-dir “$icon_folder”
–dir “$1”
–links
–exec-t="^$program $extensions_all"
–exec-file “^$program”
| awk -F’Popup “|”$’ ’
{
gsub(/%[0-9][0-9][0-9][0-9] - /,"%")
gsub(/ item.*$/,"")
}
/Popup “/ {
if (!system(“test -f “”$2”/.cover.png”"))
{
dir=$2
gsub(/&/,"\\&",dir)
gsub("’$icon_folder’",dir"/.cover.png")
}
}
$0 !~ /’"$program"’ “/ || $0 ~ /’$extensions_regex’”/ {
gsub(/(’$extensions_regex’)"/,""")
print
}’
| awk -F’.png%|" Exec ’ ’
/’"$extensions_all_regex"’/ {
gsub(/&/,"\&\&",$2)
gsub(/*/,"**",$2)
gsub(/%/,"%%",$2)
print $1 “.png%” $2 “” Exec " $3
}
$0 !~ /’"$extensions_all_regex"’/ {
print
}’[/code]
This script may interest some of you, or not… :wink:

Original version here (in french !!). I translated the post I wrote on Gentoo Forums, and the script variables names, in order to make it easier for non-french speaking people ! I hope I didn’t forget mistakes due to translation…

As a conclusion, please forgive me for my too french english speaking…