Hammerspoon / hammerspoon

Staggeringly powerful macOS desktop automation with Lua
http://www.hammerspoon.org
MIT License
12.12k stars 582 forks source link

Redshift wrongly active on external monitor #1197

Open tiagoboldt opened 7 years ago

tiagoboldt commented 7 years ago

When I plug in an external monitor when redshift should be disabled, the external monitor often gets its colors shifted anyway. Color in the main screen is ok though. Reloading the configuration from hammerspoon's icon in the menu bar solves the issue.

This is a very frequent issue, but it doesn't happen every time. If I reload the config the problem gets fixed and I'm unable to replicate it for some time by unplug and plugging the monitor. I haven't figured out the pattern for replicating the issue, but it has been happening every day, so might it

Here's my redshift config:

local location = hs.location.get()
local times = {sunrise = "07:00", sunset = "20:00"}
if location then
  local tzOffset = tonumber(string.sub(os.date("%z"), 1, -3))
  for i, v in pairs({"sunrise", "sunset"}) do
    times[v] = os.date("%H:%M", hs.location[v](location.latitude, location.longitude, tzOffset))
  end
end

hs.redshift.start(4200, times.sunset, times.sunrise)

logger.i("redshift location", location)
logger.i("redshift from", times.sunset, "to", times.sunrise)
logger.i("redshift started with state", hs.redshift.isDisabled())

local redshift = hs.menubar.new()
if redshift then
  function setRedshiftDisplay(disabled)
    if disabled then
      redshift:setTitle("☀️")
    else
      redshift:setTitle("🌙")
    end
  end

  function toggleRedshift()
    hs.redshift.toggle()
    setRedshiftDisplay(hs.redshift.isDisabled())
  end

  redshift:setClickCallback(toggleRedshift)
  setRedshiftDisplay(hs.redshift.isDisabled())
end
cmsj commented 7 years ago

@lowne any thoughts on this one?