Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 234005 | Differences between
and this patch

Collapse All | Expand All

(-)ivman-old/AUTHORS (+2 lines)
Lines 1-3 Link Here
1
Written by Ikke - http://www.eikke.com
1
Written by Ikke - http://www.eikke.com
2
2
3
Code inspired by Gnome Volume Manager by RML and others
3
Code inspired by Gnome Volume Manager by RML and others
4
5
Condition detail matching added by Michał Górny, http://mgorny.jogger.pl/
(-)ivman-old/IvmConfigConditions.xml.5 (-3 / +7 lines)
Lines 40-46 file is: Link Here
40
.br
40
.br
41
      <ivm:Condition name="conditionname1" exec="command1" />
41
      <ivm:Condition name="conditionname1" exec="command1" />
42
.br
42
.br
43
      <ivm:Condition name="conditionname1" exec="command1" />
43
      <ivm:Condition name="conditionname2" value="conditionvalue2" exec="command2" />
44
.br
44
.br
45
   </ivm:Match>
45
   </ivm:Match>
46
46
Lines 51-58 file is: Link Here
51
51
52
Each time a condition is emitted by a device, this file will be parsed.  If the
52
Each time a condition is emitted by a device, this file will be parsed.  If the
53
Match rule matches the device on which the condition came from, and the Condition
53
Match rule matches the device on which the condition came from, and the Condition
54
rule matches the name of the condition which occurred, then the command specified in
54
rule matches the name (and value, if specified) of the condition which occurred,
55
the 'exec' option will be executed.
55
then the command specified in the 'exec' option will be executed.
56
56
57
A Match element can have any of the following names:
57
A Match element can have any of the following names:
58
.RS 5
58
.RS 5
Lines 77-82 Condition names usually take the form of Link Here
77
button is pressed on your machine.  See the HAL specification for a full list of
77
button is pressed on your machine.  See the HAL specification for a full list of
78
possible conditions.
78
possible conditions.
79
79
80
Some conditions may also have a value, which supplies some additional info
81
about event occured. For example, keyboard-emitted 'ButtonPressed' may have
82
values like 'sleep', 'power' and 'wake-up'.
83
80
The
84
The
81
.B exec
85
.B exec
82
attributes of Condition tags support substitution of HAL device properties. 
86
attributes of Condition tags support substitution of HAL device properties. 
(-)ivman-old/README (+1 lines)
Lines 8-13 Who wrote it? Link Here
8
-------------
8
-------------
9
Ivman was written by Ikke <eikke at users dot sourceforge dot org>, based on gnome-volume-manager, by Robert M. Love and others.
9
Ivman was written by Ikke <eikke at users dot sourceforge dot org>, based on gnome-volume-manager, by Robert M. Love and others.
10
10
11
Conditional detail matching added by Michał Górny.
11
12
12
Where can I find the latest information?
13
Where can I find the latest information?
13
----------------------------------------
14
----------------------------------------
(-)ivman-old/src/hal_interface.c (-1 / +4 lines)
Lines 231-236 hal_device_condition(LibHalContext * ctx Link Here
231
                     __attribute__ ((__unused__)))
231
                     __attribute__ ((__unused__)))
