For years, I’ve been enjoying the practice of using multiple monitors to get my work done. My current setup consists of three monitors, where the left and right are in portrait mode and the middle is in landscape mode.
I generally will have my editor, terminal or browser on the center monitor, my notes on the right and my communication programs on the left. These communication programs include Slack, Discord, Email etc. I’ve found that having access to these communication programs in my peripherals to be incredibly distracting to focus, both in depth and duration.
Back when I was developing on an macOS machine, I found extensive benefits from using the program Isolator which would blur all non active windows. Since I’m now using Linux for 99% of my development, I decided to write a short script to try to somewhat isolate this program. Our goal is have a script that toggles the turning of the left and right monitors from completely visible to completely black. This will allow us to focus on the middle monitor. Additionally, this will be incredibly useful if notifications from these programs are not visible in the form of alerts on our middle monitor or in any audible form.
Our script essentially leverages the writing and deleting of a temporary file to support the desired toggle effect. We use the program xrandr
to interact with our displays, as its generally available or installable on all Linux distros.
#!/bin/bash
set -euo pipefail
IFS=$'\n\t'
TOGGLE=$HOME/.focus-mode-toggle-file
FOCUS="xrandr --output DP-4 --brightness 0.0 && xrandr --output DP-2 --brightness 0.0"
UNFOCUS="xrandr --output DP-4 --brightness 1.0 && xrandr --output DP-2 --brightness 1.0"
if [ ! -e $TOGGLE ]; then
echo "Enabling focus mode"
touch $TOGGLE
eval "$FOCUS"
else
echo "Disabling focus mode"
rm $TOGGLE
eval "$UNFOCUS"
fi
So our workflow looks like this:
- Want to focus on the middle monitor? Run
$ toggle-focus.sh
and disable the display of the left and right monitors. - Want to check in on the communication programs? Run
$ toggle-focus.sh
If you want to use this script, you’ll have to replace the references to DP-4
and DP-2
with your own displays. You can find these displays by running $ xrandr
and looking at the output.
I generally like to put these types of scripts in my toolbox, so this link will have the most up to date version.
One change I might make is not blurring my right monitor, as I use that for notes. Additionally, since I’m now in love with i3wm, I’ll probably end up binding this script to a keystroke.
I hope this script helps you remove distractions from your work and make it easier to focus on your tasks at hand.