16 |
for i in $* |
for i in $* |
17 |
do |
do |
18 |
case $1 in |
case $1 in |
19 |
|
--add|--del|--print) method="${1//--}" ;; |
20 |
--name|-n) shift; name="$1" ;; |
--name|-n) shift; name="$1" ;; |
21 |
--command|-c) shift; command="$1" ;; |
--command|-c) shift; command="$1" ;; |
22 |
--icon|-i) shift; icon="$1" ;; |
--icon|-i) shift; icon="$1" ;; |
31 |
done |
done |
32 |
|
|
33 |
# some sanity checks: |
# some sanity checks: |
34 |
|
[[ -z ${method} ]] && die "No method given" |
35 |
|
|
36 |
# abort if name or command not given |
case ${method} in |
37 |
[[ -z ${name} ]] && die "No name given" |
add) |
38 |
[[ -z ${command} ]] && die "No command given" |
# abort if name or command not given |
39 |
|
[[ -z ${name} ]] && die "No name given" |
40 |
[[ -z ${filename} ]] && filename="${name}" |
[[ -z ${command} ]] && die "No command given" |
41 |
|
|
42 |
# use some defaults for icon, dest, {x,y}res |
[[ -z ${filename} ]] && filename="${name}" |
43 |
[[ -z ${xres} ]] && xres=50 |
|
44 |
[[ -z ${yres} ]] && yres=50 |
# use some defaults for icon, dest, {x,y}res |
45 |
if [[ -z ${icon} ]] |
[[ -z ${xres} ]] && xres=50 |
46 |
then |
[[ -z ${yres} ]] && yres=50 |
47 |
# if no default icon is given use default.png |
if [[ -z ${icon} ]] |
48 |
[[ -z ${deficon} ]] && deficon="default.png" |
then |
49 |
icon="${deficon}" |
# if no default icon is given use default.png |
50 |
fi |
[[ -z ${deficon} ]] && deficon="default.png" |
51 |
|
icon="${deficon}" |
52 |
CONFIG="${ICON_INFO_PATH}/${filename}.${ICON_INFO_SUFFIX}" |
fi |
53 |
clearconfig |
|
54 |
|
CONFIG="${ICON_INFO_PATH}/${filename}.${ICON_INFO_SUFFIX}" |
55 |
addconfig "name=\"${name}\"" |
clearconfig |
56 |
addconfig "filename=\"${filename}\"" |
|
57 |
addconfig "command=\"${command}\"" |
addconfig "name=\"${name}\"" |
58 |
addconfig "icon=\"${icon}\"" |
addconfig "filename=\"${filename}\"" |
59 |
addconfig "deficon=\"${deficon}\"" |
addconfig "command=\"${command}\"" |
60 |
addconfig "xres=\"${xres}\"" |
addconfig "icon=\"${icon}\"" |
61 |
addconfig "yres=\"${yres}\"" |
addconfig "deficon=\"${deficon}\"" |
62 |
if [[ ! -z ${iwidth} ]] |
addconfig "xres=\"${xres}\"" |
63 |
then |
addconfig "yres=\"${yres}\"" |
64 |
addconfig "iwidth=\"${iwidth}\"" |
if [[ ! -z ${iwidth} ]] |
65 |
fi |
then |
66 |
|
addconfig "iwidth=\"${iwidth}\"" |
67 |
if [[ ! -z ${iheight} ]] |
fi |
68 |
then |
|
69 |
addconfig "iheight=\"${iheight}\"" |
if [[ ! -z ${iheight} ]] |
70 |
fi |
then |
71 |
|
addconfig "iheight=\"${iheight}\"" |
72 |
|
fi |
73 |
|
;; |
74 |
|
|
75 |
|
del) |
76 |
|
[[ -z ${name} ]] && die "No name given" |
77 |
|
[[ -z ${filename} ]] && filename="${name}" |
78 |
|
|
79 |
|
if [[ -f ${ICON_INFO_PATH}/${filename}.${ICON_INFO_SUFFIX} ]] |
80 |
|
then |
81 |
|
rm "${ICON_INFO_PATH}/${filename}.${ICON_INFO_SUFFIX}" |
82 |
|
fi |
83 |
|
;; |
84 |
|
|
85 |
|
print) |
86 |
|
list_files_in_directory "${ICON_INFO_PATH}" |
87 |
|
;; |
88 |
|
esac |