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 2532 by niro, Wed Sep 16 07:51:43 2015 UTC revision 2883 by niro, Fri Aug 14 11:37:49 2020 UTC
# Line 1  Line 1 
1  # $Id$  # $Id$
2    
3    push_firstboot 80_fluxbox_menuitem
4    
5    push_config 80_fluxbox_menuitem
6    push_config 80_fluxbox_autostart
7    
8  help_fluxbox_menuitem()  help_fluxbox_menuitem()
9  {  {
10   local serial="${CLASS_ARGV[0]}"   local serial="${CLASS_ARGV[0]}"
# Line 14  set_fluxbox_menuitem() Line 19  set_fluxbox_menuitem()
19   local exec="${CLASS_ARGV[3]}"   local exec="${CLASS_ARGV[3]}"
20   local workdir="${CLASS_ARGV[4]}"   local workdir="${CLASS_ARGV[4]}"
21   local icon="${CLASS_ARGV[5]}"   local icon="${CLASS_ARGV[5]}"
22     local id
23     local enabled
24    
25   case "${action}" in   case "${action}" in
26   add) import_resource cfg_fluxbox_menuitem "${serial}" name "${name}" exec "${exec}" workdir "${workdir}" icon "${icon}" ;;   add) enabled=1 ;;
27   del)   del) enabled=0 ;;
28   if [[ -n ${name} ]]   *)
29   then   eecho "Unknown action '${action}'"
30   mysqldo "delete from cfg_fluxbox_menuitem where serial='${serial}' and name='${name}';"   return 1
  else  
  mysqldo "delete from cfg_fluxbox_menuitem where serial='${serial}';"  
  fi  
31   ;;   ;;
32   esac   esac
33    
34     if [[ -z ${name} ]]
35     then
36     eecho "No name given"
37     return 1
38     fi
39    
40     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  }  }
48    
49  control_fluxbox_menuitem()  control_fluxbox_menuitem()
50  {  {
51   local serial="${CLASS_ARGV[0]}"   local serial="${CLASS_ARGV[0]}"
52     push_config_80_fluxbox_menuitem "${serial}"
53    }
54    
55    push_config_80_fluxbox_menuitem()
56    {
57     local serial="$1"
58   local values   local values
59   local id   local id
60    
61   values=$(mysqldo "select id from cfg_fluxbox_menuitem where serial='${serial}';")   values=$(mysqldo "select id from cfg_fluxbox_menuitem where serial='${serial}';")
62   for id in ${values}   for id in ${values}
63   do   do
64   evaluate_table_xml cfg_fluxbox_menuitem "where serial='${serial}'"   evaluate_table_xml cfg_fluxbox_menuitem "where id='${id}'"
65   if [[ -z ${cfg_fluxbox_menuitem_name} ]]   if [[ -z ${cfg_fluxbox_menuitem_name} ]]
66   then   then
67   eecho "Name must not be empty id->'${id}'"   eecho "Name must not be empty id->'${id}'"
68   continue   continue
69   fi   fi
70   if [[ -z ${cfg_fluxbox_menuitem_exec} ]]   if [[ -z ${cfg_fluxbox_menuitem_enabled} ]]
71   then   then
72   eecho "Exec must not be empty id->'${id}'"   eecho "Enabled must not be empty id->'${id}'"
73   continue   continue
74   fi   fi
75   control fluxbox.menitem "${serial}" "${cfg_fluxbox_menuitem_name}" "${cfg_fluxbox_menuitem_exec}" "${cfg_fluxbox_menuitem_workdir}" "${cfg_fluxbox_menuitem_icon}"   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     then
80     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     fi
87     done
88    }
89    
90    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     id=$(mysqldo "select id from cfg_fluxbox_autostart where serial='${serial}' and name='${name}';")
121     if [[ -n ${id} ]]
122     then
123     mysqldo "update cfg_fluxbox_autostart set name='${name}', exec='${exec}', enabled='${enabled}' where id=${id};"
124     else
125     mysqldo "insert into cfg_fluxbox_autostart(serial,name,exec,enabled) values('${serial}','${name}','${exec}','${enabled}');"
126     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     values=$(mysqldo "select id from cfg_fluxbox_autostart where serial='${serial}';")
142     for id in ${values}
143     do
144     evaluate_table_xml cfg_fluxbox_autostart "where id='${id}'"
145     if [[ -z ${cfg_fluxbox_autostart_name} ]]
146     then
147     eecho "Name must not be empty id->'${id}'"
148     continue
149     fi
150     if [[ -z ${cfg_fluxbox_autostart_enabled} ]]
151     then
152     eecho "Enabled must not be empty id->'${id}'"
153     continue
154     fi
155     if [[ ${cfg_fluxbox_autostart_enabled} = 1 ]]
156     then
157     control_client "${serial}" set fluxbox.autostart add "\"${cfg_fluxbox_autostart_name}\"" "\"${cfg_fluxbox_autostart_exec}\""
158     elif [[ ${cfg_fluxbox_autostart_enabled} = 0 ]]
159     then
160     control_client "${serial}" set fluxbox.autostart del "\"${cfg_fluxbox_autostart_name}\""
161     # remove from database too
162     mysqldo "delete from cfg_fluxbox_autostart where id='${id}';"
163     else
164     eecho "unknown enabled value id->'${id}', cfg_fluxbox_autostart_enabled -> '${cfg_fluxbox_autostart_enabled}'"
165     return 1
166     fi
167   done   done
168  }  }
169    
# Line 69  set_fluxbox_theme() Line 184  set_fluxbox_theme()
184  control_fluxbox_theme()  control_fluxbox_theme()
185  {  {
186   local serial="${CLASS_ARGV[0]}"   local serial="${CLASS_ARGV[0]}"
187     push_config_fluxbox_theme "${serial}"
188    }
189    
190    push_config_80_fluxbox_theme()
191    {
192     local serial="$1"
193   local value   local value
194    
195   value=$(mysqldo "select theme from cfg_fluxbox.menuitem where serial='${serial}'")   value=$(mysqldo "select theme from cfg_fluxbox.theme where serial='${serial}'")
196   if [[ -z ${value} ]] || [[ ${value} = NULL ]]   if [[ -z ${value} ]] || [[ ${value} = NULL ]]
197   then   then
198   decho "No theme retrieved"   decho "No theme retrieved"
199   else   else
200   control_client "${serial}" set fluxbox.theme "${value}"   control_client "${serial}" set fluxbox.theme "\"${value}\""
201     fi
202    }
203    
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   fi
215  }  }

Legend:
Removed from v.2532  
changed lines
  Added in v.2883