summarylogtreecommitdiffstats
path: root/displaylink-sleep.sh
blob: b4b4f972d8f0476b8f821f3e428abc6b53b18187 (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
#!/usr/bin/env bash
# Copyright (c) 2015 - 2019 DisplayLink (UK) Ltd.

suspend_displaylink-driver()
{
  while read -n 1 -t 1 SUSPEND_RESULT < /tmp/PmMessagesPort_out; do : ; done;
  echo "S" > /tmp/PmMessagesPort_in

  if [[ -p /tmp/PmMessagesPort_out ]]; then
    read -n 1 -t 10 SUSPEND_RESULT < /tmp/PmMessagesPort_out
  fi
}

resume_displaylink-driver()
{
  echo "R" > /tmp/PmMessagesPort_in
}

case "$1" in
  pre)
    suspend_displaylink-driver
    ;;
  post)
    resume_displaylink-driver
    ;;
esac