Magellan Linux

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2564 - (show annotations) (download)
Thu Sep 17 09:40:02 2015 UTC (8 years, 7 months ago) by niro
File size: 2845 byte(s)
-push_config support
1 # $Id$
2
3 push_config fluxbox_menuitem
4
5 help_fluxbox_menuitem()
6 {
7 local serial="${CLASS_ARGV[0]}"
8 control_client "${serial}" help fluxbox.menuitem
9 }
10
11 set_fluxbox_menuitem()
12 {
13 local serial="${CLASS_ARGV[0]}"
14 local action="${CLASS_ARGV[1]}"
15 local name="${CLASS_ARGV[2]}"
16 local exec="${CLASS_ARGV[3]}"
17 local workdir="${CLASS_ARGV[4]}"
18 local icon="${CLASS_ARGV[5]}"
19 local id
20 local enabled
21
22 case "${action}" in
23 add) enabled=1 ;;
24 del) enabled=0 ;;
25 *)
26 eecho "Unknown action '${action}'"
27 return 1
28 ;;
29 esac
30
31 id=$(mysqldo "select id from cfg_fluxbox_menuitem where serial='${serial}' and name='${name}';")
32 if [[ -n ${id} ]]
33 then
34 mysqldo "update cfg_fluxbox_menuitem set name='${name}', exec='${exec}', workdir='${workdir}', icon='${icon}', enabled='${enabled}' where id=${id};"
35 else
36 mysqldo "insert into cfg_fluxbox_menuitem(serial,name,exec,workdir,icon,enabled) values('${serial}','${name}','${exec}','${workdir}','${icon}','${enabled}');"
37 fi
38 }
39
40 control_fluxbox_menuitem()
41 {
42 local serial="${CLASS_ARGV[0]}"
43 push_config_fluxbox_menuitem "${serial}"
44 }
45
46 push_config_fluxbox_menuitem()
47 {
48 local serial="$1"
49 local values
50 local id
51
52 values=$(mysqldo "select id from cfg_fluxbox_menuitem where serial='${serial}';")
53 for id in ${values}
54 do
55 evaluate_table_xml cfg_fluxbox_menuitem "where serial='${serial}'"
56 if [[ -z ${cfg_fluxbox_menuitem_name} ]]
57 then
58 eecho "Name must not be empty id->'${id}'"
59 continue
60 fi
61 if [[ -z ${cfg_fluxbox_menuitem_enabled} ]]
62 then
63 eecho "Enabled must not be empty id->'${id}'"
64 continue
65 fi
66 if [[ ${cfg_fluxbox_menuitem_enabled} = 1 ]]
67 then
68 control_client "${serial}" set fluxbox.menuitem add "${cfg_fluxbox_menuitem_name}" "${cfg_fluxbox_menuitem_exec}" "${cfg_fluxbox_menuitem_workdir}" "${cfg_fluxbox_menuitem_icon}"
69 elif [[ ${cfg_fluxbox_menuitem_enabled} = 0 ]]
70 then
71 control_client "${serial}" set fluxbox.menuitem del "${cfg_fluxbox_menuitem_name}"
72 # remove from database too
73 mysqldo "delete from cfg_fluxbox_menuitem where id='${id}';"
74 else
75 eecho "unknown enabled value id->'${id}', cfg_fluxbox_menuitem_enabled -> '${cfg_fluxbox_menuitem_enabled}'"
76 return 1
77 fi
78 done
79 }
80
81 help_fluxbox_theme()
82 {
83 local serial="${CLASS_ARGV[0]}"
84 control_client "${serial}" help fluxbox.menuitem
85 }
86
87 set_fluxbox_theme()
88 {
89 local serial="${CLASS_ARGV[0]}"
90 local theme="${CLASS_ARGV[1]}"
91
92 import_resource cfg_fluxbox_theme "${serial}" theme "${theme}"
93 }
94
95 control_fluxbox_theme()
96 {
97 local serial="${CLASS_ARGV[0]}"
98 push_config_fluxbox_theme "${serial}"
99 }
100
101 push_config_fluxbox_theme()
102 {
103 local serial="$1"
104 local value
105
106 value=$(mysqldo "select theme from cfg_fluxbox.menuitem where serial='${serial}'")
107 if [[ -z ${value} ]] || [[ ${value} = NULL ]]
108 then
109 decho "No theme retrieved"
110 else
111 control_client "${serial}" set fluxbox.theme "${value}"
112 fi
113 }