#!/bin/bash
# Copyright 2017 Lucid Networks sloeckle
# Package Version 1.11-0 - Script Version 2

. /opt/nexp-tools/nexp-tools.lib

if [ -a /home/nexp/bin/disable-second-monitor.sh ]; then
  /home/nexp/bin/disable-second-monitor.sh
  sleep 5
fi

if [ -a /home/nexp/bin/setres.sh ]; then
  /home/nexp/bin/setres.sh
  sleep 5
fi

source /etc/nexp-tools/nexp-tools.conf

# Log search and rotation
rotatechromelogs

export DISPLAY=:0
export EMAIL=$HOSTNAME'@lucidnetworks.net'
currentresolution=$(xdpyinfo | grep dimensions: | awk '{print $2}')
if [[ $currentresolution == *"3840x2160"* ]]
then
  background="nexp3840x2160.jpg"
else
  background="nexp1920x1080.jpg"
fi
if [[ $1 == "-notfullscreen" ]]
then
  /usr/bin/google-chrome file:///usr/share/nexp-tools/$background &
else
  /usr/bin/google-chrome $CHROMEOPTS file:///usr/share/nexp-tools/$background &
fi
sleep 4
xdotool key F5
sleep 1
xdotool key space