232
#endif
232
#endif
233
{
233
{
234
#ifdef HAL_0_4
235
    const char *condition_detail = NULL;
236
#endif
234
    // VolumeUnmountForced occurs when USB disk is yanked or similar
237
    // VolumeUnmountForced occurs when USB disk is yanked or similar
235
    // We have to ensure that device is removed from hash table
238
    // We have to ensure that device is removed from hash table
236
    if (!strcmp(condition_name, "VolumeUnmountForced"))
239
    if (!strcmp(condition_name, "VolumeUnmountForced"))
Lines 245-251 hal_device_condition(LibHalContext * ctx Link Here
245
248
246
    char *file = ivm_get_config_file("IvmConfigConditions.xml");
249
    char *file = ivm_get_config_file("IvmConfigConditions.xml");
247
    IvmConfigConditions *cfg =
250
    IvmConfigConditions *cfg =
248
        parseIvmConfigConditions(file, udi, condition_name);
251
        parseIvmConfigConditions(file, udi, condition_name, condition_detail);
249
    free(file);
252
    free(file);
250
253
251
    if (!cfg)
254
    if (!cfg)
(-)ivman-old/src/IvmConfig/IvmConfigConditions.c (-2 / +5 lines)
Lines 29-35 Link Here
29
IvmConfigConditions *parseIvmConfigConditions(char const *const path,
29
IvmConfigConditions *parseIvmConfigConditions(char const *const path,
30
                                              char const *udi,
30
                                              char const *udi,
31
                                              char const *const
31
                                              char const *const
32
                                              conditionName)
32
                                              conditionName,
33
					      char const *const
34
					      conditionValue)
33
{
35
{
34
    gboolean mountable = ivm_device_is_mountable(udi);
36
    gboolean mountable = ivm_device_is_mountable(udi);
35
37
Lines 142-147 nextMatch: Link Here
142
        else if (!xmlStrcmp(cur->name, (const xmlChar *) "Condition"))
144
        else if (!xmlStrcmp(cur->name, (const xmlChar *) "Condition"))
143
        {
145
        {
144
            xmlChar *name = xmlGetProp(cur, "name");
146
            xmlChar *name = xmlGetProp(cur, "name");
147
	    xmlChar *value = xmlGetProp(cur, "value");
145
148
146
            xmlChar *exec = xmlGetProp(cur, "exec");
149
            xmlChar *exec = xmlGetProp(cur, "exec");
147
150
Lines 151-157 nextMatch: Link Here
151
                goto nextCondition;
154
                goto nextCondition;
152
            }
155
            }
153
            
156
            
154
            if (!xmlStrcmp(name, (xmlChar *) conditionName))
157
            if (!xmlStrcmp(name, (xmlChar *) conditionName) && (!value || (conditionValue && !xmlStrcmp(value, (xmlChar *) conditionValue))))
155
            {
158
            {
156
                num_exec++;
159
                num_exec++;
157
                ret->exec = realloc(ret->exec,
160
                ret->exec = realloc(ret->exec,
(-)ivman-old/src/IvmConfig/IvmConfigConditions.h (-1 / +2 lines)
Lines 25-30 typedef struct IvmConfigConditions Link Here
25
    char **exec;
25
    char **exec;
26
} IvmConfigConditions;
26
} IvmConfigConditions;
27
27
28
IvmConfigConditions * parseIvmConfigConditions(char const * const path, char const * udi, char const * const conditionName);
28
IvmConfigConditions * parseIvmConfigConditions(char const * const path, char const * udi,
29
		char const * const conditionName, char const * const conditionValue);
29
30
30
#endif
31
#endif
(-)ivman-old/src/IvmConfig/IvmConfigConditions.xml (-2 / +11 lines)
Lines 5-11 Link Here
5
5
6
         <ivm:Match name="matchname" value="matchvalue">
6
         <ivm:Match name="matchname" value="matchvalue">
7
             <ivm:Condition name="conditionname1" exec="command1" />
7
             <ivm:Condition name="conditionname1" exec="command1" />
8
             <ivm:Condition name="conditionname2" exec="command2" />
8
             <ivm:Condition name="conditionname2" value="value2" exec="command2" />
9
         </ivm:Match>
9
         </ivm:Match>
10
10
11
         What does this actually mean?  Well, when a device emits a condition,
11
         What does this actually mean?  Well, when a device emits a condition,
Lines 13-18 Link Here
13
         matches the name of the condition, then 'command1' will be
13
         matches the name of the condition, then 'command1' will be
14
         executed.
14
         executed.
15
15
16
         If 'value' is set the condition detail will also have to match.
17
16
         Matches can be nested.  See the examples.
18
         Matches can be nested.  See the examples.
17
19
18
         If a condition matches multiple times, all matching commands will be
20
         If a condition matches multiple times, all matching commands will be
Lines 36-46 Link Here
36
38
37
    <!-- Shut down when power button is pressed.  This and the rest of the ACPI
39
    <!-- Shut down when power button is pressed.  This and the rest of the ACPI
38
         stuff needs HAL 0.5 or better to work.  Also, /sbin/shutdown needs to be
40
         stuff needs HAL 0.5 or better to work.  Also, /sbin/shutdown needs to be
39
	 in /etc/sudoers for whatever user Ivman runs as. -->
41
         in /etc/sudoers for whatever user Ivman runs as. -->
40
    <!--
42
    <!--
41
    <ivm:Match name="hal.info.udi" value="/org/freedesktop/Hal/devices/acpi_PWRF">
43
    <ivm:Match name="hal.info.udi" value="/org/freedesktop/Hal/devices/acpi_PWRF">
42
        <ivm:Condition name="ButtonPressed" exec="/usr/bin/sudo /sbin/shutdown" />
44
        <ivm:Condition name="ButtonPressed" exec="/usr/bin/sudo /sbin/shutdown" />
43
    </ivm:Match>
45
    </ivm:Match>
44
    -->
46
    -->
45
47
48
    <!-- Shut down on both frontpanel 'power' button and 'power' key on keyboard,
49
         and hibernate on 'sleep' key. -->
50
    <!--
51
    <ivm:Condition name="ButtonPressed" value="power" exec="/usr/bin/sudo /sbin/shutdown -h now"/>
52
    <ivm:Condition name="ButtonPressed" value="sleep" exec="/usr/bin/sudo /usr/sbin/hibernate"/>
53
    -->
54
46
</ivm:ConditionsConfig>
55
</ivm:ConditionsConfig>

Return to bug 234005