Skip to content

F.lux like color changes

Kim Silkebækken edited this page Jan 31, 2019 · 2 revisions

F.lux color changes

Note: Adjust time offset/range to adjust the amount of dimming and the time of day with peak colorscheme brightness.

let s:monotone_current_hour = 0
let s:monotone_flux_time_offset = 13
let s:monotone_flux_range = [0, 5]

function! s:MonotoneFlux()
	let l:current_hour = str2nr(strftime("%H"), 10)
	if l:current_hour == s:monotone_current_hour
		return
	endif
	let s:monotone_current_hour = l:current_hour
	let l:flux_factor = abs(s:monotone_flux_time_offset - s:monotone_current_hour)
	let l:flux_factor_clamped = max([s:monotone_flux_range[0], min([l:flux_factor, s:monotone_flux_range[1]])])

	call g:Monotone(10, l:flux_factor_clamped * 10, 90 - l:flux_factor_clamped * 3)
endfunction
autocmd CursorMoved,CursorHold,CursorHoldI,WinEnter,WinLeave,FocusLost,FocusGained,VimResized,ShellCmdPost * nested 
	\ call s:MonotoneFlux()
Clone this wiki locally