Magellan Linux

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2551 - (show annotations) (download)
Wed Sep 16 13:28:56 2015 UTC (8 years, 7 months ago) by niro
File size: 2270 byte(s)
-try to find an existing icon with the same name first
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
13 die() { echo "ERROR: $@"; exit 1; }
14
15 # very basic getops
16 for i in $*
17 do
18 case $1 in
19 --add|--del|--print) method="${1//--}" ;;
20 --name|-n) shift; name="$1" ;;
21 --command|-c) shift; command="$1" ;;
22 --icon|-i) shift; icon="$1" ;;
23 --filename|-f) shift; filename="$1" ;;
24 --xpos|-x) shift; xpos="$1" ;;
25 --ypos|-y) shift; ypos="$1" ;;
26 --icon-width|-w) shift; iwidth="$1" ;;
27 --icon-height|-h) shift; iheight="$1" ;;
28 --default-icon) shift; deficon="$1" ;;
29 esac
30 shift
31 done
32
33 # some sanity checks:
34 [[ -z ${method} ]] && die "No method given"
35
36 case ${method} in
37 add)
38 # abort if name or command not given
39 [[ -z ${name} ]] && die "No name given"
40 [[ -z ${command} ]] && die "No command given"
41
42 [[ -z ${filename} ]] && filename="${name}"
43
44 # use some defaults for icon, dest, {x,y}pos
45 [[ -z ${xpos} ]] && xpos=50
46 [[ -z ${ypos} ]] && ypos=50
47 # try to find an existing icon with the same name first
48 if [[ -z ${icon} ]]
49 then
50 [[ -f ${GLOBAL_PIXMAPS_PATH}/${name}.png ]] && icon="${name}.png"
51 fi
52 if [[ -z ${icon} ]]
53 then
54 # if no default icon is given use default.png
55 [[ -z ${deficon} ]] && deficon="default.png"
56 icon="${deficon}"
57 fi
58
59 CONFIG="${ICON_INFO_PATH}/${filename}.${ICON_INFO_SUFFIX}"
60 clearconfig
61
62 addconfig "name=\"${name}\""
63 addconfig "filename=\"${filename}\""
64 addconfig "command=\"${command}\""
65 addconfig "icon=\"${icon}\""
66 addconfig "deficon=\"${deficon}\""
67 addconfig "xpos=\"${xpos}\""
68 addconfig "ypos=\"${ypos}\""
69 if [[ ! -z ${iwidth} ]]
70 then
71 addconfig "iwidth=\"${iwidth}\""
72 fi
73
74 if [[ ! -z ${iheight} ]]
75 then
76 addconfig "iheight=\"${iheight}\""
77 fi
78 ;;
79
80 del)
81 [[ -z ${name} ]] && die "No name given"
82 [[ -z ${filename} ]] && filename="${name}"
83
84 if [[ -f ${ICON_INFO_PATH}/${filename}.${ICON_INFO_SUFFIX} ]]
85 then
86 rm "${ICON_INFO_PATH}/${filename}.${ICON_INFO_SUFFIX}"
87 fi
88 ;;
89
90 print)
91 list_files_in_directory "${ICON_INFO_PATH}"
92 ;;
93 esac