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