#!/bin/bash# Script to force the Konsole terminal background to solid black (#000000) with pure white text.set-euopipefail
# 1. Apply immediate runtime change using standard OSC Escape Sequencesapply_runtime_colors(){# OSC 10: Set default text foreground color to White (#FFFFFF)printf'\033]10;#FFFFFF\007'# OSC 11: Set default background color to Black (#000000)printf'\033]11;#000000\007'# (The prompt can't be changed from here: a script runs in its own shell.# update_bashrc_prompt below makes the plain prompt permanent for new terminals.)# Clear screen buffer to repaint the entire background canvas immediatelyclear
}# 2. Generate and store a persistent KDE Konsole Color Scheme fileapply_persistent_scheme(){localscheme_dir="${HOME}/.local/share/konsole"localscheme_file="${scheme_dir}/PureWhiteOnBlack.colorscheme"# Ensure local Konsole user profile directory existsmkdir-p"${scheme_dir}"# Write standard INI-formatted Konsole color schemecat<<'EOF' >"${scheme_file}"[General]Description=Pure White on BlackOpacity=1[Background]Color=0,0,0[BackgroundFaint]Color=0,0,0[BackgroundIntense]Color=0,0,0[Foreground]Color=255,255,255[ForegroundFaint]Color=200,200,200[ForegroundIntense]Color=255,255,255[Color0]Color=0,0,0[Color0Intense]Color=128,128,128[Color7]Color=220,220,220[Color7Intense]Color=255,255,255EOFecho"Persistent color scheme created at: ${scheme_file}"# Update default profile if it exists in local storagelocaldefault_profile="${scheme_dir}/Profile 1.profile"if[[-f"${default_profile}"]];thenifgrep-q"^ColorScheme=""${default_profile}";thensed-i's/^ColorScheme=.*/ColorScheme=PureWhiteOnBlack/'"${default_profile}"elseecho"ColorScheme=PureWhiteOnBlack">>"${default_profile}"fiecho"Updated existing profile at: ${default_profile}"fi}# 3. Permanently update ~/.bashrc to ensure future interactive sessions use white textupdate_bashrc_prompt(){localbashrc="${HOME}/.bashrc"localprompt_entry='export PS1="\u@\h:\w\$ "'if[[-f"${bashrc}"]];then# Append the uncolored prompt declaration if not already presentif!grep-qF'export PS1="\u@\h:\w\$ "'"${bashrc}";thenecho"">>"${bashrc}"echo"# Override shell prompt to use default white text">>"${bashrc}"echo"${prompt_entry}">>"${bashrc}"echo"Updated ${bashrc} with white PS1 prompt definition."elseecho"${bashrc} already contains the plain PS1 prompt override."fifi}main(){apply_runtime_colors
apply_persistent_scheme
update_bashrc_prompt
echo"Konsole color scheme and shell prompt updated successfully."}main"$@"