#!/bin/bash # # Copyright (c) 2019 Clementine Computing LLC. # # This file is part of PopuFare. # # PopuFare is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # PopuFare is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with PopuFare. If not, see . # func="$1" param="$2" echo "$0 , $func , $param ." >> /tmp/custom.log if [[ "$func" == "dim" ]] ; then infofn="/tmp/kiosk.info" export DISPLAY=':0' export XAUTHORITY='/home/pi/.Xauthority' if [[ -e "/tmp/kiosk.info" ]] ; then disp=`grep DISPLAY $infofn | cut -f2 -d'='` auth=`grep XAUTHORITY $infofn | cut -f2 -d'='` export DISPLAY="$disp" export XAUTHORITY="$auth" fi /usr/bin/xset dpms force off elif [[ "$func" == "undim" ]] ; then infofn="/tmp/kiosk.info" export DISPLAY=':0' export XAUTHORITY='/home/pi/.Xauthority' if [[ -e "/tmp/kiosk.info" ]] ; then disp=`grep DISPLAY $infofn | cut -f2 -d'='` auth=`grep XAUTHORITY $infofn | cut -f2 -d'='` export DISPLAY="$disp" export XAUTHORITY="$auth" fi /usr/bin/xset s noblank /usr/bin/xset s off /usr/bin/xset -dpms elif [[ "$func" == "interface" ]] ; then if [[ "$param" == "up" ]]; then /sbin/ip link set eth0 up elif [[ "$param" == "down" ]] ; then /sbin/ip link set eth0 down fi elif [[ "$func" == "ts_calibrate" ]] ; then /usr/bin/ts_calibrate elif [[ "$func" == "volume" ]] ; then vol=100 if [[ "$param" != "" ]] ; then vol=`printf "%2d" "$param" 2> /dev/null` ; fi chan=`amixer controls | grep Volume | head -n1 | cut -f1 -d',' | cut -f2 -d'='` amixer cset numid=$chan -- ${vol}% > /dev/null elif [[ "$func" == "say" ]] ; then echo "$param" | espeak --stdin --stdout | aplay 2> /dev/null elif [[ "$func" == "getconfig" ]] ; then cfgfn="/home/bus/config/popufare.config" if [[ -e $cfgfn ]] ; then cat $cfgfn | tr '\n' ' ' else echo "file-not-found" fi elif [[ "$func" == "setconfig" ]] ; then cfgfn="/home/bus/config/popufare.config" _v=`echo "$param" | tr '=' ' ' | grep -P -o 'volume (\d+)' | cut -f2 -d' '` _b=`echo "$param" | tr '=' ' ' | grep -P -o 'brightness (\d+)' | cut -f2 -d' '` _d=`echo "$param" | tr '=' ' ' | grep -P -o 'showdimclock (\d+)' | cut -f2 -d' '` if [[ "$_v" == "" ]] ; then _v=100; fi if [[ "$_b" == "" ]] ; then _b=100; fi if [[ "$_d" == "" ]] ; then _d="0"; fi _t=`mktemp` echo -e "volume=$_v\nbrightness=$_b\nshowdimclock=$_d\n" > $_t mv $_t $cfgfn cat $cfgfn | tr '\n' ' ' elif [[ "$func" == "reboot" ]] ; then /sbin/reboot fi exit 0