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