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