examples: the examples were always meant to be all under GPL-3+
[libam7xxx.git] / contrib / am7xxx-autodisplay.sh
1 #!/bin/sh
2 #
3 # am7xxx-autodisplay - resize the screen and run am7xxx-play
4 #
5 # Copyright (C) 2012-2014  Antonio Ospite <ao2@ao2.it>
6 #
7 # This program is free software. It comes without any warranty, to
8 # the extent permitted by applicable law. You can redistribute it
9 # and/or modify it under the terms of the Do What The Fuck You Want
10 # To Public License, Version 2, as published by Sam Hocevar. See
11 # http://sam.zoy.org/wtfpl/COPYING for more details.
12
13 # This is just an example script to show how to resize the screen before
14 # running am7xxx-play, this can be called also from a udev script.
15 #
16 # Resizing the screen may be needed if the am7xxx device has problems
17 # displaying a certain resolution.
18 #
19 # For example on some devices the firmware fails to display images of
20 # resolution 800x469 resulting from scaled down 1024x600 screens, in
21 # cases like this, resizing the screen can be a viable workaround.
22
23 USER=ao2
24
25 RESOLUTION_PROJECTOR=800x600
26 RESOLUTION_ORIGINAL=1024x600
27
28 AM7XXX_PLAY=am7xxx-play
29
30 # needed when running xrandr as root from udev rules,
31 # see https://bugs.launchpad.net/ubuntu/+source/xserver-xorg-video-intel/+bug/660901
32 export XAUTHORITY=$(find /var/run/gdm3/ -type f -path "*${USER}*" 2> /dev/null)
33
34 export DISPLAY=:0.0
35
36 case $1 in
37   start)
38     xrandr --size $RESOLUTION_PROJECTOR && \
39       $AM7XXX_PLAY -f x11grab -i $DISPLAY
40     ;;
41
42   stop)
43     xrandr --size $RESOLUTION_ORIGINAL
44     ;;
45
46   *)
47     { echo "usage: $(basename $0) <start|stop>" 1>&2; exit 1; }
48     ;;
49 esac