Magellan Linux

Annotation of /mcore-src/trunk/mcore-tools/src/modules/fluxbox/fluxbox.control.class.in

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2873 - (hide annotations) (download)
Fri Aug 14 08:43:19 2020 UTC (3 years, 8 months ago) by niro
File size: 5318 byte(s)
-fixed broken table evaluation
1 niro 2532 # $Id$
2    
3 niro 2762 push_firstboot 80_fluxbox_menuitem
4    
5 niro 2576 push_config 80_fluxbox_menuitem
6 niro 2623 push_config 80_fluxbox_autostart
7 niro 2564
8 niro 2532 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 niro 2535 local id
23 niro 2545 local enabled
24 niro 2532
25     case "${action}" in
26 niro 2545 add) enabled=1 ;;
27     del) enabled=0 ;;
28     *)
29     eecho "Unknown action '${action}'"
30     return 1
31 niro 2536 ;;
32 niro 2532 esac
33 niro 2545
34 niro 2567 if [[ -z ${name} ]]
35     then
36     eecho "No name given"
37     return 1
38     fi
39    
40 niro 2545 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 niro 2532 }
48    
49     control_fluxbox_menuitem()
50     {
51     local serial="${CLASS_ARGV[0]}"
52 niro 2576 push_config_80_fluxbox_menuitem "${serial}"
53 niro 2564 }
54    
55 niro 2576 push_config_80_fluxbox_menuitem()
56 niro 2564 {
57     local serial="$1"
58 niro 2532 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 niro 2873 evaluate_table_xml cfg_fluxbox_menuitem "where id='${id}'"
65 niro 2532 if [[ -z ${cfg_fluxbox_menuitem_name} ]]
66     then
67     eecho "Name must not be empty id->'${id}'"
68     continue
69     fi
70 niro 2545 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 niro 2547 then
80 niro 2545 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 niro 2546 fi
87 niro 2532 done
88     }
89    
90 niro 2623 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 niro 2769 id=$(mysqldo "select id from cfg_fluxbox_autostart where serial='${serial}' and name='${name}';")
121 niro 2623 if [[ -n ${id} ]]
122     then
123 niro 2769 mysqldo "update cfg_fluxbox_autostart set name='${name}', exec='${exec}', enabled='${enabled}' where id=${id};"
124 niro 2623 else
125 niro 2769 mysqldo "insert into cfg_fluxbox_autostart(serial,name,exec,enabled) values('${serial}','${name}','${exec}','${enabled}');"
126 niro 2623 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 niro 2769 values=$(mysqldo "select id from cfg_fluxbox_autostart where serial='${serial}';")
142 niro 2623 for id in ${values}
143     do
144 niro 2873 evaluate_table_xml cfg_fluxbox_autostart "where id='${id}'"
145 niro 2769 if [[ -z ${cfg_fluxbox_autostart_name} ]]
146 niro 2623 then
147     eecho "Name must not be empty id->'${id}'"
148     continue
149     fi
150 niro 2769 if [[ -z ${cfg_fluxbox_autostart_enabled} ]]
151 niro 2623 then
152     eecho "Enabled must not be empty id->'${id}'"
153     continue
154     fi
155 niro 2769 if [[ ${cfg_fluxbox_autostart_enabled} = 1 ]]
156 niro 2623 then
157 niro 2769 control_client "${serial}" set fluxbox.autostart add "${cfg_fluxbox_autostart_name}" "${cfg_fluxbox_autostart_exec}"
158     elif [[ ${cfg_fluxbox_autostart_enabled} = 0 ]]
159 niro 2623 then
160 niro 2769 control_client "${serial}" set fluxbox.autostart del "${cfg_fluxbox_autostart_name}"
161 niro 2623 # remove from database too
162 niro 2769 mysqldo "delete from cfg_fluxbox_autostart where id='${id}';"
163 niro 2623 else
164 niro 2769 eecho "unknown enabled value id->'${id}', cfg_fluxbox_autostart_enabled -> '${cfg_fluxbox_autostart_enabled}'"
165 niro 2623 return 1
166     fi
167     done
168     }
169    
170 niro 2532 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 niro 2564 push_config_fluxbox_theme "${serial}"
188     }
189    
190 niro 2760 push_config_80_fluxbox_theme()
191 niro 2564 {
192     local serial="$1"
193 niro 2532 local value
194    
195 niro 2770 value=$(mysqldo "select theme from cfg_fluxbox.theme where serial='${serial}'")
196 niro 2532 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 niro 2762
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     }