Annotation of /mcore-src/trunk/mcore-tools/src/modules/idesk/idesk.client.class.in
Parent Directory | Revision Log
Revision 2147 -
(hide annotations)
(download)
Fri Jan 10 13:34:55 2014 UTC (10 years, 4 months ago) by niro
File size: 6758 byte(s)
Fri Jan 10 13:34:55 2014 UTC (10 years, 4 months ago) by niro
File size: 6758 byte(s)
-use mcore variables and use variable pathes for pixmapsdir
1 | niro | 2041 | # $Id$ |
2 | |||
3 | provide idesk basic-icons | ||
4 | |||
5 | helper_generate_icon() | ||
6 | { | ||
7 | local name | ||
8 | local icon | ||
9 | local command | ||
10 | local dest | ||
11 | local yres | ||
12 | local xres | ||
13 | local iwidth | ||
14 | local iheight | ||
15 | local deficon | ||
16 | local CONFIG | ||
17 | local utility | ||
18 | |||
19 | # very basic getops | ||
20 | for i in $* | ||
21 | do | ||
22 | case $1 in | ||
23 | --name|-n) shift; name="$1" ;; | ||
24 | --command|-c) shift; command="$1" ;; | ||
25 | --icon|-i) shift; icon="$1" ;; | ||
26 | --dest|-d) shift; dest="$1" ;; | ||
27 | --xres|-x) shift; xres="$1" ;; | ||
28 | --yres|-y) shift; yres="$1" ;; | ||
29 | --icon-width|-w) shift; iwidth="$1" ;; | ||
30 | --icon-height|-h) shift; iheight="$1" ;; | ||
31 | --default-icon) shift; deficon="$1" ;; | ||
32 | esac | ||
33 | shift | ||
34 | done | ||
35 | |||
36 | # some sanity checks: | ||
37 | niro | 2104 | |
38 | niro | 2041 | # abort if name or command not given |
39 | [[ -z ${name} ]] && return 1 | ||
40 | [[ -z ${command} ]] && return 1 | ||
41 | |||
42 | niro | 2147 | [[ -z ${dest} ]] && dest="${MCORE_UNPRIV_HOME}/.idesktop/${name}.lnk" |
43 | niro | 2041 | |
44 | # use some defaults for icon, dest, {x,y}res | ||
45 | [[ -z ${xres} ]] && xres=50 | ||
46 | [[ -z ${yres} ]] && xres=50 | ||
47 | if [[ -z ${icon} ]] || [ ! -f ${icon} ] | ||
48 | then | ||
49 | # if no default icon is given use default.png | ||
50 | [[ -z ${deficon} ]] && deficon="default.png" | ||
51 | niro | 2147 | icon="@@PIXMAPSDIR@@/${deficon}" |
52 | niro | 2041 | fi |
53 | |||
54 | CONFIG="${dest}" | ||
55 | clearconfig | ||
56 | |||
57 | addconfig 'table Icon' | ||
58 | addconfig " Caption: ${name}" | ||
59 | addconfig " Command: ${command}" | ||
60 | addconfig " Icon: ${icon}" | ||
61 | addconfig " X: ${xres}" | ||
62 | addconfig " Y: ${yres}" | ||
63 | |||
64 | # add these only if not zero | ||
65 | if [[ ! -z ${iwidth} ]] && [[ ! -z ${iheight} ]] | ||
66 | then | ||
67 | addconfig " Width: ${iwidth}" | ||
68 | addconfig " Height: ${iheight}" | ||
69 | fi | ||
70 | |||
71 | addconfig 'end' | ||
72 | } | ||
73 | |||
74 | helper_generate_all_desktop_icons() | ||
75 | { | ||
76 | local session_list="$1" | ||
77 | local other_menuitem_list="$2" | ||
78 | local plugin_list="$3" | ||
79 | local res | ||
80 | local xres | ||
81 | local yres | ||
82 | local x | ||
83 | local y | ||
84 | local i | ||
85 | local name | ||
86 | local progsh_path | ||
87 | local utility | ||
88 | local dest | ||
89 | local rc | ||
90 | |||
91 | niro | 2147 | dest="${MCORE_UNPRIV_HOME}/.idesktop" |
92 | rc="${MCORE_UNPRIV_HOME}/.ideskrc" | ||
93 | niro | 2041 | |
94 | niro | 2147 | # progs path |
95 | progsh_path="${MCORE_UNPRIV_HOME}/.progs" | ||
96 | niro | 2041 | |
97 | # get the resolution | ||
98 | niro | 2147 | res=$(mysqldo "select resolution from cfg_graphic where serial='${MCORE_SERIAL}'") |
99 | niro | 2041 | |
100 | # split res to x & y | ||
101 | xres="${res%x*}" | ||
102 | yres="${res#*x}" | ||
103 | |||
104 | # top left edge of the icon is given in config file | ||
105 | # remove a little bit to simulate the bottom-right edge | ||
106 | xres="$(( ${xres} - 120 ))" | ||
107 | yres="$(( ${yres} - 80 ))" | ||
108 | |||
109 | # clean desktop icon location | ||
110 | [ -d ${dest} ] && rm -rf ${dest} | ||
111 | [ -f ${rc} ] && rm -f ${rc} | ||
112 | install -d ${dest} | ||
113 | |||
114 | # default settings | ||
115 | declare -i x=50 | ||
116 | declare -i y=50 | ||
117 | |||
118 | # ica icons | ||
119 | for i in ${session_list} | ||
120 | do | ||
121 | # abort if empty | ||
122 | [[ -z ${i} ]] && continue | ||
123 | |||
124 | # get database information | ||
125 | niro | 2147 | evaluate_table cfg_sessions "where serial='${MCORE_SERIAL}' and id='${i}'" |
126 | niro | 2041 | |
127 | # new line if x > xres | ||
128 | if [ ${x} -ge ${xres} ] | ||
129 | then | ||
130 | x=50 | ||
131 | y=$((${y} + 80)) | ||
132 | fi | ||
133 | |||
134 | # new row if y > yres | ||
135 | if [ ${y} -ge ${yres} ] | ||
136 | then | ||
137 | x=$((${x} + 120)) | ||
138 | y=50 | ||
139 | |||
140 | # re-check x | ||
141 | [ ${x} -ge ${xres} ] && x=50 | ||
142 | fi | ||
143 | |||
144 | generate_icon \ | ||
145 | --name "${cfg_sessions_session}" \ | ||
146 | --command "nice -n 19 wfica ${ALX_ICA_SESSIONS}/$(fix_whitespaces ${cfg_sessions_filename})" \ | ||
147 | --icon "${ALX_SESSIONS_ICONS}/$(fix_whitespaces ${cfg_sessions_session}).png" \ | ||
148 | --dest "${dest}/$(fix_whitespaces ${cfg_sessions_session}).lnk" \ | ||
149 | --xres "${x}" \ | ||
150 | --yres "${y}" | ||
151 | |||
152 | y=$((${y} + 80)) | ||
153 | done | ||
154 | |||
155 | for i in ${other_menuitem_list} | ||
156 | do | ||
157 | # abort if empty | ||
158 | [[ -z ${i} ]] && continue | ||
159 | |||
160 | # get database information | ||
161 | evaluate_table cfg_other_menuitems "where serial='${ALX_SERIAL}' and id='${i}'" | ||
162 | |||
163 | # new line if x > xres | ||
164 | if [ ${x} -ge ${xres} ] | ||
165 | then | ||
166 | x=50 | ||
167 | y=$((${y} + 80)) | ||
168 | fi | ||
169 | |||
170 | # new row if y > yres | ||
171 | if [ ${y} -ge ${yres} ] | ||
172 | then | ||
173 | x=$((${x} + 120)) | ||
174 | y=50 | ||
175 | |||
176 | # re-check x | ||
177 | [ ${x} -ge ${xres} ] && x=50 | ||
178 | fi | ||
179 | |||
180 | generate_icon \ | ||
181 | --name "${cfg_other_menuitems_name}" \ | ||
182 | --command "${progsh_path}/$(fix_whitespaces ${cfg_other_menuitems_name})" \ | ||
183 | --icon "${ALX_SESSIONS_ICONS}/$(fix_whitespaces ${cfg_other_menuitems_name}).png" \ | ||
184 | --dest "${dest}/$(fix_whitespaces ${cfg_other_menuitems_name}).lnk" \ | ||
185 | --xres "${x}" \ | ||
186 | --yres "${y}" \ | ||
187 | --default-icon "default_item.png" | ||
188 | |||
189 | y=$((${y} + 80)) | ||
190 | done | ||
191 | |||
192 | for i in ${plugin_list} | ||
193 | do | ||
194 | # abort if empty | ||
195 | [[ -z ${i} ]] && continue | ||
196 | |||
197 | evaluate_table cfg_plugins "where serial='${ALX_SERIAL}' and id='${i}'" | ||
198 | if [[ -x ${ALX_PLUGINS}/${cfg_plugins_plugin}/plugin.sh ]] | ||
199 | then | ||
200 | eval $(${ALX_PLUGINS}/${cfg_plugins_plugin}/plugin.sh menuitem) | ||
201 | |||
202 | # abort if name or exec is empty | ||
203 | [[ -z ${PLUGIN_MENUITEM_NAME} ]] && continue | ||
204 | [[ -z ${PLUGIN_MENUITEM_EXEC} ]] && continue | ||
205 | |||
206 | # new line if x > xres | ||
207 | if [ ${x} -ge ${xres} ] | ||
208 | then | ||
209 | x=50 | ||
210 | y=$((${y} + 80)) | ||
211 | fi | ||
212 | |||
213 | # new row if y > yres | ||
214 | if [ ${y} -ge ${yres} ] | ||
215 | then | ||
216 | x=$((${x} + 120)) | ||
217 | y=50 | ||
218 | |||
219 | # re-check x | ||
220 | [ ${x} -ge ${xres} ] && x=50 | ||
221 | fi | ||
222 | |||
223 | generate_icon \ | ||
224 | --name "${PLUGIN_MENUITEM_NAME}" \ | ||
225 | --command "${progsh_path}/$(fix_whitespaces ${PLUGIN_MENUITEM_NAME})" \ | ||
226 | --icon "${ALX_SESSIONS_ICONS}/$(fix_whitespaces ${PLUGIN_MENUITEM_NAME}).png" \ | ||
227 | --dest "${dest}/$(fix_whitespaces ${PLUGIN_MENUITEM_NAME}).lnk" \ | ||
228 | --xres "${x}" \ | ||
229 | --yres "${y}" \ | ||
230 | --default-icon "default_item.png" | ||
231 | |||
232 | y=$((${y} + 80)) | ||
233 | fi | ||
234 | |||
235 | # unset all variables | ||
236 | unset PLUGIN_MENUITEM_NAME | ||
237 | unset PLUGIN_MENUITEM_EXEC | ||
238 | unset PLUGIN_MENUITEM_PARAM | ||
239 | unset PLUGIN_MENUITEM_WORKDIR | ||
240 | unset PLUGIN_MENUITEM_ICON | ||
241 | done | ||
242 | |||
243 | # add shutdown, reboot icons | ||
244 | for i in shutdown reboot | ||
245 | do | ||
246 | # new line if x > xres | ||
247 | if [ ${x} -ge ${xres} ] | ||
248 | then | ||
249 | x=50 | ||
250 | y=$((${y} + 80)) | ||
251 | fi | ||
252 | |||
253 | # new row if y > yres | ||
254 | if [ ${y} -ge ${yres} ] | ||
255 | then | ||
256 | x=$((${x} + 120)) | ||
257 | y=50 | ||
258 | |||
259 | # re-check x | ||
260 | [ ${x} -ge ${xres} ] && x=50 | ||
261 | fi | ||
262 | |||
263 | case ${i} in | ||
264 | shutdown) name="Herunterfahren" ;; | ||
265 | reboot) name="Neustarten" ;; | ||
266 | esac | ||
267 | |||
268 | generate_icon \ | ||
269 | --name "${name}" \ | ||
270 | --command "/usr/lib/alxconfig-ng/bin/user_${i}.sh" \ | ||
271 | --icon "${ALX_SESSIONS_ICONS}/${i}.png" \ | ||
272 | --dest "${dest}/${i}.lnk" \ | ||
273 | --xres "${x}" \ | ||
274 | --yres "${y}" \ | ||
275 | --icon-width "40" \ | ||
276 | --icon-height "40" | ||
277 | |||
278 | y=$((${y} + 80)) | ||
279 | done | ||
280 | |||
281 | # last but not least gen a icon with some sys informations | ||
282 | local sysinfo | ||
283 | local hostname | ||
284 | local osversion | ||
285 | |||
286 | osversion="$(< /etc/mageversion)" | ||
287 | hostname=$(mysqldo "select hostname from cfg_network where serial='${ALX_SERIAL}'") | ||
288 | sysinfo="Hostname: ${hostname} Serial: #${ALX_SERIAL} OS: alx-${osversion} Kernel: $(uname -r)" | ||
289 | |||
290 | # now get the right position: | ||
291 | # restore orig values of xres | ||
292 | xres="$(( ${xres} + 120 ))" | ||
293 | # default y pos (full yres -22 = cur yres + 58 !) | ||
294 | yres="$(( ${yres} + 58 ))" | ||
295 | # middle of the screen | ||
296 | # (no txt - length required, xtdesk manage that itself) | ||
297 | xres="$(( ${xres} / 2))" | ||
298 | |||
299 | generate_icon \ | ||
300 | --name "${sysinfo}" \ | ||
301 | --command "exit 0" \ | ||
302 | --icon "${ALX_SESSIONS_ICONS}/sysinfo.png" \ | ||
303 | --dest "${dest}/sysinfo.lnk" \ | ||
304 | --xres "${xres}" \ | ||
305 | --yres "${yres}" \ | ||
306 | --icon-width "1" \ | ||
307 | --icon-height "1" | ||
308 | } | ||
309 |