#!/bin/bash
output=$(xrandr | grep ' connected ' | awk '{print $1}' | head -1)
echo $output > /tmp/montog 
screenSize=$(xrandr | awk 'BEGIN {foundOutput=0}
    / '$output' / {foundOutput=1}
    /\*\+/ {print $1}
    /^[^ ]/ {if(foundOutput) exit 0}')
echo $screenSize >> /tmp/montog
if [ "$screenSize" != "" ]; then
    xrandr --output $output --fb $screenSize --off
	spd-say 'Lécran est éteint'
else
    xrandr --output $output --auto
    spd-say 'Lécran est allumé'
fi
