Magellan Linux

Contents of /mcore-src/trunk/mcore-tools/src/modules/idesk/idesk-generate-all-desktop-icons.in

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2368 - (show annotations) (download)
Wed Aug 26 10:47:17 2015 UTC (8 years, 8 months ago) by niro
File size: 2361 byte(s)
-remove shutdown,reboot info before creating all desktop icons
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 # top left edge of the icon is given in config file
28 # remove a little bit to simulate the bottom-right edge
29 xres="$(( ${xres} - 120 ))"
30 yres="$(( ${yres} - 80 ))"
31
32 # clean desktop icon location
33 [ -d ${dest} ] && rm -rf ${dest}
34 [ -f ${rc} ] && rm -f ${rc}
35 install -d ${dest}
36
37 # clean default reboot,shutdown icon info
38 for i in shutdown reboot
39 do
40 if [ -f ${MROOT}/${MCORE_CONFIG_PATH}/icons/info/${i}.${ICON_INFO_SUFFIX} ]
41 then
42 rm ${MROOT}/${MCORE_CONFIG_PATH}/icons/info/${i}.${ICON_INFO_SUFFIX}
43 fi
44 done
45
46 # default settings
47 declare -i x=50
48 declare -i y=50
49
50 for icon_resource in $(find ${MROOT}/${MCORE_CONFIG_PATH}/icons/info -type f)
51 do
52 # abort if empty
53 [[ -z ${icon_resource} ]] && continue
54
55 # new line if x > xres
56 if [ ${x} -ge ${xres} ]
57 then
58 x=50
59 y=$((${y} + 80))
60 fi
61
62 # new row if y > yres
63 if [ ${y} -ge ${yres} ]
64 then
65 x=$((${x} + 120))
66 y=50
67
68 # re-check x
69 [ ${x} -ge ${xres} ] && x=50
70 fi
71
72 ${MCORE_LIBDIR}/idesk-generate-icon --resource "${icon_resource}" --xres "${x}" --yres "${y}"
73
74 y=$((${y} + 80))
75 done
76
77 # add shutdown, reboot icons
78 for i in shutdown reboot
79 do
80 # new line if x > xres
81 if [ ${x} -ge ${xres} ]
82 then
83 x=50
84 y=$((${y} + 80))
85 fi
86
87 # new row if y > yres
88 if [ ${y} -ge ${yres} ]
89 then
90 x=$((${x} + 120))
91 y=50
92
93 # re-check x
94 [ ${x} -ge ${xres} ] && x=50
95 fi
96
97 case ${i} in
98 shutdown) name="Herunterfahren"; cmd="poweroff" ;;
99 reboot) name="Neustarten"; cmd="${i}" ;;
100 esac
101
102 ${MCORE_LIBDIR}/idesk-generate-icon \
103 --name "${name}" \
104 --command "sudo /usr/sbin/${cmd}" \
105 --icon "${i}.png" \
106 --filename "${i}" \
107 --xres "${x}" \
108 --yres "${y}" \
109 --icon-width "40" \
110 --icon-height "40"
111
112 y=$((${y} + 80))
113 done
114
115
116 # restart idesk
117 killall idesk; x11runas "nohup idesk > /dev/null &"