summaryrefslogtreecommitdiff
path: root/script/uactivity/key/#20-toggle_demo
blob: 3ec3cfbc0f1dfe20da50e8c7ecea120e0474a858 (plain)
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
#!/bin/sh

# do not use names starting with [0-9][0-9] for data files
FLAG="${4}/key/flag.$(basename ${0})"

case "${1}" in
  startup)
    # create flag directory (using cache directory)
    mkdir -p "${4}/key/"
    # delete flag (may leftover from previus vdr crash)
    # kepp the flag if toggle state should be keep over vdr sessions
    rm -f "${FLAG}"
  ;;
  running)
    # we are interested in Key "1"
    if [ "${2}" = "1" ]; then
      if [ -f "${FLAG}" ]; then
        # here we do our "off" action
        logger -t "uactivity [key/$(basename ${0})]" "$(basename ${0}) off"
        rm -f "${FLAG}"
      else
        # here we do our "on" action
        logger -t "uactivity [key/$(basename ${0})]" "$(basename ${0}) on"
        touch "${FLAG}"
      fi
    fi
  ;;
esac

exit 0