Created
October 21, 2021 02:13
-
-
Save junkblocker/3f98f449317884a431026905e4333a8c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
local config = {} | |
local wezterm = require "wezterm" | |
local math = require "math" | |
local os = require "os" | |
math.randomseed(os.time()) | |
config.unix_domains = { | |
{ | |
name = "unix", | |
connect_automatically = true | |
} | |
} | |
config.keys = {} | |
config.debug_key_events = true | |
config.text_background_opacity = 1.0 | |
config.window_background_opacity = 1.0 | |
WALLPAPER_CHANGE_INTERVAL_SECONDS = 5 * 60 | |
WALLPAPERS = wezterm.glob(wezterm.home_dir .. "/Pictures/Terminal-Wallpapers/*") | |
WALLPAPER_LAST_CHANGED = 0 -- s.time() | |
function random_wallpaper() | |
wezterm.log_info("random_wallpaper()") | |
if #WALLPAPERS > 0 then | |
return WALLPAPERS[math.random(#WALLPAPERS)] | |
else | |
return wezterm.home_dir .. "/Pictures/Terminal-Wallpapers/120433284861-1024x768.jpg" | |
end | |
end | |
config.window_background_image = random_wallpaper() | |
local mapkey = function(mods, key, action) | |
config.keys[#config.keys + 1] = {key = key, mods = mods, action = action} | |
end | |
mapkey( | |
"CTRL|ALT|SHIFT", | |
"w", | |
wezterm.action_callback( | |
function(window, pane) | |
WALLPAPER_LAST_CHANGED = os.time() | |
-- set a new one | |
local overrides = window:get_config_overrides() or {} | |
overrides.window_background_image = random_wallpaper() | |
window:set_config_overrides(overrides) | |
end | |
) | |
) | |
config.window_background_image_hsb = { | |
brightness = 0.05, | |
hue = 0.1, | |
saturation = 0.1 | |
} | |
mapkey( | |
"CTRL|SHIFT", | |
"o", | |
wezterm.action_callback( | |
function(window, pane) | |
wezterm.log_info("CTRL+SHIFT+o") | |
local overrides = window:get_config_overrides() or {} | |
if | |
not overrides.window_background_image_hsb or not overrides.window_background_image_hsb.brightness or | |
overrides.window_background_image_hsb.brightness == 1.0 | |
then | |
overrides.window_background_image_hsb = {} | |
overrides.window_background_image_hsb.brightness = 0.05 | |
overrides.window_background_image_hsb.hue = 0.1 | |
overrides.window_background_image_hsb.saturation = 0.1 | |
else | |
overrides.window_background_image_hsb.brightness = 1.0 | |
overrides.window_background_image_hsb.hue = 1.0 | |
overrides.window_background_image_hsb.saturation = 1.0 | |
end | |
window:set_config_overrides(overrides) | |
end | |
) | |
) | |
return config |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment