summaryrefslogtreecommitdiff
path: root/script/uactivity/activity/-20-switch_tv
blob: c9bbf57145c9e2a9279834ede156bb761042bef7 (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
31
32
33
34
35
36
37
38
#!/bin/sh

switch_tv(){
  if [ "${1}" = "on" ]; then
    # yaUSBir sometimes ignore the first command, send an existing dummy ir code
    irsend -d /var/run/lirc/ya_usbir SEND_ONCE TV_DUMMY dummy
    sleep 0.5
    irsend -d /var/run/lirc/ya_usbir SEND_ONCE TV_REMOTE on
  else
    # yaUSBir sometimes ignore the first command, send an existing dummy ir code
    irsend -d /var/run/lirc/ya_usbir SEND_ONCE TV_DUMMY dummy
    sleep 0.5
    irsend -d /var/run/lirc/ya_usbir SEND_ONCE TV_REMOTE off
  fi
}



case "${1}" in
  startup)
    true
  ;;
  started)
    [ "${2}" = "true" ] && switch_tv on
  ;;
  shutdown)
    switch_tv off
  ;;
  running)
    if [ "${2}" = "true" ]; then
      switch_tv on
    else
      switch_tv off
    fi
  ;;
esac

exit 0