Annotation of /mcore-src/trunk/mcore-tools/src/modules/idesk/idesk-generate-all-desktop-icons.in
Parent Directory | Revision Log
Revision 2410 -
(hide annotations)
(download)
Mon Aug 31 09:32:57 2015 UTC (8 years, 9 months ago) by niro
File size: 2701 byte(s)
Mon Aug 31 09:32:57 2015 UTC (8 years, 9 months ago) by niro
File size: 2701 byte(s)
-generate sysinfo icon too
1 | niro | 2358 | #!/bin/bash |
2 | |||
3 | MCORE_LIBDIR="@@MCORE_LIBDIR@@" | ||
4 | source @@SYSCONFDIR@@/mcore/mcore.conf | ||
5 | source ${MCORE_LIBDIR}/include/common.global.class | ||
6 | |||
7 | GLOBAL_PIXMAPS_PATH="@@GLOBAL_PIXMAPS_PATH@@" | ||
8 | LOCAL_PIXMAPS_PATH="${MCORE_CONFIG_PATH}/icons/default" | ||
9 | |||
10 | ICON_INFO_PATH="${MCORE_CONFIG_PATH}/icons/info" | ||
11 | ICON_INFO_SUFFIX="@@ICON_INFO_SUFFIX@@" | ||
12 | ICON_SUFFIX="@@ICON_SUFFIX@@" | ||
13 | |||
14 | niro | 2360 | die() { echo "ERROR: $@"; exit 1; } |
15 | |||
16 | niro | 2358 | dest="${MCORE_UNPRIV_HOME}/.idesktop" |
17 | rc="${MCORE_UNPRIV_HOME}/.ideskrc" | ||
18 | |||
19 | # progs path | ||
20 | progsh_path="${MCORE_UNPRIV_HOME}/.progs" | ||
21 | |||
22 | # get the resolution | ||
23 | eval $(x11runas xinfo) | ||
24 | xres="${xorg_width}" | ||
25 | yres="${xorg_height}" | ||
26 | |||
27 | niro | 2404 | # fallback to 1024x768 |
28 | [[ -z ${xres} ]] && xres="1024" | ||
29 | [[ -z ${yres} ]] && xres="768" | ||
30 | niro | 2397 | |
31 | niro | 2358 | # top left edge of the icon is given in config file |
32 | # remove a little bit to simulate the bottom-right edge | ||
33 | xres="$(( ${xres} - 120 ))" | ||
34 | yres="$(( ${yres} - 80 ))" | ||
35 | |||
36 | # clean desktop icon location | ||
37 | [ -d ${dest} ] && rm -rf ${dest} | ||
38 | [ -f ${rc} ] && rm -f ${rc} | ||
39 | install -d ${dest} | ||
40 | niro | 2403 | chown "${MCORE_UNPRIV_USER}":"${MCORE_UNPRIV_GROUP}" ${dest} |
41 | niro | 2358 | |
42 | niro | 2368 | # clean default reboot,shutdown icon info |
43 | for i in shutdown reboot | ||
44 | do | ||
45 | if [ -f ${MROOT}/${MCORE_CONFIG_PATH}/icons/info/${i}.${ICON_INFO_SUFFIX} ] | ||
46 | then | ||
47 | rm ${MROOT}/${MCORE_CONFIG_PATH}/icons/info/${i}.${ICON_INFO_SUFFIX} | ||
48 | fi | ||
49 | done | ||
50 | |||
51 | niro | 2358 | # default settings |
52 | declare -i x=50 | ||
53 | declare -i y=50 | ||
54 | |||
55 | for icon_resource in $(find ${MROOT}/${MCORE_CONFIG_PATH}/icons/info -type f) | ||
56 | do | ||
57 | # abort if empty | ||
58 | niro | 2367 | [[ -z ${icon_resource} ]] && continue |
59 | niro | 2358 | |
60 | # new line if x > xres | ||
61 | if [ ${x} -ge ${xres} ] | ||
62 | then | ||
63 | x=50 | ||
64 | y=$((${y} + 80)) | ||
65 | fi | ||
66 | |||
67 | # new row if y > yres | ||
68 | if [ ${y} -ge ${yres} ] | ||
69 | then | ||
70 | x=$((${x} + 120)) | ||
71 | y=50 | ||
72 | |||
73 | # re-check x | ||
74 | [ ${x} -ge ${xres} ] && x=50 | ||
75 | fi | ||
76 | |||
77 | niro | 2404 | ${MCORE_LIBDIR}/idesk-generate-icon --add --resource "${icon_resource}" --xpos "${x}" --ypos "${y}" |
78 | niro | 2358 | |
79 | y=$((${y} + 80)) | ||
80 | done | ||
81 | |||
82 | # add shutdown, reboot icons | ||
83 | for i in shutdown reboot | ||
84 | do | ||
85 | # new line if x > xres | ||
86 | if [ ${x} -ge ${xres} ] | ||
87 | then | ||
88 | x=50 | ||
89 | y=$((${y} + 80)) | ||
90 | fi | ||
91 | |||
92 | # new row if y > yres | ||
93 | if [ ${y} -ge ${yres} ] | ||
94 | then | ||
95 | x=$((${x} + 120)) | ||
96 | y=50 | ||
97 | |||
98 | # re-check x | ||
99 | [ ${x} -ge ${xres} ] && x=50 | ||
100 | fi | ||
101 | |||
102 | case ${i} in | ||
103 | shutdown) name="Herunterfahren"; cmd="poweroff" ;; | ||
104 | reboot) name="Neustarten"; cmd="${i}" ;; | ||
105 | esac | ||
106 | |||
107 | ${MCORE_LIBDIR}/idesk-generate-icon \ | ||
108 | niro | 2373 | --add \ |
109 | niro | 2358 | --name "${name}" \ |
110 | --command "sudo /usr/sbin/${cmd}" \ | ||
111 | --icon "${i}.png" \ | ||
112 | --filename "${i}" \ | ||
113 | niro | 2404 | --xpos "${x}" \ |
114 | --ypos "${y}" \ | ||
115 | niro | 2358 | --icon-width "40" \ |
116 | --icon-height "40" | ||
117 | |||
118 | y=$((${y} + 80)) | ||
119 | done | ||
120 | niro | 2366 | |
121 | niro | 2410 | # generate sysinfo |
122 | ${MCORE_LIBDIR}/idesk-sysinfo | ||
123 | ${MCORE_LIBDIR}/idesk-generate-icon --add \ | ||
124 | --resource "${MROOT}/${MCORE_CONFIG_PATH}/icons/info/sysinfo.${ICON_INFO_SUFFIX}" | ||
125 | |||
126 | niro | 2366 | # restart idesk |
127 | killall idesk; x11runas "nohup idesk > /dev/null &" |