From: Antonio Ospite Date: Fri, 29 Jun 2012 11:22:55 +0000 (+0200) Subject: contrib: add an example of how to start displaying images automatically X-Git-Tag: v0.1.3~18 X-Git-Url: https://git.ao2.it/libam7xxx.git/commitdiff_plain/69d3f89c0ad1b04bf78537726bd1ad891d94855a contrib: add an example of how to start displaying images automatically Add an example of how an am7xxx-autodisplay functionality might be implemented: some udev rules call a script which resizes the screen and then call am7xxx-play. --- diff --git a/contrib/99-am7xxx-autodisplay.rules b/contrib/99-am7xxx-autodisplay.rules new file mode 100644 index 0000000..fc58472 --- /dev/null +++ b/contrib/99-am7xxx-autodisplay.rules @@ -0,0 +1,3 @@ +# Example rules to show how to run a program when the device is plugged in or out +ACTION=="add", SUBSYSTEM=="usb", ATTRS{idVendor}=="1de1", ATTRS{idProduct}=="c101", MODE="0660", GROUP="plugdev", RUN+="am7xxx-autodisplay.sh start" +ACTION=="remove", SUBSYSTEM=="usb", ENV{ID_VENDOR_ID}=="1de1", ENV{ID_MODEL_ID}=="c101", RUN+="am7xxx-autodisplay.sh stop" diff --git a/contrib/am7xxx-autodisplay.sh b/contrib/am7xxx-autodisplay.sh new file mode 100755 index 0000000..9d5199d --- /dev/null +++ b/contrib/am7xxx-autodisplay.sh @@ -0,0 +1,49 @@ +#!/bin/sh +# +# am7xxx-autodisplay - resize the screen and run am7xxx-play +# +# Copyright (C) 2012 Antonio Ospite +# +# This program is free software. It comes without any warranty, to +# the extent permitted by applicable law. You can redistribute it +# and/or modify it under the terms of the Do What The Fuck You Want +# To Public License, Version 2, as published by Sam Hocevar. See +# http://sam.zoy.org/wtfpl/COPYING for more details. + +# This is just an example script to show how to resize the screen before +# running am7xxx-play, this can be called also from a udev script. +# +# Resizing the screen may be needed if the am7xxx device has problems +# displaying a certain resolution. +# +# For example on some devices the firmware fails to display images of +# resolution 800x469 resulting from scaled down 1024x600 screens, in +# cases like this, resizing the screen can be a viable workaround. + +USER=ao2 + +RESOLUTION_PROJECTOR=800x600 +RESOLUTION_ORIGINAL=1024x600 + +AM7XXX_PLAY=am7xxx-play + +# needed when running xrandr as root from udev rules, +# see https://bugs.launchpad.net/ubuntu/+source/xserver-xorg-video-intel/+bug/660901 +export XAUTHORITY=$(find /var/run/gdm3/ -type f -path "*${USER}*" 2> /dev/null) + +export DISPLAY=:0.0 + +case $1 in + start) + xrandr --size $RESOLUTION_PROJECTOR && \ + $AM7XXX_PLAY -f x11grab -i $DISPLAY + ;; + + stop) + xrandr --size $RESOLUTION_ORIGINAL + ;; + + *) + { echo "usage: $(basename $0) " 1>&2; exit 1; } + ;; +esac