File: input-device-example.sh

package info (click to toggle)
cinnamon-settings-daemon 2.2.4.repack-7
  • links: PTS, VCS
  • area: main
  • in suites: jessie-kfreebsd
  • size: 14,864 kB
  • sloc: ansic: 46,046; makefile: 1,693; xml: 245; sh: 58; python: 21
file content (69 lines) | stat: -rw-r--r-- 1,548 bytes parent folder | download | duplicates (8)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#!/bin/sh
#
# This script is an example hotplug script for use with the various
# input devices plugins.
#
# The script is called with the arguments:
# -t [added|present|removed] <device name>
#       added ... device was just plugged in
#       present.. device was present at cinnamon-settings-daemon startup
#       removed.. device was just removed
# -i <device ID>
#       device ID being the XInput device ID
# <device name> The name of the device
#
# The script should return 0 if the device is to be
# ignored from future configuration.
#
# Set the script to be used with:
# gsettings set org.cinnamon.settings-daemon.peripherals.input-devices hotplug-command /path/to/script/input-devices.sh
#

args=`getopt "t:i:" $*`

set -- $args

while [ $# -gt 0 ]
do
    case $1 in
    -t)
        shift;
        type="$1"
        ;;
     -i)
        shift;
        id="$1"
        ;;
     --)
        shift;
        device="$@"
        break;
        ;;
    *)
        echo "Unknown option $1";
        exit 1
        ;;
    esac
    shift
done

retval=0

case $type in
        added)
                echo "Device '$device' (ID=$id) was added"
                ;;
        present)
                echo "Device '$device' (ID=$id) was already present at startup"
                ;;
        removed)
                echo "Device '$device' (ID=$id) was removed"
                ;;
        *)
                echo "Unknown operation"
                retval=1
                ;;
esac

# All further processing will be disabled if $retval == 0
exit $retval