@@ -62,6 +62,7 @@ class SettingData(NamedTuple):
6262 "autohide" : ("autohide" , "no_autohide" ),
6363 "notify" : ("enabled" , "disabled" ),
6464 "exit_confirmation" : ("enabled" , "disabled" ),
65+ "transparency" : ("enabled" , "disabled" ),
6566}
6667
6768COLOR_DEPTH_ARGS_TO_DEPTHS : Dict [str , int ] = {
@@ -80,13 +81,15 @@ class SettingData(NamedTuple):
8081 "color-depth" : "256" ,
8182 "maximum-footlinks" : "3" ,
8283 "exit_confirmation" : "enabled" ,
84+ "transparency" : "disabled" ,
8385}
8486assert DEFAULT_SETTINGS ["autohide" ] in VALID_BOOLEAN_SETTINGS ["autohide" ]
8587assert DEFAULT_SETTINGS ["notify" ] in VALID_BOOLEAN_SETTINGS ["notify" ]
8688assert DEFAULT_SETTINGS ["color-depth" ] in COLOR_DEPTH_ARGS_TO_DEPTHS
8789assert (
8890 DEFAULT_SETTINGS ["exit_confirmation" ] in VALID_BOOLEAN_SETTINGS ["exit_confirmation" ]
8991)
92+ assert DEFAULT_SETTINGS ["transparency" ] in VALID_BOOLEAN_SETTINGS ["transparency" ]
9093
9194
9295def in_color (color : str , text : str ) -> str :
@@ -155,6 +158,22 @@ def parse_args(argv: List[str]) -> argparse.Namespace:
155158 help = "do not mark messages as read in the session" ,
156159 )
157160
161+ transparency_group = parser .add_mutually_exclusive_group ()
162+ transparency_group .add_argument (
163+ "--transparency" ,
164+ dest = "transparency" ,
165+ action = "store_const" ,
166+ const = "enabled" ,
167+ help = "enable transparent background (if supported by theme and terminal)" ,
168+ )
169+ transparency_group .add_argument (
170+ "--no-transparency" ,
171+ dest = "transparency" ,
172+ action = "store_const" ,
173+ const = "disabled" ,
174+ help = "disable transparent background" ,
175+ )
176+
158177 notify_group = parser .add_mutually_exclusive_group ()
159178 notify_group .add_argument (
160179 "--notify" ,
@@ -496,6 +515,11 @@ def main(options: Optional[List[str]] = None) -> None:
496515 theme_to_use = SettingData (real_theme_name , theme_to_use .source )
497516
498517 ### Load overrides & validate remaining settings
518+ if args .transparency :
519+ zterm ["transparency" ] = SettingData (
520+ args .transparency , ConfigSource .COMMANDLINE
521+ )
522+
499523 if args .autohide :
500524 zterm ["autohide" ] = SettingData (args .autohide , ConfigSource .COMMANDLINE )
501525
@@ -553,22 +577,27 @@ def print_setting(setting: str, data: SettingData, suffix: str = "") -> None:
553577 print_setting ("maximum footlinks value" , zterm ["maximum-footlinks" ])
554578 print_setting ("color depth setting" , zterm ["color-depth" ])
555579 print_setting ("notify setting" , zterm ["notify" ])
580+ print_setting ("transparency setting" , zterm ["transparency" ])
556581
557582 ### Generate data not output to user, but into Controller
583+ # Translate valid strings for boolean values into True/False
584+ boolean_settings : Dict [str , bool ] = dict ()
585+ for setting , valid_values in VALID_BOOLEAN_SETTINGS .items ():
586+ boolean_settings [setting ] = zterm [setting ].value == valid_values [0 ]
587+
558588 # Generate urwid palette
559589 color_depth_str = zterm ["color-depth" ].value
560590 color_depth = COLOR_DEPTH_ARGS_TO_DEPTHS [color_depth_str ]
591+ transparency_enabled = boolean_settings ["transparency" ]
561592
562593 theme_data = generate_theme (
563594 theme_to_use .value ,
564595 color_depth = color_depth ,
565- transparent_background = False ,
596+ transparent_background = transparency_enabled ,
566597 )
567598
568- # Translate valid strings for boolean values into True/False
569- boolean_settings : Dict [str , bool ] = dict ()
570- for setting , valid_boolean_values in VALID_BOOLEAN_SETTINGS .items ():
571- boolean_settings [setting ] = zterm [setting ].value == valid_boolean_values [0 ]
599+ # Avoid passing this to the Controller
600+ boolean_settings .pop ("transparency" )
572601
573602 Controller (
574603 config_file = zuliprc_path ,
0 commit comments