File: media_directories

package info (click to toggle)
fvwm-crystal 3.3.1%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 19,748 kB
  • ctags: 793
  • sloc: sh: 2,815; cs: 880; python: 875; makefile: 212
file content (104 lines) | stat: -rwxr-xr-x 4,412 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
#!/bin/bash

# Generation of multimedia browser menu for FVWM-Crystal
# Written by Dominique Michel <dominique_libre@users.sourceforge.net>, 2008-2013
# Read $[USER_USERDIR"/preferences/MediaDirectories and generate the /Music/LoadMovie
# menu in $[FVWM_USERDIR]/tmp/MenuMovieDirectory"

# Syntax:
# PipeRead '$[FVWM_SYSTEMDIR]/scripts/media_directories $[infostore.USERDIR] $[MediaMenuIcons]'
# Include tmp/MenuMovieDirectory

# mplayer command line
fvwm_video_exec="fvwm-crystal.mplayer-wrapper file $1"

# find media type and related strings creation {{{1
find_type() {
    case "$1" in
    audio*)
      Audio="${Audio} \"`echo "$1 "|cut -d " " -f 2`\"*) myexec=\"${fvwm_video_exec}\";; "
      BrowseAudio="${BrowseVideo} + '%22x22/categories/video_movies_view.png%\$[gt.Browse Music]' Popup `echo "$1 "|cut -d " " -f 2` \\n"
      ;;
    video*)
      Video="${Video} \"`echo "$1 "|cut -d " " -f 2`\"*) myexec=\"${fvwm_video_exec}\";; "
      BrowseVideo="${BrowseVideo} + '%22x22/categories/video_movies_view.png%\$[gt.Browse Medias]' Popup `echo "$1 "|cut -d " " -f 2` \\n"
      ;;
    cdrom*)
      CDrom="${CDrom} \"`echo "$1 "|cut -d " " -f 2`\"*) myexec=\"${fvwm_video_exec}\";; "
      BrowseCDrom="${BrowseCDrom} + '%22x22/categories/video_movies_view.png%\$[gt.Browse CDrom]' Popup `echo "$1 "|cut -d " " -f 2` \\n"
      ;;
    dvd*)
      DVD="${DVD} \"`echo "$1 "|cut -d " " -f 2`\"*) myexec=\"${fvwm_video_exec}\";; "
      BrowseDVD="${BrowseDVD} + '%22x22/categories/video_movies_view.png%\$[gt.Browse DVD]' Popup `echo "$1 "|cut -d " " -f 2` \\n"
      ;;
    *)
      echo "something wrong"
      exit 66
      ;;
    esac
}

# variables initialisations {{{1
Audio=""
BrowseAudio=""
Video=""
BrowseVideo=""
CDrom=""
BrowseCDrom=""
DVD=""
BrowseDVD=""

# we just create a file from those variables.

# the main function {{{1
# be sure media directories file exist
if [ ! -f "${FVWM_USERDIR}/preferences/MediaDirectories" ]
then
    cp -R "${FVWM_SYSTEMDIR}/preferences/MediaDirectories" "${FVWM_USERDIR}/preferences/MediaDirectories"
    FvwmCommand "Module FvwmForm MediaDirectories-Dialog" 
fi

while read line; do
    find_type "$line"
done <"${FVWM_USERDIR}/preferences/MediaDirectories"

mkdir -p "${FVWM_USERDIR}/tmp"
menufile="${FVWM_USERDIR}/tmp/MenuMovieDirectory"
#menufile="/dev/null"

# Menu creation {{{2
# From Taviso's configuration
# 22x22/categories/Audio-Video.png will be used for all the files that doesn't have a .media.png inside their directory
# 22x22/categories/directory.png will be used for all the directories that doesn't have a .icontitle.png file
echo "DestroyFunc FuncFvwmMenuMovieDirectory" > "${menufile}"
echo "AddToFunc FuncFvwmMenuMovieDirectory" >> "${menufile}"
echo "+ I PipeRead 'case \'\$0\' in \\" >> "${menufile}"
echo -e "${Video} ${CDrom} ${DVD} \\" >> "${menufile}"
echo "esac; \\" >> "${menufile}"
# The following commented out lines hang fvwm with a lot of file/dir names. Don't complain, fix fvwm!
# Note that the generated menu by fvwm-menu-directory look correct in any case, so the issue is in fvwm itself.
#echo "test -f \\\"\$0\\\"/.icontitle.png && mytitle=\\\"\$0\\\"/.icontitle.png; \\" >> "${menufile}"
#echo "test -f \\\"\$0\\\"/.media.png && mypng=\\\"\$0\\\"/.media.png; \\" >> "${menufile}"
#echo "fvwm-menu-directory --icon-title \"\${mytitle:-22x22/categories/directory.png}\"  \\" >> "${menufile}"
echo "fvwm-menu-directory --icon-title \"22x22/categories/directory.png\"  \\" >> "${menufile}"
# Idem:
#echo "--icon-file \"\${mypng:-22x22/categories/Audio-Video.png}\" \\" >> "${menufile}"
if [ "$2" = "1" ]
then
    echo "--icon-file \"22x22/categories/Audio-Video.png\" \\" >> "${menufile}"
    echo "--icon-dir \"22x22/categories/video_movies_view.png\" \\" >> "${menufile}"
fi
echo "--func=\"FuncFvwmMenuMovieDirectory\" \\" >> "${menufile}"
# workarounf fvwm file names bug
if [ "$2" = "1" ]
then
    echo "--exec-file \"^\${myexec}\" --dir \'\$0\' --exec-title \"^fvwm-crystal.play-movies\"'" >> "${menufile}"
else
    echo "--exec-file \"^\${myexec}\" --dir \'\$0\''" >> "${menufile}"
fi
# --exec-t=\"^fvwm-crystal.play-movies \\\"\$0\\\"\"
echo "" >> "${menufile}"
echo "DestroyMenu /Music/LoadMovie" >> "${menufile}"
echo "AddToMenu /Music/LoadMovie" >> "${menufile}"
echo "+ MissingSubmenuFunction FuncFvwmMenuMovieDirectory" >> "${menufile}"
echo -e "${BrowseVideo} ${BrowseCDrom} ${BrowseDVD}" >> "${menufile}"