summaryrefslogtreecommitdiffstats
path: root/ubuntu/raring/defaultsettings/desktop-base/usplash/moreblue-orbit/themesetup.sh
blob: 81f0bd882d9b447392ce90188fba80152b835a52 (plain)
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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
#!/bin/sh

#
# Sanity checks
#
if [ ! -e theme.in ]; then
	exit 1
fi

if [ $# -lt 1 ]; then
	exit 1
fi

#
# Helper functions
#
struct_name() {
	name=${1%.*}
	echo "pixmap_$name"
}

#
# Begin processing
#

echo "/*"
echo " * Part 1 - Generic header part"
echo " */"
cat theme.in
echo



echo "/*"
echo " * Part 2 - Forward theme struct declarations"
echo " */"
first=yes
for size in $@; do
	if [ $first = "yes" ]; then
		THEMENAME="usplash_theme"
		first=no
	else
		THEMENAME="usplash_theme_$size"
	fi
	echo "struct usplash_theme $THEMENAME;"
done
echo



echo "/*"
echo " * Step 3 - Actual theme struct defs"
echo " */"
first=yes
while [ 1 ]; do
	size="$1"
	if [ -z "$size" ]; then
		exit 0
	fi

	if [ $first = "yes" ]; then
		THEMENAME="usplash_theme"
		first=no
	else
		THEMENAME="usplash_theme_$size"
	fi

	if [ -z "$2" ]; then
		THEMENEXT="NULL"
	else
		THEMENEXT="&usplash_theme_$2"
	fi
	shift

	PGFG_PIX="progressfg_$size.png"
	PGFG_STRUCT=$(struct_name "$PGFG_PIX")
	PGBG_PIX="progressbg_$size.png"
	PGBG_STRUCT=$(struct_name "$PGBG_PIX")
	BG_PIX="background_$size.png"
	BG_STRUCT=$(struct_name "$BG_PIX")

	PROGRESS_WIDTH=$(   identify "$PGFG_PIX" | cut -d' ' -f3 | cut -dx -f1)
	PROGRESS_HEIGHT=$(  identify "$PGFG_PIX" | cut -d' ' -f3 | cut -dx -f2)
	WIDTH=${size%x*}
	HEIGHT=${size#*x}

	if [ $(( $WIDTH / 16 )) -eq $(( $HEIGHT / 9 )) ]; then
		RATIO="USPLASH_16_9"
	else
		RATIO="USPLASH_4_3"
	fi

	cat <<EOF
/* Theme definition for $size */
extern struct usplash_pixmap $PGFG_STRUCT;
extern struct usplash_pixmap $PGBG_STRUCT;
extern struct usplash_pixmap $BG_STRUCT;

struct private_hack phack_$size = {
	.progress_fg = &$PGFG_STRUCT,
	.progress_bg = &$PGBG_STRUCT
};

struct usplash_theme $THEMENAME = {
	.version = THEME_VERSION,
	.next = $THEMENEXT,
	.ratio = $RATIO,

	/* Background and font */
	.pixmap = &$BG_STRUCT,
	.font = (struct usplash_font *)&phack_$size,

	/* Palette indexes */
	.background             = PALETTE_BG,
	.progressbar_background = PALETTE_PROGRESS_FG,
	.progressbar_foreground = PALETTE_PROGRESS_BG,
	.text_background        = PALETTE_TEXT_BG,
	.text_foreground        = PALETTE_TEXT_FG,
	.text_success           = PALETTE_TEXT_SUCCESS,
	.text_failure           = PALETTE_TEXT_FAILURE,

	/* Progress bar position and size in pixels */
	.progressbar_x      = $WIDTH/2 - $PROGRESS_WIDTH/2,
	.progressbar_y      = $HEIGHT/2 - $PROGRESS_HEIGHT/2,
	.progressbar_width  = $PROGRESS_WIDTH,
	.progressbar_height = $PROGRESS_HEIGHT,

	/* Text box position and size in pixels */
	.text_x      = TEXT_MARGIN,
	.text_y      = $HEIGHT/2 + $PROGRESS_HEIGHT/2 + TEXT_MARGIN,
	.text_width  = $WIDTH - 2 * TEXT_MARGIN,
	.text_height = $HEIGHT/2 - $PROGRESS_HEIGHT/2 - 2*TEXT_MARGIN,

	/* Text details */
	.line_height  = 15,
	.line_length  = 32,
	.status_width = 25,

	/* Functions */
	.init = t_init,
	.clear_progressbar = t_clear_progressbar,
	.draw_progressbar = t_draw_progressbar,
	.clear_text = t_clear_text,
	.animate_step = t_animate_step,
};

EOF
done

exit 0