Contents of /mcore-src/trunk/mcore-tools/src/modules/fluxbox/fluxbox.control.class.in
Parent Directory | Revision Log
Revision 2770 -
(show annotations)
(download)
Thu Feb 11 14:18:05 2016 UTC (8 years, 2 months ago) by niro
File size: 5334 byte(s)
Thu Feb 11 14:18:05 2016 UTC (8 years, 2 months ago) by niro
File size: 5334 byte(s)
-push_config_80_fluxbox_theme(): fixed wrong database table
1 | # $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() |
9 | { |
10 | local serial="${CLASS_ARGV[0]}" |
11 | control_client "${serial}" help fluxbox.menuitem |
12 | } |
13 | |
14 | set_fluxbox_menuitem() |
15 | { |
16 | local serial="${CLASS_ARGV[0]}" |
17 | local action="${CLASS_ARGV[1]}" |
18 | local name="${CLASS_ARGV[2]}" |
19 | local exec="${CLASS_ARGV[3]}" |
20 | local workdir="${CLASS_ARGV[4]}" |
21 | local icon="${CLASS_ARGV[5]}" |
22 | local id |
23 | local enabled |
24 | |
25 | case "${action}" in |
26 | add) enabled=1 ;; |
27 | del) enabled=0 ;; |
28 | *) |
29 | eecho "Unknown action '${action}'" |
30 | return 1 |
31 | ;; |
32 | 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() |
50 | { |
51 | 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 |
59 | local id |
60 | |
61 | values=$(mysqldo "select id from cfg_fluxbox_menuitem where serial='${serial}';") |
62 | for id in ${values} |
63 | do |
64 | evaluate_table_xml cfg_fluxbox_menuitem "where serial='${serial}'" |
65 | if [[ -z ${cfg_fluxbox_menuitem_name} ]] |
66 | then |
67 | eecho "Name must not be empty id->'${id}'" |
68 | continue |
69 | fi |
70 | if [[ -z ${cfg_fluxbox_menuitem_enabled} ]] |
71 | then |
72 | eecho "Enabled must not be empty id->'${id}'" |
73 | continue |
74 | fi |
75 | 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 |
168 | } |
169 | |
170 | help_fluxbox_theme() |
171 | { |
172 | local serial="${CLASS_ARGV[0]}" |
173 | control_client "${serial}" help fluxbox.menuitem |
174 | } |
175 | |
176 | set_fluxbox_theme() |
177 | { |
178 | local serial="${CLASS_ARGV[0]}" |
179 | local theme="${CLASS_ARGV[1]}" |
180 | |
181 | import_resource cfg_fluxbox_theme "${serial}" theme "${theme}" |
182 | } |
183 | |
184 | control_fluxbox_theme() |
185 | { |
186 | 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 |
194 | |
195 | value=$(mysqldo "select theme from cfg_fluxbox.theme where serial='${serial}'") |
196 | if [[ -z ${value} ]] || [[ ${value} = NULL ]] |
197 | then |
198 | decho "No theme retrieved" |
199 | else |
200 | control_client "${serial}" set fluxbox.theme "${value}" |
201 | 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 | } |