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 2774 - (show annotations) (download)
Thu Feb 11 15:02:04 2016 UTC (8 years, 2 months ago) by niro
File size: 3106 byte(s)
-sanitize variables
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 if [[ $(whoami) = ${MCORE_UNPRIV_USER} ]]
23 then
24 x11runas=""
25 sudo="sudo"
26 else
27 x11runas="x11runas"
28 sudo=""
29 fi
30
31 RUN_IDESK=1
32 case $1 in
33 --no-startup|-n) RUN_IDESK=0 ;;
34 esac
35
36 # get the resolution
37 xinfo=$(${x11runas} xinfo)
38 if [[ $? = 0 ]]
39 then
40 eval ${xinfo}
41 xres="${xorg_width}"
42 yres="${xorg_height}"
43 fi
44
45 # fallback to 1024x768
46 [[ -z ${xres} ]] && xres="1024"
47 [[ -z ${yres} ]] && xres="768"
48
49 # top left edge of the icon is given in config file
50 # remove a little bit to simulate the bottom-right edge
51 xres="$(( ${xres} - 120 ))"
52 yres="$(( ${yres} - 80 ))"
53
54 # clean desktop icon location
55 [ -d ${dest} ] && rm -rf ${dest}
56 [ -f ${rc} ] && rm -f ${rc}
57 install -d ${dest}
58 if [ -f /usr/share/idesk/dot.ideskrc ]
59 then
60 install -m0644 /usr/share/idesk/dot.ideskrc "${rc}"
61 fi
62 chown "${MCORE_UNPRIV_USER}":"${MCORE_UNPRIV_GROUP}" ${dest}
63
64 # clean default reboot,shutdown,sysinfo icon info
65 for i in shutdown reboot sysinfo
66 do
67 ${sudo} ${MCORE_LIBDIR}/idesk-generate-icon-info --del --name "${i}"
68 done
69
70 # default settings
71 declare -i x=50
72 declare -i y=50
73
74 for icon_resource in $(find ${MROOT}/${MCORE_CONFIG_PATH}/icons/info -type f)
75 do
76 # abort if empty
77 [[ -z ${icon_resource} ]] && continue
78
79 # new line if x > xres
80 if [ ${x} -ge ${xres} ]
81 then
82 x=50
83 y=$((${y} + 80))
84 fi
85
86 # new row if y > yres
87 if [ ${y} -ge ${yres} ]
88 then
89 x=$((${x} + 120))
90 y=50
91
92 # re-check x
93 [ ${x} -ge ${xres} ] && x=50
94 fi
95
96 ${MCORE_LIBDIR}/idesk-generate-icon --add --resource "${icon_resource}" --xpos "${x}" --ypos "${y}"
97
98 y=$((${y} + 80))
99 done
100
101 # add shutdown, reboot icons
102 for i in shutdown reboot
103 do
104 # new line if x > xres
105 if [ ${x} -ge ${xres} ]
106 then
107 x=50
108 y=$((${y} + 80))
109 fi
110
111 # new row if y > yres
112 if [ ${y} -ge ${yres} ]
113 then
114 x=$((${x} + 120))
115 y=50
116
117 # re-check x
118 [ ${x} -ge ${xres} ] && x=50
119 fi
120
121 case ${i} in
122 shutdown) name="Herunterfahren"; cmd="poweroff" ;;
123 reboot) name="Neustarten"; cmd="${i}" ;;
124 esac
125
126 ${sudo} ${MCORE_LIBDIR}/idesk-generate-icon \
127 --add \
128 --name "${name}" \
129 --command "sudo @@SBINDIR@@/${cmd}" \
130 --icon "${i}.png" \
131 --filename "${i}" \
132 --xpos "${x}" \
133 --ypos "${y}" \
134 --icon-width "40" \
135 --icon-height "40"
136
137 y=$((${y} + 80))
138 done
139
140 # generate sysinfo
141 ${MCORE_LIBDIR}/idesk-sysinfo
142 ${MCORE_LIBDIR}/idesk-generate-icon --add \
143 --resource "${MROOT}/${MCORE_CONFIG_PATH}/icons/info/sysinfo.${ICON_INFO_SUFFIX}"
144
145 if [[ ${RUN_IDESK} = 1 ]]
146 then
147 # restart idesk
148 if [[ -n $(pidof idesk) ]]
149 then
150 killall idesk
151 fi
152 if [[ -z ${x11runas} ]]
153 then
154 nohup idesk > /dev/null &
155 else
156 ${x11runas} "nohup idesk > /dev/null &"
157 fi
158 fi