Contents of /mcore-src/trunk/mcore-tools/src/modules/fluxbox/fluxbox.control.class.in
Parent Directory | Revision Log
Revision 2760 -
(show annotations)
(download)
Tue Feb 2 14:49:47 2016 UTC (8 years, 2 months ago) by niro
File size: 4872 byte(s)
Tue Feb 2 14:49:47 2016 UTC (8 years, 2 months ago) by niro
File size: 4872 byte(s)
-fixed a typo
1 | # $Id$ |
2 | |
3 | push_config 80_fluxbox_menuitem |
4 | push_config 80_fluxbox_autostart |
5 | |
6 | help_fluxbox_menuitem() |
7 | { |
8 | local serial="${CLASS_ARGV[0]}" |
9 | control_client "${serial}" help fluxbox.menuitem |
10 | } |
11 | |
12 | set_fluxbox_menuitem() |
13 | { |
14 | local serial="${CLASS_ARGV[0]}" |
15 | local action="${CLASS_ARGV[1]}" |
16 | local name="${CLASS_ARGV[2]}" |
17 | local exec="${CLASS_ARGV[3]}" |
18 | local workdir="${CLASS_ARGV[4]}" |
19 | local icon="${CLASS_ARGV[5]}" |
20 | local id |
21 | local enabled |
22 | |
23 | case "${action}" in |
24 | add) enabled=1 ;; |
25 | del) enabled=0 ;; |
26 | *) |
27 | eecho "Unknown action '${action}'" |
28 | return 1 |
29 | ;; |
30 | esac |
31 | |
32 | if [[ -z ${name} ]] |
33 | then |
34 | eecho "No name given" |
35 | return 1 |
36 | fi |
37 | |
38 | id=$(mysqldo "select id from cfg_fluxbox_menuitem where serial='${serial}' and name='${name}';") |
39 | if [[ -n ${id} ]] |
40 | then |
41 | mysqldo "update cfg_fluxbox_menuitem set name='${name}', exec='${exec}', workdir='${workdir}', icon='${icon}', enabled='${enabled}' where id=${id};" |
42 | else |
43 | mysqldo "insert into cfg_fluxbox_menuitem(serial,name,exec,workdir,icon,enabled) values('${serial}','${name}','${exec}','${workdir}','${icon}','${enabled}');" |
44 | fi |
45 | } |
46 | |
47 | control_fluxbox_menuitem() |
48 | { |
49 | local serial="${CLASS_ARGV[0]}" |
50 | push_config_80_fluxbox_menuitem "${serial}" |
51 | } |
52 | |
53 | push_config_80_fluxbox_menuitem() |
54 | { |
55 | local serial="$1" |
56 | local values |
57 | local id |
58 | |
59 | values=$(mysqldo "select id from cfg_fluxbox_menuitem where serial='${serial}';") |
60 | for id in ${values} |
61 | do |
62 | evaluate_table_xml cfg_fluxbox_menuitem "where serial='${serial}'" |
63 | if [[ -z ${cfg_fluxbox_menuitem_name} ]] |
64 | then |
65 | eecho "Name must not be empty id->'${id}'" |
66 | continue |
67 | fi |
68 | if [[ -z ${cfg_fluxbox_menuitem_enabled} ]] |
69 | then |
70 | eecho "Enabled must not be empty id->'${id}'" |
71 | continue |
72 | fi |
73 | if [[ ${cfg_fluxbox_menuitem_enabled} = 1 ]] |
74 | then |
75 | control_client "${serial}" set fluxbox.menuitem add "${cfg_fluxbox_menuitem_name}" "${cfg_fluxbox_menuitem_exec}" "${cfg_fluxbox_menuitem_workdir}" "${cfg_fluxbox_menuitem_icon}" |
76 | elif [[ ${cfg_fluxbox_menuitem_enabled} = 0 ]] |
77 | then |
78 | control_client "${serial}" set fluxbox.menuitem del "${cfg_fluxbox_menuitem_name}" |
79 | # remove from database too |
80 | mysqldo "delete from cfg_fluxbox_menuitem where id='${id}';" |
81 | else |
82 | eecho "unknown enabled value id->'${id}', cfg_fluxbox_menuitem_enabled -> '${cfg_fluxbox_menuitem_enabled}'" |
83 | return 1 |
84 | fi |
85 | done |
86 | } |
87 | |
88 | help_fluxbox_autostart() |
89 | { |
90 | local serial="${CLASS_ARGV[0]}" |
91 | control_client "${serial}" help fluxbox.autostart |
92 | } |
93 | |
94 | set_fluxbox_autostart() |
95 | { |
96 | local serial="${CLASS_ARGV[0]}" |
97 | local action="${CLASS_ARGV[1]}" |
98 | local name="${CLASS_ARGV[2]}" |
99 | local exec="${CLASS_ARGV[3]}" |
100 | local id |
101 | local enabled |
102 | |
103 | case "${action}" in |
104 | add) enabled=1 ;; |
105 | del) enabled=0 ;; |
106 | *) |
107 | eecho "Unknown action '${action}'" |
108 | return 1 |
109 | ;; |
110 | esac |
111 | |
112 | if [[ -z ${name} ]] |
113 | then |
114 | eecho "No name given" |
115 | return 1 |
116 | fi |
117 | |
118 | id=$(mysqldo "select id from cfg_autostart where serial='${serial}' and name='${name}';") |
119 | if [[ -n ${id} ]] |
120 | then |
121 | mysqldo "update cfg_autostart set name='${name}', exec='${exec}', enabled='${enabled}' where id=${id};" |
122 | else |
123 | mysqldo "insert into cfg_autostart(serial,name,exec,enabled) values('${serial}','${name}','${exec}','${enabled}');" |
124 | fi |
125 | } |
126 | |
127 | control_fluxbox_autostart() |
128 | { |
129 | local serial="${CLASS_ARGV[0]}" |
130 | push_config_80_fluxbox_autostart "${serial}" |
131 | } |
132 | |
133 | push_config_80_fluxbox_autostart() |
134 | { |
135 | local serial="$1" |
136 | local values |
137 | local id |
138 | |
139 | values=$(mysqldo "select id from cfg_autostart where serial='${serial}';") |
140 | for id in ${values} |
141 | do |
142 | evaluate_table_xml cfg_autostart "where serial='${serial}'" |
143 | if [[ -z ${cfg_autostart_name} ]] |
144 | then |
145 | eecho "Name must not be empty id->'${id}'" |
146 | continue |
147 | fi |
148 | if [[ -z ${cfg_autostart_enabled} ]] |
149 | then |
150 | eecho "Enabled must not be empty id->'${id}'" |
151 | continue |
152 | fi |
153 | if [[ ${cfg_autostart_enabled} = 1 ]] |
154 | then |
155 | control_client "${serial}" set fluxbox.autostart add "${cfg_autostart_name}" "${cfg_autostart_exec}" |
156 | elif [[ ${cfg_autostart_enabled} = 0 ]] |
157 | then |
158 | control_client "${serial}" set fluxbox.autostart del "${cfg_autostart_name}" |
159 | # remove from database too |
160 | mysqldo "delete from cfg_autostart where id='${id}';" |
161 | else |
162 | eecho "unknown enabled value id->'${id}', cfg_autostart_enabled -> '${cfg_autostart_enabled}'" |
163 | return 1 |
164 | fi |
165 | done |
166 | } |
167 | |
168 | help_fluxbox_theme() |
169 | { |
170 | local serial="${CLASS_ARGV[0]}" |
171 | control_client "${serial}" help fluxbox.menuitem |
172 | } |
173 | |
174 | set_fluxbox_theme() |
175 | { |
176 | local serial="${CLASS_ARGV[0]}" |
177 | local theme="${CLASS_ARGV[1]}" |
178 | |
179 | import_resource cfg_fluxbox_theme "${serial}" theme "${theme}" |
180 | } |
181 | |
182 | control_fluxbox_theme() |
183 | { |
184 | local serial="${CLASS_ARGV[0]}" |
185 | push_config_fluxbox_theme "${serial}" |
186 | } |
187 | |
188 | push_config_80_fluxbox_theme() |
189 | { |
190 | local serial="$1" |
191 | local value |
192 | |
193 | value=$(mysqldo "select theme from cfg_fluxbox.menuitem where serial='${serial}'") |
194 | if [[ -z ${value} ]] || [[ ${value} = NULL ]] |
195 | then |
196 | decho "No theme retrieved" |
197 | else |
198 | control_client "${serial}" set fluxbox.theme "${value}" |
199 | fi |
200 | } |