How to Disable Redshift during Screenshots

Redshift is a great program to lower the strain on one’s eyes and help one go to sleep sooner. It does this by making the screen use the red light more and the blue light less. However, we don’t like red screenshots. Here’s how to make screenshots have normal colors.

Prereqs

Well, make sure you have redshift installed

To do this we are going to substitute our screensaver script with one that will disable redshift so we can

#!/bin/bash

# script to disable redshift while doing screenshots
# options:
# screen:   -f
# window:   -w
# slection: -s

# todo: alt modifier makes it autosave

# What screensaver do you use?
ss="xfce4-screenshooter"

# put the arguments for these tasks for your screensaver here:
full_screen="-f"
window="-w"
selection_with_mouse="-r"

# Other options you'd like to give the screensaver program.
# For example, I like to specify the default folder where I'm going to save the screenshot:
# (remember this is for xfce4-screenshooter. Yours may be different)
#opts="-s '/path/to/where/to/save/screenshots'"

##########################
### functions and program:

function _pause_redshift() {
  # first check that redshit is running (or we might mess up user's screen colors?)
  if [ -n "$(pgrep redshift)" ] ; then
  # we need to 'pause' the current running redshift
    killall -SIGSTOP redshift
    # and we run another redshift resetting (-x) the settings without fade out (-r)
    redshift -xr
  fi
}

function _cont_redshift() {
  # first check that redshit is running
  if [ -n "$(pgrep redshift)" ] ; then
    # now we can tell redshift to continue
    killall -SIGCONT redshift
  fi
}

case $1 in

  -f) # full_screen
      _pause_redshift ; $ss $full_screen $opts ; _cont_redshift
  ;;
  -w) # window only
      _pause_redshift ; $ss $window $opts ; _cont_redshift
  ;;
  -r) # selection with mouse
      _pause_redshift ; $ss $selection_with_mouse $opts ; _cont_redshift
  ;;
  *) echo "Usage $0 <-f -w -r>"
  ;;
esac