diff options
author | Teddy Wing | 2019-10-16 20:37:31 +0200 |
---|---|---|
committer | Teddy Wing | 2019-10-16 20:37:31 +0200 |
commit | 72c660e74a8d32e547c07ff2190b81263b0ab78f (patch) | |
tree | 87bef7b1521bc38b93ab39e7f1ce04ada0de3554 | |
parent | a3cb685eb03c256221e8412640fd8ab5a044df9c (diff) | |
download | dothammerspoon-72c660e74a8d32e547c07ff2190b81263b0ab78f.tar.bz2 |
Add brightness correction for OS X 10.15 Catalina
Since upgrading to 10.15 Catalina, when my external monitor is plugged
in and I wake up my machine, for some unexplained reason the internal
display resets to maximum brightness. Fix Catalina's nonsense on wake by
resetting to the brightness from before sleep.
-rw-r--r-- | catalina_brightness_bullshit.lua | 47 | ||||
-rw-r--r-- | init.lua | 1 |
2 files changed, 48 insertions, 0 deletions
diff --git a/catalina_brightness_bullshit.lua b/catalina_brightness_bullshit.lua new file mode 100644 index 0000000..17d5bde --- /dev/null +++ b/catalina_brightness_bullshit.lua @@ -0,0 +1,47 @@ +-- When an external monitor is connected, saves internal screen brightness when +-- locking the screen or sleeping. Restores the saved brightness level on +-- unlock or wake. Fixes OS X 10.15 Catalina's bullshit where unlocking my +-- machine caused the internal screen's brightness to be reset to the maximum. + +-- Copyright (c) 2019 Teddy Wing +-- +-- This program is free software: you can redistribute it and/or modify +-- it under the terms of the GNU General Public License as published by +-- the Free Software Foundation, either version 3 of the License, or +-- (at your option) any later version. +-- +-- This program is distributed in the hope that it will be useful, +-- but WITHOUT ANY WARRANTY; without even the implied warranty of +-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +-- GNU General Public License for more details. +-- +-- You should have received a copy of the GNU General Public License +-- along with this program. If not, see <https://www.gnu.org/licenses/>. + + +-- Default brightness to 50%. +cbb_brightness = 50 + +cbb_logger = hs.logger.new('catalina_brightness_bullshit', 'debug') + +cbb_wake_watcher = hs.caffeinate.watcher.new(function(event_type) + -- Only run if the external monitor is connected. + if hs.screen.primaryScreen():name() ~= 'G247HL' then + cbb_logger:d('no external monitor') + + return + end + + if event_type == hs.caffeinate.watcher.screensDidLock + or event_type == hs.caffeinate.watcher.screensDidSleep then + cbb_brightness = hs.brightness.get() + + cbb_logger:d('saved brightness: ', cbb_brightness) + elseif event_type == hs.caffeinate.watcher.screensDidUnlock + or event_type == hs.caffeinate.watcher.screensDidWake then + hs.brightness.set(cbb_brightness) + + cbb_logger:d('restored brightness: ', cbb_brightness) + end +end) +cbb_wake_watcher:start() @@ -18,6 +18,7 @@ require("hs.ipc") require('application_switch') +require('catalina_brightness_bullshit') require('gdrive_mouseover_item') require('mouse') require('terminal_tab_hotkeys') |