I have this script, which changes NVIDIA-SETTINGS vibrance, when certain application/process is launched (in my case Counter-Strike:Global Offensive game)
Script:
#!/bin/bash
on="1023"
off="0"
dv="0"
# RESET
sleep 10
log "RESET"
nvidia-settings -a "[gpu:0]/DigitalVibrance[DFP-0]=$off"
while true; do #daemon mode
dv=`nvidia-settings -q "[gpu:0]/DigitalVibrance[DFP-0]" -t`
if pgrep -l csgo | grep csgo_linux
then
# log "Process csgo_linux found"
if [ $dv -eq $off ]; then
nvidia-settings -a "[gpu:0]/DigitalVibrance[DFP-0]=$on"
fi
else
# No process found
if [ $dv -eq $on ]; then
nvidia-settings -a "[gpu:0]/DigitalVibrance[DFP-0]=$off"
fi
fi
if [ $dv -eq $on ]; then
sleep 5
else
sleep 1
fi
done
What is wrong with this script, why it gives me these errors?
622 csgo_linux64
/home/matas/Desktop/vib-gui.sh: line 18: [: -eq: unary operator expected
/home/matas/Desktop/vib-gui.sh: line 28: [: -eq: unary operator expected
622 csgo_linux64
/home/matas/Desktop/vib-gui.sh: line 18: [: -eq: unary operator expected
/home/matas/Desktop/vib-gui.sh: line 28: [: -eq: unary operator expected
622 csgo_linux64
/home/matas/Desktop/vib-gui.sh: line 18: [: -eq: unary operator expected
/home/matas/Desktop/vib-gui.sh: line 28: [: -eq: unary operator expected
622 csgo_linux64
/home/matas/Desktop/vib-gui.sh: line 18: [: -eq: unary operator expected
/home/matas/Desktop/vib-gui.sh: line 28: [: -eq: unary operator expected
EDIT:
#!/bin/bash
on="1023"
off="0"
dv="0"
# RESET
sleep 10
nvidia-settings -a "[gpu:0]/DigitalVibrance[DFP-0]=$off"
while true; do #daemon mode
dv=`nvidia-settings -q "[gpu:0]/DigitalVibrance[DFP-0]" -t`
if pgrep -l csgo | grep csgo_linux
then
# log "Process csgo_linux found"
if [ "$dv -eq $off" ]; then
nvidia-settings -a "[gpu:0]/DigitalVibrance[DFP-0]=$on"
fi
else
# No process found
if [ "$dv" -eq "$on" ]; then
nvidia-settings -a "[gpu:0]/DigitalVibrance[DFP-0]=$off"
fi
fi
if [ "$dv -eq $on" ]; then
sleep 5
else
sleep 1
fi
done
$dv -eq $on
to$dv = $on
and try again – George Udosen May 13 '17 at 16:45[ "$dv" -eq "$on" ]
– Byte Commander May 13 '17 at 16:45"$dv" -eq "$on"
to"$dv" = "$on"
, yes forgot the quotes... – George Udosen May 13 '17 at 16:49[ $dv -eq $on ]
says "-eq: unary operator expected", this means that you first variable,$dv
is empty. Check the output of the command which you are assigning to it. – Byte Commander May 13 '17 at 16:52pgrep -l csgo | grep csgo_linux
, searching for processes with "csgo_linux" in their name. The 14441 is the process id then. If you get such output and not any error messages, I suppose the script is working. – Byte Commander May 13 '17 at 17:00"$dv -eq $off"
in line 17, but it must be"$dv" -eq "$off"
– Byte Commander May 13 '17 at 17:15