Contents of /mcore-src/trunk/mcore-tools/src/modules/fluxbox/fluxbox.control.class.in
Parent Directory | Revision Log
Revision 2545 -
(show annotations)
(download)
Wed Sep 16 10:54:19 2015 UTC (8 years, 7 months ago) by niro
File size: 2728 byte(s)
Wed Sep 16 10:54:19 2015 UTC (8 years, 7 months ago) by niro
File size: 2728 byte(s)
-reworked the whole logic
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_exec} ]] |
54 | then |
55 | eecho "Exec must not be empty id->'${id}'" |
56 | continue |
57 | fi |
58 | if [[ -z ${cfg_fluxbox_menuitem_enabled} ]] |
59 | then |
60 | eecho "Enabled must not be empty id->'${id}'" |
61 | continue |
62 | fi |
63 | if [[ ${cfg_fluxbox_menuitem_enabled} = 1 ]] |
64 | then |
65 | control_client "${serial}" set fluxbox.menuitem add "${cfg_fluxbox_menuitem_name}" "${cfg_fluxbox_menuitem_exec}" "${cfg_fluxbox_menuitem_workdir}" "${cfg_fluxbox_menuitem_icon}" |
66 | elif [[ ${cfg_fluxbox_menuitem_enabled} = 0 ]] |
67 | control_client "${serial}" set fluxbox.menuitem del "${cfg_fluxbox_menuitem_name}" |
68 | # remove from database too |
69 | mysqldo "delete from cfg_fluxbox_menuitem where id='${id}';" |
70 | else |
71 | eecho "unknown enabled value id->'${id}', cfg_fluxbox_menuitem_enabled -> '${cfg_fluxbox_menuitem_enabled}'" |
72 | return 1 |
73 | done |
74 | } |
75 | |
76 | help_fluxbox_theme() |
77 | { |
78 | local serial="${CLASS_ARGV[0]}" |
79 | control_client "${serial}" help fluxbox.menuitem |
80 | } |
81 | |
82 | set_fluxbox_theme() |
83 | { |
84 | local serial="${CLASS_ARGV[0]}" |
85 | local theme="${CLASS_ARGV[1]}" |
86 | |
87 | import_resource cfg_fluxbox_theme "${serial}" theme "${theme}" |
88 | } |
89 | |
90 | control_fluxbox_theme() |
91 | { |
92 | local serial="${CLASS_ARGV[0]}" |
93 | local value |
94 | |
95 | value=$(mysqldo "select theme from cfg_fluxbox.menuitem where serial='${serial}'") |
96 | if [[ -z ${value} ]] || [[ ${value} = NULL ]] |
97 | then |
98 | decho "No theme retrieved" |
99 | else |
100 | control_client "${serial}" set fluxbox.theme "${value}" |
101 | fi |
102 | } |