Magellan Linux

Annotation of /mcore-src/trunk/mcore-tools/src/modules/idesk/idesk.control.class.in

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2546 - (hide annotations) (download)
Wed Sep 16 11:16:27 2015 UTC (8 years, 7 months ago) by niro
File size: 3972 byte(s)
-fixed missing fi
1 niro 2543 # $Id$
2    
3     # control_input_keymap $serial
4     control_input_keymap()
5     {
6     local serial="${CLASS_ARGV[0]}"
7     push_config_input_keymap "${serial}"
8     }
9    
10     push_config_input_keymap()
11     {
12     local serial="$1"
13     local value
14    
15     value=$(mysqldo "select keymap from cfg_input where serial='${serial}'")
16     control_client "${serial}" set input.keymap "${value}"
17     }
18    
19     help_idesk_icon()
20     {
21     local serial="${CLASS_ARGV[0]}"
22     control_client "${serial}" help idesk.icon
23    
24     mecho "get idesk.icon"
25     mecho " Shows all configured icons."
26     mecho
27     mecho "set idesk.icon [action] [name] [command] [icon] [filename] [x,y] [width,height] [default-icon]"
28     mecho " Adds or deletes an desktop icon."
29     mecho " [actions]:"
30     mecho " add - adds an icon"
31     mecho " del - deletes an icon"
32     mecho " if no [name] given, all desktop icons will be deleted"
33     mecho
34     mecho " name - Name of the icon"
35     mecho " command - command which will be run"
36     mecho " icon - icon pixmap [optional]"
37     mecho " filename - filename of the icon [optional]"
38     mecho " x,y - x,y position of the icon on the desktop [optional]"
39     mecho " width,height - width and height of the icon [optional]"
40     mecho " default-icon - default icon which will be selected if the icon pixmap was not found [optional]"
41     }
42    
43     set_idesk_icon()
44     {
45     local serial="${CLASS_ARGV[0]}"
46     local action="${CLASS_ARGV[1]}"
47     local name="${CLASS_ARGV[2]}"
48     local command="${CLASS_ARGV[3]}"
49     local icon="${CLASS_ARGV[4]}"
50     local filename="${CLASS_ARGV[5]}"
51     local xypos="${CLASS_ARGV[6]}"
52     local widthheight="${CLASS_ARGV[7]}"
53     local default_icon="${CLASS_ARGV[8]}"
54     local xpos
55     local ypos
56     local width
57     local height
58 niro 2544 local id
59     local enabled
60 niro 2543
61     [[ -z ${action} ]] && help_idesk_icon && return 1
62    
63     if [[ -n ${xypos} ]]
64     then
65     xpos="${xypos%,*}"
66     ypos="${xypos#*,}"
67     fi
68    
69     if [[ -n ${widthheight} ]]
70     then
71     width="${widthheight%,*}"
72     height="${widthheight#*,}"
73     fi
74    
75     case "${action}" in
76 niro 2544 add) enabled=1 ;;
77     del) enabled=0 ;;
78     *)
79     eecho "Unknown action '${action}'"
80     return 1
81 niro 2543 ;;
82     esac
83 niro 2544
84     id=$(mysqldo "select id from cfg_idesk_icon where serial='${serial}' and name='${name}';")
85     if [[ -n ${id} ]]
86     then
87     mysqldo "update cfg_idesk_icon set name='${name}', command='${command}', icon='${icon}', filename='${filename}', xpos='${xpos}', ypos='${ypos}', width='${width}', height='${height}', default_icon='${default_icon}', enabled='${enabled}' where id=${id};"
88     else
89     mysqldo "insert into cfg_idesk_icon(serial, name, command, icon, filename, xpos, ypos, width, height, default_icon, enabled)
90     values('${serial}', '${name}', '${command}', '${icon}', '${filename}', '${xpos}', '${ypos}', '${width}', '${height}', '${default_icon}', '${enabled}');"
91     fi
92 niro 2543 }
93    
94     control_idesk_icon()
95     {
96     local serial="${CLASS_ARGV[0]}"
97     local values
98     local id
99    
100     values=$(mysqldo "select id from cfg_idesk_icon where serial='${serial}';")
101     for id in ${values}
102     do
103     evaluate_table_xml cfg_idesk_icon "where serial='${serial}'"
104     if [[ -z ${cfg_idesk_icon_name} ]]
105     then
106     eecho "Name must not be empty id->'${id}'"
107     continue
108     fi
109     if [[ -z ${cfg_idesk_icon_command} ]]
110     then
111     eecho "Command must not be empty id->'${id}'"
112     continue
113     fi
114 niro 2544 if [[ -z ${cfg_idesk_icon_enabled} ]]
115     then
116     eecho "Enabled must not be empty id->'${id}'"
117     continue
118     fi
119     if [[ ${cfg_idesk_icon_enabled} = 1 ]]
120     then
121     control_client "${serial}" set idesk.icon add "${cfg_idesk_icon_name}" "${cfg_idesk_icon_command}" "${cfg_idesk_icon_icon}" "${cfg_idesk_icon_filename}" "${cfg_idesk_icon_xpos},${cfg_idesk_icon_ypos}" "${cfg_idesk_icon_width},${cfg_idesk_icon_height}" "${cfg_idesk_icon_default_icon}"
122     elif [[ ${cfg_idesk_icon_enabled} = 0 ]]
123     control_client "${serial}" set idesk.icon del "${cfg_idesk_icon_name}"
124     # remove from database too
125     mysqldo "delete from cfg_idesk_icon where id='${id}';"
126     else
127     eecho "unknown enabled value id->'${id}', cfg_idesk_icon_enabled -> '${cfg_idesk_icon_enabled}'"
128     return 1
129 niro 2546 fi
130 niro 2543 done
131     }