Strobe Light – Bash Script Edition

Here is a fun little script I put together that will turn your monitor into a strobe light via xbacklight. It also requires yad for the initial graphical configuration dialog. (It facilitates a little more complicated forms than zenity.)

On Ubuntu-based distros you should be able to simply run “sudo apt install xbacklight” and “sudo apt install yad” in the terminal. Here’s a download link for the script: Here.

You can then set its perms to make it executable and run it from the desktop.

Here’s the source:

#!/bin/bash
declare -a settingsArray
let nCount=0
settings=$(yad --title="Strobe Light" --form --align=right --field="  Lower Brightness" --field="  Upper Brightness" --field="  Flash Length" --field="  Interval Length" "0" "100" "0.05" "0.1" --button="Run:0" --separator=' ')
ret=$?

[[ $ret -ne 0 ]] && exit 0

for item in $settings; do
  settingsArray[nCount]="$item"
  let nCount++
done

LowerBrightness=${settingsArray[0]}
UpperBrightness=${settingsArray[1]}
FlashLength=${settingsArray[2]}
IntervalLength=${settingsArray[3]}

function flashScreen
{
  xbacklight -set $UpperBrightness -time 0
  sleep $FlashLength
  xbacklight -set $LowerBrightness -time 0
}

while [[ true ]]; do
  sleep $IntervalLength
  flashScreen
done