Magellan Linux

Contents of /mcore-src/trunk/mcore-tools/src/modules/idesk/idesk-generate-icon.in

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2358 - (show annotations) (download)
Tue Aug 25 09:51:46 2015 UTC (8 years, 8 months ago) by niro
File size: 3341 byte(s)
-basic idesk helpers
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 # very basic getops
15 for i in $*
16 do
17 case $1 in
18 --resouce|-r) shift; icon_resource="$1" ;;
19 --name|-n) shift; argv_name="$1" ;;
20 --command|-c) shift; argv_command="$1" ;;
21 --icon|-i) shift; argv_icon="$1" ;;
22 --filename|-f) shift; argv_filename="$1" ;;
23 --xres|-x) shift; argv_xres="$1" ;;
24 --yres|-y) shift; argv_yres="$1" ;;
25 --icon-width|-w) shift; argv_iwidth="$1" ;;
26 --icon-height|-h) shift; argv_iheight="$1" ;;
27 --default-icon) shift; argv_deficon="$1" ;;
28 esac
29 shift
30 done
31
32 # some sanity checks:
33
34 if [[ -n ${icon_resource} ]]
35 then
36 [[ -f ${icon_resource} ]] || die "Icon resource '${icon_resource}' does not exist"
37 else
38 name="${argv_name}"
39 command="${argv_command}"
40 filename="${argv_filename}"
41 xres="${argv_xres}"
42 yres="${argv_yres}"
43 icon="${argv_icon}"
44 deficon="${argv_deficon}"
45 iwidth="${argv_iwidth}"
46 iheight="${argv_iheight}"
47
48 # abort if name or command not given
49 [[ -z ${name} ]] && die "No name given"
50 [[ -z ${command} ]] && die "No command given"
51
52 [[ -z ${filename} ]] && filename="${name}"
53
54 # use some defaults for icon, dest, {x,y}res
55 [[ -z ${xres} ]] && xres=50
56 [[ -z ${yres} ]] && xres=50
57 if [[ -z ${icon} ]]
58 then
59 # if no default icon is given use default.png
60 [[ -z ${deficon} ]] && deficon="default.png"
61 icon="${deficon}"
62 fi
63
64 ${MCORE_LIBDIR}/idesk-generate-icon-info \
65 --name "${name}" \
66 --command "${command}" \
67 --icon "${icon}" \
68 --filename "${filename}" \
69 --xres "${xres}" \
70 --yres "${yres}" \
71 --icon-width "${iwidth}" \
72 --icon-height "${iheight}" \
73 --default-icon "${deficon}"
74
75 icon_resource="${ICON_INFO_PATH}/${filename}.${ICON_INFO_SUFFIX}"
76 fi
77
78 source "${icon_resource}"
79
80 # icon resource overrides
81 [[ -n ${argv_name} ]] && name="${argv_name}"
82 [[ -n ${argv_command} ]] && command="${argv_command}"
83 [[ -n ${argv_filename} ]] && filename="${argv_filename}"
84 [[ -n ${argv_xres} ]] && xres="${argv_xres}"
85 [[ -n ${argv_yres} ]] && yres="${argv_yres}"
86 [[ -n ${argv_icon} ]] && icon="${argv_icon}"
87 [[ -n ${argv_deficon} ]] && deficon="${argv_deficon}"
88 [[ -n ${argv_iwidth} ]] && iwidth="${argv_iwidth}"
89 [[ -n ${argv_iheight} ]] && iheight="${argv_iheight}"
90
91 [[ -z ${filename} ]] && die "Error \$filename is empty in icon resource '${icon_resource}'"
92
93 # get the right icon path, local overrides global
94 [[ -f ${GLOBAL_PIXMAPS_PATH}/${icon} ]] && icon_path="${GLOBAL_PIXMAPS_PATH}"
95 [[ -f ${LOCAL_PIXMAPS_PATH}/${icon} ]] && icon_path="${LOCAL_PIXMAPS_PATH}"
96 # no icon found, use default icon
97 if [[ -z ${icon_path} ]]
98 then
99 icon_path="${GLOBAL_PIXMAPS_PATH}"
100 icon="default.png"
101 fi
102
103 CONFIG="${MCORE_UNPRIV_HOME}/.idesktop/${filename}.${ICON_SUFFIX}"
104 clearconfig
105
106 addconfig 'table Icon'
107 addconfig " Caption: ${name}"
108 addconfig " Command: ${command}"
109 addconfig " Icon: ${icon_path}/${icon}"
110 addconfig " X: ${xres}"
111 addconfig " Y: ${yres}"
112
113 # add these only if not zero
114 if [[ ! -z ${iwidth} ]] && [[ ! -z ${iheight} ]]
115 then
116 addconfig " Width: ${iwidth}"
117 addconfig " Height: ${iheight}"
118 fi
119
120 addconfig 'end'