1 |
# $Header: /home/cvsd/alx-cvs/alx-src/alxconfig-ng/functions/config_sessions.sh,v 1.12 2005-08-28 22:50:09 niro Exp $ |
# $Header: /home/cvsd/alx-cvs/alx-src/alxconfig-ng/functions/config_sessions.sh,v 1.13 2005-09-01 18:27:44 niro Exp $ |
2 |
# configures ica-sessions on the host via mysql db settings |
# configures ica-sessions on the host via mysql db settings |
3 |
|
|
4 |
get_sessions_settings() |
get_sessions_settings() |
26 |
count=0 |
count=0 |
27 |
fi |
fi |
28 |
|
|
29 |
|
# get settings from database |
30 |
|
ALX_PROGRAMS=$(mysql_command ${SQL_USER} ${SQL_PASS} ${SQL_HOST} ${SQL_DB} \ |
31 |
|
"select name from cfg_other_menuitems where serial='${ALX_SERIAL}'") |
32 |
|
|
33 |
export ALX_SESSIONS |
export ALX_SESSIONS |
34 |
|
export ALX_PROGRAMS |
35 |
} |
} |
36 |
|
|
37 |
get_autostart_settings() |
get_autostart_settings() |
126 |
done |
done |
127 |
} |
} |
128 |
|
|
129 |
|
# generates a sh file to start programs |
130 |
|
generate_program_sh() |
131 |
|
{ |
132 |
|
local dest |
133 |
|
local name |
134 |
|
local exec |
135 |
|
local workdir |
136 |
|
|
137 |
|
# very basic getops |
138 |
|
for i in $* |
139 |
|
do |
140 |
|
case $1 in |
141 |
|
--name|-n) shift; name="$1" ;; |
142 |
|
--exec|-x) shift; exec="$1" ;; |
143 |
|
--dest|-d) shift; dest="$1" ;; |
144 |
|
--workdir|-w) shift; workdir="$1" ;; |
145 |
|
esac |
146 |
|
shift |
147 |
|
done |
148 |
|
|
149 |
|
# abort if name, dest or exec not given |
150 |
|
[ -z "${name}" ] && return 1 |
151 |
|
[ -z "${exec}" ] && return 1 |
152 |
|
[ -z "${dest}" ] && return 1 |
153 |
|
|
154 |
|
echo "#!/bin/sh" > ${dest} |
155 |
|
[ -n "${workdir}" ] && echo "cd ${workdir}" >> ${dest} |
156 |
|
echo "exec ${exec}" >> ${dest} |
157 |
|
|
158 |
|
chmod 0755 ${dest} |
159 |
|
} |
160 |
|
|
161 |
get_other_menuitems() |
get_other_menuitems() |
162 |
{ |
{ |
163 |
local x i count name exec icon workdir |
local x i progsh_path name exec icon workdir |
164 |
|
|
165 |
# all arrays: |
# all arrays: |
166 |
# -> session1 session2 ... sessionN |
# -> session1 session2 ... sessionN |
167 |
|
|
168 |
# get settings from database |
# get settings from database -> now stored in ALX_PROGRAMS |
|
count=$(mysql_command ${SQL_USER} ${SQL_PASS} ${SQL_HOST} ${SQL_DB} \ |
|
|
"select name from cfg_other_menuitems where serial='${ALX_SERIAL}'") |
|
169 |
|
|
170 |
# get all instances and put them into an array |
# abort if empty |
171 |
if [ -n "${count}" ] |
[ -z "${ALX_PROGRAMS}" ] && return 0 |
172 |
then |
|
173 |
for x in ${count} |
progsh_path=${ALX_UNPRIV_HOME}/.alxprogs |
174 |
do |
[ -d ${progsh_path} ] && rm -rf ${progsh_path} |
175 |
# to be sure |
install -d ${progsh_path} |
|
unset name |
|
|
unset exec |
|
|
unset workdir |
|
|
unset icon |
|
|
|
|
|
name=$(mysql_command ${SQL_USER} ${SQL_PASS} ${SQL_HOST} ${SQL_DB} \ |
|
|
"select name from cfg_other_menuitems where serial='${ALX_SERIAL}' and name='${x}'") |
|
|
|
|
|
exec=$(mysql_command ${SQL_USER} ${SQL_PASS} ${SQL_HOST} ${SQL_DB} \ |
|
|
"select exec from cfg_other_menuitems where serial='${ALX_SERIAL}' and name='${x}'") |
|
|
|
|
|
workdir=$(mysql_command ${SQL_USER} ${SQL_PASS} ${SQL_HOST} ${SQL_DB} \ |
|
|
"select workdir from cfg_other_menuitems where serial='${ALX_SERIAL}' and name='${x}'") |
|
|
|
|
|
icon=$(mysql_command ${SQL_USER} ${SQL_PASS} ${SQL_HOST} ${SQL_DB} \ |
|
|
"select icon from cfg_other_menuitems where serial='${ALX_SERIAL}' and name='${x}'") |
|
|
|
|
|
# debug only |
|
|
#echo "DEBUG: ${x}: name:'${name}' exec:'${exec}' workdir:'${workdir}' ic$ |
|
|
|
|
|
# now echo config line for fluxbox-menu |
|
|
# make it "configureable" :P |
|
|
[ -n "${workdir}" ] && workdir="cd ${workdir};" |
|
|
[ -n "${icon}" ] && icon="[${icon}]" |
|
|
echo "[exec] (${name}) {${workdir}${exec}} ${icon}" |
|
|
done |
|
|
fi |
|
|
} |
|
176 |
|
|
177 |
|
# gen menu items |
178 |
|
for x in ${ALX_PROGRAMS} |
179 |
|
do |
180 |
|
# to be sure |
181 |
|
unset name |
182 |
|
unset exec |
183 |
|
unset workdir |
184 |
|
unset icon |
185 |
|
|
186 |
|
name=$(mysql_command ${SQL_USER} ${SQL_PASS} ${SQL_HOST} ${SQL_DB} \ |
187 |
|
"select name from cfg_other_menuitems where serial='${ALX_SERIAL}' and name='${x}'") |
188 |
|
|
189 |
|
exec=$(mysql_command ${SQL_USER} ${SQL_PASS} ${SQL_HOST} ${SQL_DB} \ |
190 |
|
"select exec from cfg_other_menuitems where serial='${ALX_SERIAL}' and name='${x}'") |
191 |
|
|
192 |
|
workdir=$(mysql_command ${SQL_USER} ${SQL_PASS} ${SQL_HOST} ${SQL_DB} \ |
193 |
|
"select workdir from cfg_other_menuitems where serial='${ALX_SERIAL}' and name='${x}'") |
194 |
|
|
195 |
|
icon=$(mysql_command ${SQL_USER} ${SQL_PASS} ${SQL_HOST} ${SQL_DB} \ |
196 |
|
"select icon from cfg_other_menuitems where serial='${ALX_SERIAL}' and name='${x}'") |
197 |
|
|
198 |
|
# debug only |
199 |
|
#echo "DEBUG: ${x}: name:'${name}' exec:'${exec}' workdir:'${workdir}' ic$ |
200 |
|
|
201 |
|
# now echo config line for fluxbox-menu |
202 |
|
# make it "configureable" :P |
203 |
|
#[ -n "${workdir}" ] && workdir="cd ${workdir};" |
204 |
|
[ -n "${workdir}" ] && workdir="--workdir ${workdir}" |
205 |
|
[ -n "${icon}" ] && icon="<${icon}>" |
206 |
|
|
207 |
|
# gen prog startup wrapper |
208 |
|
generate_program_sh \ |
209 |
|
--name "${name}" \ |
210 |
|
--exec "${exec}" \ |
211 |
|
--dest "${progsh_path}/${name}" \ |
212 |
|
"${workdir}" |
213 |
|
|
214 |
|
echo "[exec] (${name}) {${progsh_path}/${name}} ${icon}" |
215 |
|
done |
216 |
|
} |
217 |
|
|
218 |
# helper functions for generate all desktop icons |
# helper functions for generate all desktop icons |
219 |
generate_icon() |
generate_icon() |
226 |
local xres |
local xres |
227 |
local iwidth |
local iwidth |
228 |
local iheight |
local iheight |
229 |
|
local deficon |
230 |
|
|
231 |
# very basic getops |
# very basic getops |
232 |
for i in $* |
for i in $* |
240 |
--yres|-y) shift; yres="$1" ;; |
--yres|-y) shift; yres="$1" ;; |
241 |
--icon-width|-w) shift; iwidth="$1" ;; |
--icon-width|-w) shift; iwidth="$1" ;; |
242 |
--icon-height|-h) shift; iheight="$1" ;; |
--icon-height|-h) shift; iheight="$1" ;; |
243 |
|
--default-icon) shift; deficon="$1" ;; |
244 |
esac |
esac |
245 |
shift |
shift |
246 |
done |
done |
257 |
[ -z "${dest}" ] && dest="${ALX_UNPRIV_HOME}/.xtdesktop/${name}.lnk" |
[ -z "${dest}" ] && dest="${ALX_UNPRIV_HOME}/.xtdesktop/${name}.lnk" |
258 |
if [ -z "${icon}" ] || [ ! -f "${icon}" ] |
if [ -z "${icon}" ] || [ ! -f "${icon}" ] |
259 |
then |
then |
260 |
icon="${ALX_SESSIONS_ICONS}/default.png" |
# if no default icon is given use default.png |
261 |
|
[ -z "${deficon}" ] && deficon="default.png" |
262 |
|
icon="${ALX_SESSIONS_ICONS}/${deficon}" |
263 |
fi |
fi |
264 |
|
|
265 |
echo "table Icon" > ${dest} |
echo "table Icon" > ${dest} |
289 |
local x |
local x |
290 |
local y |
local y |
291 |
local item |
local item |
292 |
|
local progsh_path |
293 |
|
|
294 |
# get the resolution |
# get the resolution |
295 |
res=$(mysql_command ${SQL_USER} ${SQL_PASS} ${SQL_HOST} ${SQL_DB} \ |
res=$(mysql_command ${SQL_USER} ${SQL_PASS} ${SQL_HOST} ${SQL_DB} \ |
345 |
|
|
346 |
generate_icon \ |
generate_icon \ |
347 |
--name "${item}" \ |
--name "${item}" \ |
348 |
--command "wfica ${ALX_ICA_SESSIONS}/${item}.ica" \ |
--command "${progsh_path}/${item}" \ |
349 |
--icon "${ALX_SESSIONS_ICONS}/${item}.png" \ |
--icon "${ALX_SESSIONS_ICONS}/${item}.png" \ |
350 |
--dest "${ALX_UNPRIV_HOME}/.xtdesktop/${item}.lnk" \ |
--dest "${ALX_UNPRIV_HOME}/.xtdesktop/${item}.lnk" \ |
351 |
--xres "${x}" \ |
--xres "${x}" \ |
355 |
done |
done |
356 |
|
|
357 |
|
|
358 |
|
# generate program icons |
359 |
|
icon_list="${ALX_PROGRAMS}" |
360 |
|
|
361 |
|
progsh_path=${ALX_UNPRIV_HOME}/.alxprogs |
362 |
|
|
363 |
|
for item in ${icon_list} |
364 |
|
do |
365 |
|
# abort if empty |
366 |
|
[ -z "${item}" ] && continue |
367 |
|
|
368 |
|
# new line if x > xres |
369 |
|
if [ ${x} -ge ${xres} ];then |
370 |
|
x=20 |
371 |
|
y=$((${y} + 80)) |
372 |
|
fi |
373 |
|
|
374 |
|
# new row if y > yres |
375 |
|
if [ ${y} -ge ${yres} ];then |
376 |
|
x=$((${x} + 120)) |
377 |
|
y=20 |
378 |
|
|
379 |
|
# re-check x |
380 |
|
[ ${x} -ge ${xres} ] && x=20 |
381 |
|
fi |
382 |
|
|
383 |
|
generate_icon \ |
384 |
|
--name "${item}" \ |
385 |
|
--command "${progsh_path}/${item}" \ |
386 |
|
--icon "${ALX_SESSIONS_ICONS}/${item}.png" \ |
387 |
|
--dest "${ALX_UNPRIV_HOME}/.xtdesktop/${item}.lnk" \ |
388 |
|
--xres "${x}" \ |
389 |
|
--yres "${y}" \ |
390 |
|
--default-icon "default_item.png" |
391 |
|
|
392 |
|
y=$((${y} + 80)) |
393 |
|
done |
394 |
|
|
395 |
|
|
396 |
|
|
397 |
# last but not least gen a icon with some sys informations |
# last but not least gen a icon with some sys informations |
398 |
local sysinfo |
local sysinfo |
399 |
local hostname |
local hostname |
515 |
|
|
516 |
# unset vars |
# unset vars |
517 |
unset ALX_SESSIONS |
unset ALX_SESSIONS |
518 |
|
unset ALX_PROGRAMS |
519 |
} |
} |