Contents of /mcore-src/trunk/mcore-tools/src/modules/idesk/idesk-generate-all-desktop-icons.in
Parent Directory | Revision Log
Revision 2397 -
(show annotations)
(download)
Fri Aug 28 09:12:06 2015 UTC (8 years, 8 months ago) by niro
File size: 2461 byte(s)
Fri Aug 28 09:12:06 2015 UTC (8 years, 8 months ago) by niro
File size: 2461 byte(s)
-fallback to 800x600 resolution if xinfo fails
1 | #!/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 | die() { echo "ERROR: $@"; exit 1; } |
15 | |
16 | 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 | # fallback to 800x600 |
28 | [[ -z ${xres} ]] && xres="800" |
29 | [[ -z ${yres} ]] && xres="600" |
30 | |
31 | # 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 | |
41 | # clean default reboot,shutdown icon info |
42 | for i in shutdown reboot |
43 | do |
44 | if [ -f ${MROOT}/${MCORE_CONFIG_PATH}/icons/info/${i}.${ICON_INFO_SUFFIX} ] |
45 | then |
46 | rm ${MROOT}/${MCORE_CONFIG_PATH}/icons/info/${i}.${ICON_INFO_SUFFIX} |
47 | fi |
48 | done |
49 | |
50 | # default settings |
51 | declare -i x=50 |
52 | declare -i y=50 |
53 | |
54 | for icon_resource in $(find ${MROOT}/${MCORE_CONFIG_PATH}/icons/info -type f) |
55 | do |
56 | # abort if empty |
57 | [[ -z ${icon_resource} ]] && continue |
58 | |
59 | # new line if x > xres |
60 | if [ ${x} -ge ${xres} ] |
61 | then |
62 | x=50 |
63 | y=$((${y} + 80)) |
64 | fi |
65 | |
66 | # new row if y > yres |
67 | if [ ${y} -ge ${yres} ] |
68 | then |
69 | x=$((${x} + 120)) |
70 | y=50 |
71 | |
72 | # re-check x |
73 | [ ${x} -ge ${xres} ] && x=50 |
74 | fi |
75 | |
76 | ${MCORE_LIBDIR}/idesk-generate-icon --add --resource "${icon_resource}" --xres "${x}" --yres "${y}" |
77 | |
78 | y=$((${y} + 80)) |
79 | done |
80 | |
81 | # add shutdown, reboot icons |
82 | for i in shutdown reboot |
83 | do |
84 | # new line if x > xres |
85 | if [ ${x} -ge ${xres} ] |
86 | then |
87 | x=50 |
88 | y=$((${y} + 80)) |
89 | fi |
90 | |
91 | # new row if y > yres |
92 | if [ ${y} -ge ${yres} ] |
93 | then |
94 | x=$((${x} + 120)) |
95 | y=50 |
96 | |
97 | # re-check x |
98 | [ ${x} -ge ${xres} ] && x=50 |
99 | fi |
100 | |
101 | case ${i} in |
102 | shutdown) name="Herunterfahren"; cmd="poweroff" ;; |
103 | reboot) name="Neustarten"; cmd="${i}" ;; |
104 | esac |
105 | |
106 | ${MCORE_LIBDIR}/idesk-generate-icon \ |
107 | --add \ |
108 | --name "${name}" \ |
109 | --command "sudo /usr/sbin/${cmd}" \ |
110 | --icon "${i}.png" \ |
111 | --filename "${i}" \ |
112 | --xres "${x}" \ |
113 | --yres "${y}" \ |
114 | --icon-width "40" \ |
115 | --icon-height "40" |
116 | |
117 | y=$((${y} + 80)) |
118 | done |
119 | |
120 | # restart idesk |
121 | killall idesk; x11runas "nohup idesk > /dev/null &" |