4 SELF_ABSOLUTE
=`readlink -f "$0"`
7 # Script for generating irreco config files for buttons themes.
16 --generate|generate|gen
) theme_gen_erate
"${ARGS[@]:1}";;
23 echo "Usage: $SELF COMMAND"
26 echo " --generate | generate | gen SOURCE DESTINATION"
27 echo " Generate configuration files and directory structures"
28 echo " for so that Irreco will correctly read the theme."
35 THEME_NAME
="$( cat "$SOURCE"/name )"
36 THEME_DIR_NAME
="$( theme_gen_dir_name "$THEME_NAME" )"
39 IRRECO_DIR
="$DESTINATION/lib/irreco"
40 THEME_DIR
="$IRRECO_DIR/themes/$THEME_DIR_NAME"
41 BUTTON_DIR
="$THEME_DIR/buttons"
42 BG_DIR
="$THEME_DIR/bg"
44 [[ "$SOURCE" == "" ]] && theme_gen_error \
45 "Source directory not given."
47 [[ "$DESTINATION" == "" ]] && theme_gen_error \
48 "Destination directory not given."
50 [ ! -d "$SOURCE" ] && theme_gen_error \
51 "Source directory does not exist, is not a directory."
53 #[ -e "$DESTINATION" ] && theme_gen_error \
54 # "Destination already exists. Will not overwrite."
56 [ ! -f "$SOURCE"/name
] && theme_gen_error \
57 "Theme name file does not exist."
60 THEME_PREFIX
=`basename "$( realpath -f $SOURCE )"`
61 BUTTONDIR
="$SOURCE/buttons"
64 echo "Source: \"$SOURCE\""
65 echo "Buttondir: \"$BUTTONDIR\""
66 echo "Bgdir: \"$BGDIR\""
67 echo "Destination: \"$DESTINATION\""
68 echo "Theme name: \"$THEME_NAME\""
69 echo "Theme dir: \"$THEME_DIR\""
70 echo "Theme prefix: \"$THEME_PREFIX\""
72 if [ ! -d "$DESTINATION" ]; then
77 mkdir
-p "$BUTTON_DIR"
83 echo "Creating theme config."
84 theme_gen_theme_config
> "$THEME_DIR/theme.conf"
87 echo "Installing backgrounds:"
88 if [ -d "$BGDIR" ]; then
89 theme_gen_bg_list | theme_gen_bg_parse
93 echo "Installing buttonstyles:"
94 theme_gen_button_list | theme_gen_button_parse
97 #echo "Destination file list:"
98 #cd "$DESTINATION" && find | sort
102 # Generates a lower case name, and replaces spaces with underscores.
106 echo "$1" |
tr [:upper
:] [:lower
:] |
tr [:blank
:] _
109 theme_gen_theme_config
()
112 echo "name=$THEME_NAME"
119 ls -1 |
grep '.png$' |
sed -r 's/.png//'
125 echo "Generating: \"$LINE\""
127 DEST_BG_DIR
="$( theme_gen_dir_name "$LINE" )"
128 DEST_IMAGE
="$DEST_BG_DIR"/image.png
129 DEST_CONFIG
="$DEST_BG_DIR"/bg.conf
133 mkdir
-p "$BG_DIR"/"$DEST_BG_DIR"
134 cp "$BGDIR"/"$BG_NAME".png \
135 "$BG_DIR"/"$DEST_IMAGE"
138 # Create configuration.
139 theme_gen_bg_config
> "$BG_DIR"/"$DEST_CONFIG"
144 theme_gen_bg_config
()
148 if [[ "$BG_NAME" != "" ]]; then
152 echo "image=image.png"
155 theme_gen_button_list
()
158 ls -1 |
grep '.png$' |
sed -r 's/_(pressed|unpressed).png//' |
uniq
161 theme_gen_button_parse
()
164 echo -n "Generating: \"$LINE\""
166 DEST_PRESSED
="$LINE"/pressed.png
167 DEST_UNPRESSED
="$LINE"/unpressed.png
168 DEST_CONFIG
="$LINE"/button.conf
169 CONFIG_APPEND
="$BUTTONDIR"/"$LINE"_config_append
172 down
) BUTTON_NAME
="Down"
174 left
) BUTTON_NAME
="Left"
176 next
) BUTTON_NAME
="Next"
178 pause
) BUTTON_NAME
="Pause"
180 play
) BUTTON_NAME
="Play"
182 playpause
) BUTTON_NAME
="Play / Pause"
184 power
) BUTTON_NAME
="Power"
186 prev
) BUTTON_NAME
="Prev"
188 right
) BUTTON_NAME
="Right"
192 menu
) BUTTON_NAME
="Menu"
196 blank
) BUTTON_NAME
="Blank"
198 num_0
) BUTTON_NAME
="Number 0"
200 num_1
) BUTTON_NAME
="Number 1"
202 num_2
) BUTTON_NAME
="Number 2"
204 num_3
) BUTTON_NAME
="Number 3"
206 num_4
) BUTTON_NAME
="Number 4"
208 num_5
) BUTTON_NAME
="Number 5"
210 num_6
) BUTTON_NAME
="Number 6"
212 num_7
) BUTTON_NAME
="Number 7"
214 num_8
) BUTTON_NAME
="Number 8"
216 num_9
) BUTTON_NAME
="Number 9"
218 *) grep '^name=' "$CONFIG_APPEND" > /dev
/null
219 if [[ "$?" != "0" ]]; then
220 echo "Error: Custom button type without name."
221 echo "Unknown file: \"$LINE\"";
227 # Copy unpressed image.
228 mkdir
-p "$BUTTON_DIR"/"$LINE"
229 cp "$BUTTONDIR"/"$LINE"_unpressed.png \
230 "$BUTTON_DIR"/"$DEST_UNPRESSED"
233 # Copy pressed image.
234 if [ -e "$BUTTONDIR"/"$LINE"_pressed.png
]; then
235 cp "$BUTTONDIR"/"$LINE"_pressed.png \
236 "$BUTTON_DIR"/"$DEST_PRESSED"
243 theme_gen_button_config
> "$BUTTON_DIR"/"$DEST_CONFIG"
246 #echo "$CONFIG_APPEND"
247 if [ -f "$CONFIG_APPEND" ]; then
248 echo -n " ... appeding config"
249 cat "$CONFIG_APPEND" >> "$BUTTON_DIR"/"$DEST_CONFIG"
257 theme_gen_button_config
()
259 echo "[theme-button]"
261 if [[ "$BUTTON_NAME" != "" ]]; then
262 echo "name=$BUTTON_NAME"
265 if [[ "$ALLOW_TEXT" != "" ]]; then
266 echo "allow-text=$ALLOW_TEXT"
269 echo "up=unpressed.png"
271 if [[ "$PRESSED_EXITST" == "yes" ]]; then
272 echo "down=pressed.png"
277 # Stop script if exit code is not 0
279 # Usage: check_exit_code "$?"
283 if [[ "$1" != "0" ]]; then