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 2404 - (show annotations) (download)
Mon Aug 31 08:57:10 2015 UTC (8 years, 7 months ago) by niro
File size: 2524 byte(s)
-renamed icon position variables from {x,y}res to {x,y}pos
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 1024x768
28 [[ -z ${xres} ]] && xres="1024"
29 [[ -z ${yres} ]] && xres="768"
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 chown "${MCORE_UNPRIV_USER}":"${MCORE_UNPRIV_GROUP}" ${dest}
41
42 # 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 # 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 [[ -z ${icon_resource} ]] && continue
59
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 ${MCORE_LIBDIR}/idesk-generate-icon --add --resource "${icon_resource}" --xpos "${x}" --ypos "${y}"
78
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 --add \
109 --name "${name}" \
110 --command "sudo /usr/sbin/${cmd}" \
111 --icon "${i}.png" \
112 --filename "${i}" \
113 --xpos "${x}" \
114 --ypos "${y}" \
115 --icon-width "40" \
116 --icon-height "40"
117
118 y=$((${y} + 80))
119 done
120
121 # restart idesk
122 killall idesk; x11runas "nohup idesk > /dev/null &"