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