15 |
local workdir="${CLASS_ARGV[4]}" |
local workdir="${CLASS_ARGV[4]}" |
16 |
local icon="${CLASS_ARGV[5]}" |
local icon="${CLASS_ARGV[5]}" |
17 |
local id |
local id |
18 |
|
local enabled |
19 |
|
|
20 |
case "${action}" in |
case "${action}" in |
21 |
add) id=$(mysqldo "select id from cfg_fluxbox_menuitem where serial='${serial}' and name='${name}';") |
add) enabled=1 ;; |
22 |
if [[ -n ${id} ]] |
del) enabled=0 ;; |
23 |
then |
*) |
24 |
mysqldo "update cfg_fluxbox_menuitem set name='${name}', exec='${exec}', workdir='${workdir}', icon='${icon}' where id=${id};" |
eecho "Unknown action '${action}'" |
25 |
else |
return 1 |
|
mysqldo "insert into cfg_fluxbox_menuitem(serial,name,exec,workdir,icon) values('${serial}','${name}','${exec}','${workdir}','${icon}');" |
|
|
fi |
|
|
;; |
|
|
del) |
|
|
if [[ -n ${name} ]] |
|
|
then |
|
|
mysqldo "delete from cfg_fluxbox_menuitem where serial='${serial}' and name='${name}';" |
|
|
else |
|
|
mysqldo "delete from cfg_fluxbox_menuitem where serial='${serial}';" |
|
|
fi |
|
26 |
;; |
;; |
27 |
esac |
esac |
28 |
|
|
29 |
|
id=$(mysqldo "select id from cfg_fluxbox_menuitem where serial='${serial}' and name='${name}';") |
30 |
|
if [[ -n ${id} ]] |
31 |
|
then |
32 |
|
mysqldo "update cfg_fluxbox_menuitem set name='${name}', exec='${exec}', workdir='${workdir}', icon='${icon}', enabled='${enabled}' where id=${id};" |
33 |
|
else |
34 |
|
mysqldo "insert into cfg_fluxbox_menuitem(serial,name,exec,workdir,icon,enabled) values('${serial}','${name}','${exec}','${workdir}','${icon}','${enabled}');" |
35 |
|
fi |
36 |
} |
} |
37 |
|
|
38 |
control_fluxbox_menuitem() |
control_fluxbox_menuitem() |
55 |
eecho "Exec must not be empty id->'${id}'" |
eecho "Exec must not be empty id->'${id}'" |
56 |
continue |
continue |
57 |
fi |
fi |
58 |
control fluxbox.menitem "${serial}" "${cfg_fluxbox_menuitem_name}" "${cfg_fluxbox_menuitem_exec}" "${cfg_fluxbox_menuitem_workdir}" "${cfg_fluxbox_menuitem_icon}" |
if [[ -z ${cfg_fluxbox_menuitem_enabled} ]] |
59 |
|
then |
60 |
|
eecho "Enabled must not be empty id->'${id}'" |
61 |
|
continue |
62 |
|
fi |
63 |
|
if [[ ${cfg_fluxbox_menuitem_enabled} = 1 ]] |
64 |
|
then |
65 |
|
control_client "${serial}" set fluxbox.menuitem add "${cfg_fluxbox_menuitem_name}" "${cfg_fluxbox_menuitem_exec}" "${cfg_fluxbox_menuitem_workdir}" "${cfg_fluxbox_menuitem_icon}" |
66 |
|
elif [[ ${cfg_fluxbox_menuitem_enabled} = 0 ]] |
67 |
|
control_client "${serial}" set fluxbox.menuitem del "${cfg_fluxbox_menuitem_name}" |
68 |
|
# remove from database too |
69 |
|
mysqldo "delete from cfg_fluxbox_menuitem where id='${id}';" |
70 |
|
else |
71 |
|
eecho "unknown enabled value id->'${id}', cfg_fluxbox_menuitem_enabled -> '${cfg_fluxbox_menuitem_enabled}'" |
72 |
|
return 1 |
73 |
done |
done |
74 |
} |
} |
75 |
|
|