1 |
# $Id$ |
# $Id$ |
2 |
|
|
3 |
|
push_firstboot 80_fluxbox_menuitem |
4 |
|
|
5 |
|
push_config 80_fluxbox_menuitem |
6 |
|
push_config 80_fluxbox_autostart |
7 |
|
|
8 |
help_fluxbox_menuitem() |
help_fluxbox_menuitem() |
9 |
{ |
{ |
10 |
local serial="${CLASS_ARGV[0]}" |
local serial="${CLASS_ARGV[0]}" |
20 |
local workdir="${CLASS_ARGV[4]}" |
local workdir="${CLASS_ARGV[4]}" |
21 |
local icon="${CLASS_ARGV[5]}" |
local icon="${CLASS_ARGV[5]}" |
22 |
local id |
local id |
23 |
|
local enabled |
24 |
|
|
25 |
case "${action}" in |
case "${action}" in |
26 |
add) id=$(mysqldo "select id from cfg_fluxbox_menuitem where serial='${serial}' and name='${name}';") |
add) enabled=1 ;; |
27 |
if [[ -n ${id} ]] |
del) enabled=0 ;; |
28 |
then |
*) |
29 |
mysqldo "update cfg_fluxbox_menuitem set name='${name}', exec='${exec}', workdir='${workdir}', icon='${icon}' where id=${id};" |
eecho "Unknown action '${action}'" |
30 |
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 |
|
31 |
;; |
;; |
32 |
esac |
esac |
33 |
|
|
34 |
|
if [[ -z ${name} ]] |
35 |
|
then |
36 |
|
eecho "No name given" |
37 |
|
return 1 |
38 |
|
fi |
39 |
|
|
40 |
|
id=$(mysqldo "select id from cfg_fluxbox_menuitem where serial='${serial}' and name='${name}';") |
41 |
|
if [[ -n ${id} ]] |
42 |
|
then |
43 |
|
mysqldo "update cfg_fluxbox_menuitem set name='${name}', exec='${exec}', workdir='${workdir}', icon='${icon}', enabled='${enabled}' where id=${id};" |
44 |
|
else |
45 |
|
mysqldo "insert into cfg_fluxbox_menuitem(serial,name,exec,workdir,icon,enabled) values('${serial}','${name}','${exec}','${workdir}','${icon}','${enabled}');" |
46 |
|
fi |
47 |
} |
} |
48 |
|
|
49 |
control_fluxbox_menuitem() |
control_fluxbox_menuitem() |
50 |
{ |
{ |
51 |
local serial="${CLASS_ARGV[0]}" |
local serial="${CLASS_ARGV[0]}" |
52 |
|
push_config_80_fluxbox_menuitem "${serial}" |
53 |
|
} |
54 |
|
|
55 |
|
push_config_80_fluxbox_menuitem() |
56 |
|
{ |
57 |
|
local serial="$1" |
58 |
local values |
local values |
59 |
local id |
local id |
60 |
|
|
67 |
eecho "Name must not be empty id->'${id}'" |
eecho "Name must not be empty id->'${id}'" |
68 |
continue |
continue |
69 |
fi |
fi |
70 |
if [[ -z ${cfg_fluxbox_menuitem_exec} ]] |
if [[ -z ${cfg_fluxbox_menuitem_enabled} ]] |
71 |
then |
then |
72 |
eecho "Exec must not be empty id->'${id}'" |
eecho "Enabled must not be empty id->'${id}'" |
73 |
continue |
continue |
74 |
fi |
fi |
75 |
control_client "${serial}" fluxbox.menuitem add "${cfg_fluxbox_menuitem_name}" "${cfg_fluxbox_menuitem_exec}" "${cfg_fluxbox_menuitem_workdir}" "${cfg_fluxbox_menuitem_icon}" |
if [[ ${cfg_fluxbox_menuitem_enabled} = 1 ]] |
76 |
|
then |
77 |
|
control_client "${serial}" set fluxbox.menuitem add "${cfg_fluxbox_menuitem_name}" "${cfg_fluxbox_menuitem_exec}" "${cfg_fluxbox_menuitem_workdir}" "${cfg_fluxbox_menuitem_icon}" |
78 |
|
elif [[ ${cfg_fluxbox_menuitem_enabled} = 0 ]] |
79 |
|
then |
80 |
|
control_client "${serial}" set fluxbox.menuitem del "${cfg_fluxbox_menuitem_name}" |
81 |
|
# remove from database too |
82 |
|
mysqldo "delete from cfg_fluxbox_menuitem where id='${id}';" |
83 |
|
else |
84 |
|
eecho "unknown enabled value id->'${id}', cfg_fluxbox_menuitem_enabled -> '${cfg_fluxbox_menuitem_enabled}'" |
85 |
|
return 1 |
86 |
|
fi |
87 |
|
done |
88 |
|
} |
89 |
|
|
90 |
|
help_fluxbox_autostart() |
91 |
|
{ |
92 |
|
local serial="${CLASS_ARGV[0]}" |
93 |
|
control_client "${serial}" help fluxbox.autostart |
94 |
|
} |
95 |
|
|
96 |
|
set_fluxbox_autostart() |
97 |
|
{ |
98 |
|
local serial="${CLASS_ARGV[0]}" |
99 |
|
local action="${CLASS_ARGV[1]}" |
100 |
|
local name="${CLASS_ARGV[2]}" |
101 |
|
local exec="${CLASS_ARGV[3]}" |
102 |
|
local id |
103 |
|
local enabled |
104 |
|
|
105 |
|
case "${action}" in |
106 |
|
add) enabled=1 ;; |
107 |
|
del) enabled=0 ;; |
108 |
|
*) |
109 |
|
eecho "Unknown action '${action}'" |
110 |
|
return 1 |
111 |
|
;; |
112 |
|
esac |
113 |
|
|
114 |
|
if [[ -z ${name} ]] |
115 |
|
then |
116 |
|
eecho "No name given" |
117 |
|
return 1 |
118 |
|
fi |
119 |
|
|
120 |
|
id=$(mysqldo "select id from cfg_fluxbox_autostart where serial='${serial}' and name='${name}';") |
121 |
|
if [[ -n ${id} ]] |
122 |
|
then |
123 |
|
mysqldo "update cfg_fluxbox_autostart set name='${name}', exec='${exec}', enabled='${enabled}' where id=${id};" |
124 |
|
else |
125 |
|
mysqldo "insert into cfg_fluxbox_autostart(serial,name,exec,enabled) values('${serial}','${name}','${exec}','${enabled}');" |
126 |
|
fi |
127 |
|
} |
128 |
|
|
129 |
|
control_fluxbox_autostart() |
130 |
|
{ |
131 |
|
local serial="${CLASS_ARGV[0]}" |
132 |
|
push_config_80_fluxbox_autostart "${serial}" |
133 |
|
} |
134 |
|
|
135 |
|
push_config_80_fluxbox_autostart() |
136 |
|
{ |
137 |
|
local serial="$1" |
138 |
|
local values |
139 |
|
local id |
140 |
|
|
141 |
|
values=$(mysqldo "select id from cfg_fluxbox_autostart where serial='${serial}';") |
142 |
|
for id in ${values} |
143 |
|
do |
144 |
|
evaluate_table_xml cfg_fluxbox_autostart "where serial='${serial}'" |
145 |
|
if [[ -z ${cfg_fluxbox_autostart_name} ]] |
146 |
|
then |
147 |
|
eecho "Name must not be empty id->'${id}'" |
148 |
|
continue |
149 |
|
fi |
150 |
|
if [[ -z ${cfg_fluxbox_autostart_enabled} ]] |
151 |
|
then |
152 |
|
eecho "Enabled must not be empty id->'${id}'" |
153 |
|
continue |
154 |
|
fi |
155 |
|
if [[ ${cfg_fluxbox_autostart_enabled} = 1 ]] |
156 |
|
then |
157 |
|
control_client "${serial}" set fluxbox.autostart add "${cfg_fluxbox_autostart_name}" "${cfg_fluxbox_autostart_exec}" |
158 |
|
elif [[ ${cfg_fluxbox_autostart_enabled} = 0 ]] |
159 |
|
then |
160 |
|
control_client "${serial}" set fluxbox.autostart del "${cfg_fluxbox_autostart_name}" |
161 |
|
# remove from database too |
162 |
|
mysqldo "delete from cfg_fluxbox_autostart where id='${id}';" |
163 |
|
else |
164 |
|
eecho "unknown enabled value id->'${id}', cfg_fluxbox_autostart_enabled -> '${cfg_fluxbox_autostart_enabled}'" |
165 |
|
return 1 |
166 |
|
fi |
167 |
done |
done |
168 |
} |
} |
169 |
|
|
184 |
control_fluxbox_theme() |
control_fluxbox_theme() |
185 |
{ |
{ |
186 |
local serial="${CLASS_ARGV[0]}" |
local serial="${CLASS_ARGV[0]}" |
187 |
|
push_config_fluxbox_theme "${serial}" |
188 |
|
} |
189 |
|
|
190 |
|
push_config_80_fluxbox_theme() |
191 |
|
{ |
192 |
|
local serial="$1" |
193 |
local value |
local value |
194 |
|
|
195 |
value=$(mysqldo "select theme from cfg_fluxbox.menuitem where serial='${serial}'") |
value=$(mysqldo "select theme from cfg_fluxbox.theme where serial='${serial}'") |
196 |
if [[ -z ${value} ]] || [[ ${value} = NULL ]] |
if [[ -z ${value} ]] || [[ ${value} = NULL ]] |
197 |
then |
then |
198 |
decho "No theme retrieved" |
decho "No theme retrieved" |
200 |
control_client "${serial}" set fluxbox.theme "${value}" |
control_client "${serial}" set fluxbox.theme "${value}" |
201 |
fi |
fi |
202 |
} |
} |
203 |
|
|
204 |
|
push_firstboot_80_fluxbox_menuitem() |
205 |
|
{ |
206 |
|
local serial="$1" |
207 |
|
local ids |
208 |
|
|
209 |
|
ids=$(mysqldo "select id from cfg_fluxbox_menuitem where serial='${serial}';") |
210 |
|
if [[ -z ${ids} ]] || [[ ${ids} = NULL ]] |
211 |
|
then |
212 |
|
# create a empty menu, just delete all entries |
213 |
|
control_client "${serial}" set fluxbox.menuitem del |
214 |
|
fi |
215 |
|
} |