Magellan Linux

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2775 - (hide annotations) (download)
Thu Feb 11 15:02:35 2016 UTC (8 years, 3 months ago) by niro
File size: 3106 byte(s)
-fixed a typo xres= -> yres
1 niro 2358 #!/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 niro 2360 die() { echo "ERROR: $@"; exit 1; }
15    
16 niro 2358 dest="${MCORE_UNPRIV_HOME}/.idesktop"
17     rc="${MCORE_UNPRIV_HOME}/.ideskrc"
18    
19     # progs path
20     progsh_path="${MCORE_UNPRIV_HOME}/.progs"
21    
22 niro 2415 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 niro 2358 # get the resolution
37 niro 2774 xinfo=$(${x11runas} xinfo)
38     if [[ $? = 0 ]]
39     then
40     eval ${xinfo}
41     xres="${xorg_width}"
42     yres="${xorg_height}"
43     fi
44 niro 2358
45 niro 2404 # fallback to 1024x768
46     [[ -z ${xres} ]] && xres="1024"
47 niro 2775 [[ -z ${yres} ]] && yres="768"
48 niro 2397
49 niro 2358 # 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 niro 2415 if [ -f /usr/share/idesk/dot.ideskrc ]
59     then
60     install -m0644 /usr/share/idesk/dot.ideskrc "${rc}"
61     fi
62 niro 2403 chown "${MCORE_UNPRIV_USER}":"${MCORE_UNPRIV_GROUP}" ${dest}
63 niro 2358
64 niro 2415 # clean default reboot,shutdown,sysinfo icon info
65     for i in shutdown reboot sysinfo
66 niro 2368 do
67 niro 2415 ${sudo} ${MCORE_LIBDIR}/idesk-generate-icon-info --del --name "${i}"
68 niro 2368 done
69    
70 niro 2358 # 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 niro 2367 [[ -z ${icon_resource} ]] && continue
78 niro 2358
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 niro 2404 ${MCORE_LIBDIR}/idesk-generate-icon --add --resource "${icon_resource}" --xpos "${x}" --ypos "${y}"
97 niro 2358
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 niro 2415 ${sudo} ${MCORE_LIBDIR}/idesk-generate-icon \
127 niro 2373 --add \
128 niro 2358 --name "${name}" \
129 niro 2691 --command "sudo @@SBINDIR@@/${cmd}" \
130 niro 2358 --icon "${i}.png" \
131     --filename "${i}" \
132 niro 2404 --xpos "${x}" \
133     --ypos "${y}" \
134 niro 2358 --icon-width "40" \
135     --icon-height "40"
136    
137     y=$((${y} + 80))
138     done
139 niro 2366
140 niro 2410 # 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 niro 2415 if [[ ${RUN_IDESK} = 1 ]]
146 niro 2411 then
147 niro 2415 # 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 niro 2411 fi