From 069e5bb71413423574c210f742138064e6e8c554 Mon Sep 17 00:00:00 2001 From: David Leavenworth Date: Tue, 29 Nov 2022 11:35:42 -0800 Subject: [PATCH 1/2] feat: can now pass 'true' or 'false' to tab_mute --- qutebrowser/components/misccommands.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/qutebrowser/components/misccommands.py b/qutebrowser/components/misccommands.py index bf9f80745..808e6b1ab 100644 --- a/qutebrowser/components/misccommands.py +++ b/qutebrowser/components/misccommands.py @@ -339,7 +339,8 @@ def debug_webaction(tab: apitypes.Tab, action: str, count: int = 1) -> None: @cmdutils.register() @cmdutils.argument('tab', value=cmdutils.Value.count_tab) -def tab_mute(tab: Optional[apitypes.Tab]) -> None: +@cmdutils.argument('to_set', choices=['true', 'false']) +def tab_mute(tab: Optional[apitypes.Tab], to_set: str = None) -> None: """Mute/Unmute the current/[count]th tab. Args: @@ -348,7 +349,12 @@ def tab_mute(tab: Optional[apitypes.Tab]) -> None: if tab is None: return try: - tab.audio.set_muted(not tab.audio.is_muted(), override=True) + if to_set == 'true': + tab.audio.set_muted(True, override=True) + elif to_set == 'false': + tab.audio.set_muted(False, override=True) + else: + tab.audio.set_muted(not tab.audio.is_muted(), override=True) except apitypes.WebTabError as e: raise cmdutils.CommandError(e) From 9a62b2b1bd2af21931a7c0944d3a248f336fdc2a Mon Sep 17 00:00:00 2001 From: David Leavenworth Date: Tue, 29 Nov 2022 11:40:44 -0800 Subject: [PATCH 2/2] doc: added docstrings for the new argument --- qutebrowser/components/misccommands.py | 1 + 1 file changed, 1 insertion(+) diff --git a/qutebrowser/components/misccommands.py b/qutebrowser/components/misccommands.py index 808e6b1ab..4c8624395 100644 --- a/qutebrowser/components/misccommands.py +++ b/qutebrowser/components/misccommands.py @@ -345,6 +345,7 @@ def tab_mute(tab: Optional[apitypes.Tab], to_set: str = None) -> None: Args: count: The tab index to mute or unmute, or None + to_set: The mute setting to force: 'true' 'false' or 'None """ if tab is None: return