From f95649b1e524f85d27bfbec9ca09d48ddb712ffd Mon Sep 17 00:00:00 2001 From: fr0stbyt Date: Sat, 21 Feb 2026 01:22:02 -0600 Subject: [PATCH] Add backgroundOpacity config option to fade image toward black --- index.js | 63 ++++++++++++++++++++++++++++++-------------------------- 1 file changed, 34 insertions(+), 29 deletions(-) diff --git a/index.js b/index.js index 8ce1df6..9dd5f1f 100644 --- a/index.js +++ b/index.js @@ -1,29 +1,34 @@ -// Import path if we need to resolve relative paths. -const path = require('path') -const os = require('os') - -// Let's add that background image. -exports.decorateConfig = config => { - if (!config.backgroundImage) return - // Check if the background path is absolute. - const backgroundPath = path.isAbsolute(config.backgroundImage) - // If it is absolute, then set it to the value, else resolve it correctly. - ? config.backgroundImage - : path.resolve(os.homedir(), config.backgroundImage) - // Assign the old config and our customizations to a new object and return it. - return Object.assign(config, { - // This makes the terminal transparent. - backgroundColor: 'transparent', - // Add our custom background CSS. Don't reassign CSS to avoid replacing any existing CSS. - css: ` - ${config.css || ''} - .hyper_main { - background: url(file://${backgroundPath}) center; - background-size: cover; - } - .terms_terms { - background-color: transparent; - } - ` - }) -} +// Import path if we need to resolve relative paths. +const path = require('path') +const os = require('os') + +// Let's add that background image. +exports.decorateConfig = config => { + if (!config.backgroundImage) return + // Check if the background path is absolute. + const backgroundPath = path.isAbsolute(config.backgroundImage) + // If it is absolute, then set it to the value, else resolve it correctly. + ? config.backgroundImage + : path.resolve(os.homedir(), config.backgroundImage) + // Pull opacity from config, default to 1.0 if not set (backwards compatible). + // We invert it for the black overlay — higher opacity = more image visible = less black. + const overlay = config.backgroundOpacity !== undefined ? 1 - config.backgroundOpacity : 0 + // Assign the old config and our customizations to a new object and return it. + return Object.assign(config, { + // This makes the terminal transparent. + backgroundColor: 'transparent', + // Add our custom background CSS. Don't reassign CSS to avoid replacing any existing CSS. + css: ` + ${config.css || ''} + .hyper_main { + background: + linear-gradient(rgba(0,0,0,${overlay}), rgba(0,0,0,${overlay})), + url(file://${backgroundPath}) center; + background-size: cover; + } + .terms_terms { + background-color: transparent; + } + ` + }) +}