Magellan Linux

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

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 2539 by niro, Wed Sep 16 09:20:11 2015 UTC revision 2625 by niro, Fri Sep 25 13:31:20 2015 UTC
# Line 1  Line 1 
1  # $Id$  # $Id$
2    
3    push_config 80_fluxbox_menuitem
4    push_config 80_fluxbox_autostart
5    
6  help_fluxbox_menuitem()  help_fluxbox_menuitem()
7  {  {
8   local serial="${CLASS_ARGV[0]}"   local serial="${CLASS_ARGV[0]}"
# Line 15  set_fluxbox_menuitem() Line 18  set_fluxbox_menuitem()
18   local workdir="${CLASS_ARGV[4]}"   local workdir="${CLASS_ARGV[4]}"
19   local icon="${CLASS_ARGV[5]}"   local icon="${CLASS_ARGV[5]}"
20   local id   local id
21     local enabled
22    
23   case "${action}" in   case "${action}" in
24   add) id=$(mysqldo "select id from cfg_fluxbox_menuitem where serial='${serial}' and name='${name}';")   add) enabled=1 ;;
25   if [[ -n ${id} ]]   del) enabled=0 ;;
26   then   *)
27   mysqldo "update cfg_fluxbox_menuitem set name='${name}', exec='${exec}', workdir='${workdir}', icon='${icon}' where id=${id};"   eecho "Unknown action '${action}'"
28   else   return 1
  mysqldo "insert into cfg_fluxbox_menuitem(serial,name,exec,workdir,icon) values('${serial}','${name}','${exec}','${workdir}','${icon}');"  
  fi  
  ;;  
  del)  
  if [[ -n ${name} ]]  
  then  
  mysqldo "delete from cfg_fluxbox_menuitem where serial='${serial}' and name='${name}';"  
  else  
  mysqldo "delete from cfg_fluxbox_menuitem where serial='${serial}';"  
  fi  
29   ;;   ;;
30   esac   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()  control_fluxbox_menuitem()
48  {  {
49   local serial="${CLASS_ARGV[0]}"   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   local values
57   local id   local id
58    
# Line 51  control_fluxbox_menuitem() Line 65  control_fluxbox_menuitem()
65   eecho "Name must not be empty id->'${id}'"   eecho "Name must not be empty id->'${id}'"
66   continue   continue
67   fi   fi
68   if [[ -z ${cfg_fluxbox_menuitem_exec} ]]   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   then
150   eecho "Exec must not be empty id->'${id}'"   eecho "Enabled must not be empty id->'${id}'"
151   continue   continue
152   fi   fi
153   control_client "${serial}" fluxbox.menuitem add "${cfg_fluxbox_menuitem_name}" "${cfg_fluxbox_menuitem_exec}" "${cfg_fluxbox_menuitem_workdir}" "${cfg_fluxbox_menuitem_icon}"   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   done
166  }  }
167    
# Line 77  set_fluxbox_theme() Line 182  set_fluxbox_theme()
182  control_fluxbox_theme()  control_fluxbox_theme()
183  {  {
184   local serial="${CLASS_ARGV[0]}"   local serial="${CLASS_ARGV[0]}"
185     push_config_fluxbox_theme "${serial}"
186    }
187    
188    push_config_fluxbox_theme()
189    {
190     local serial="$1"
191   local value   local value
192    
193   value=$(mysqldo "select theme from cfg_fluxbox.menuitem where serial='${serial}'")   value=$(mysqldo "select theme from cfg_fluxbox.menuitem where serial='${serial}'")

Legend:
Removed from v.2539  
changed lines
  Added in v.2625