Contents of /mcore-src/trunk/mcore-tools/src/modules/fluxbox/fluxbox.control.class.in
Parent Directory | Revision Log
Revision 2623 -
(show annotations)
(download)
Fri Sep 25 13:06:52 2015 UTC (8 years, 7 months ago) by niro
File size: 4973 byte(s)
Fri Sep 25 13:06:52 2015 UTC (8 years, 7 months ago) by niro
File size: 4973 byte(s)
-added autostart mechanics
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 comment="${CLASS_ARGV[4]}" |
101 | local id |
102 | local enabled |
103 | |
104 | case "${action}" in |
105 | add) enabled=1 ;; |
106 | del) enabled=0 ;; |
107 | *) |
108 | eecho "Unknown action '${action}'" |
109 | return 1 |
110 | ;; |
111 | esac |
112 | |
113 | if [[ -z ${name} ]] |
114 | then |
115 | eecho "No name given" |
116 | return 1 |
117 | fi |
118 | |
119 | id=$(mysqldo "select id from cfg_autostart where serial='${serial}' and name='${name}';") |
120 | if [[ -n ${id} ]] |
121 | then |
122 | mysqldo "update cfg_autostart set name='${name}', exec='${exec}', comment='${comment}', enabled='${enabled}' where id=${id};" |
123 | else |
124 | mysqldo "insert into cfg_autostart(serial,name,exec,comment,enabled) values('${serial}','${name}','${exec}','${comment}','${enabled}');" |
125 | fi |
126 | } |
127 | |
128 | control_fluxbox_autostart() |
129 | { |
130 | local serial="${CLASS_ARGV[0]}" |
131 | push_config_80_fluxbox_autostart "${serial}" |
132 | } |
133 | |
134 | push_config_80_fluxbox_autostart() |
135 | { |
136 | local serial="$1" |
137 | local values |
138 | local id |
139 | |
140 | values=$(mysqldo "select id from cfg_autostart where serial='${serial}';") |
141 | for id in ${values} |
142 | do |
143 | evaluate_table_xml cfg_autostart "where serial='${serial}'" |
144 | if [[ -z ${cfg_autostart_name} ]] |
145 | then |
146 | eecho "Name must not be empty id->'${id}'" |
147 | continue |
148 | fi |
149 | if [[ -z ${cfg_autostart_enabled} ]] |
150 | then |
151 | eecho "Enabled must not be empty id->'${id}'" |
152 | continue |
153 | fi |
154 | if [[ ${cfg_autostart_enabled} = 1 ]] |
155 | then |
156 | control_client "${serial}" set fluxbox.autostart add "${cfg_autostart_name}" "${cfg_autostart_exec}" "${cfg_autostart_comment}" |
157 | elif [[ ${cfg_autostart_enabled} = 0 ]] |
158 | then |
159 | control_client "${serial}" set fluxbox.autostart del "${cfg_autostart_name}" |
160 | # remove from database too |
161 | mysqldo "delete from cfg_autostart where id='${id}';" |
162 | else |
163 | eecho "unknown enabled value id->'${id}', cfg_autostart_enabled -> '${cfg_autostart_enabled}'" |
164 | return 1 |
165 | fi |
166 | done |
167 | } |
168 | |
169 | help_fluxbox_theme() |
170 | { |
171 | local serial="${CLASS_ARGV[0]}" |
172 | control_client "${serial}" help fluxbox.menuitem |
173 | } |
174 | |
175 | set_fluxbox_theme() |
176 | { |
177 | local serial="${CLASS_ARGV[0]}" |
178 | local theme="${CLASS_ARGV[1]}" |
179 | |
180 | import_resource cfg_fluxbox_theme "${serial}" theme "${theme}" |
181 | } |
182 | |
183 | control_fluxbox_theme() |
184 | { |
185 | local serial="${CLASS_ARGV[0]}" |
186 | push_config_fluxbox_theme "${serial}" |
187 | } |
188 | |
189 | push_config_fluxbox_theme() |
190 | { |
191 | local serial="$1" |
192 | local value |
193 | |
194 | value=$(mysqldo "select theme from cfg_fluxbox.menuitem where serial='${serial}'") |
195 | if [[ -z ${value} ]] || [[ ${value} = NULL ]] |
196 | then |
197 | decho "No theme retrieved" |
198 | else |
199 | control_client "${serial}" set fluxbox.theme "${value}" |
200 | fi |
201 | } |