mirror of
https://github.com/swaywm/sway.git
synced 2026-04-23 06:46:27 -04:00
Add flag to set all inactive windows transparent
When using multiple monitors, each monitor has a separate workspace. Default behavior remains the same. An --allinactive/-a flag is added. When this flag is used, all inactive windows on all workspaces will become transparent upon focus change.
This commit is contained in:
parent
a8261f6c1d
commit
d425cc90cc
1 changed files with 12 additions and 3 deletions
|
|
@ -11,7 +11,7 @@ import signal
|
||||||
import sys
|
import sys
|
||||||
from functools import partial
|
from functools import partial
|
||||||
|
|
||||||
def on_window_focus(inactive_opacity, ipc, event):
|
def on_window_focus(inactive_opacity, allinactive, ipc, event):
|
||||||
global prev_focused
|
global prev_focused
|
||||||
global prev_workspace
|
global prev_workspace
|
||||||
|
|
||||||
|
|
@ -25,7 +25,9 @@ def on_window_focus(inactive_opacity, ipc, event):
|
||||||
|
|
||||||
if focused.id != prev_focused.id: # https://github.com/swaywm/sway/issues/2859
|
if focused.id != prev_focused.id: # https://github.com/swaywm/sway/issues/2859
|
||||||
focused.command("opacity 1")
|
focused.command("opacity 1")
|
||||||
if workspace == prev_workspace:
|
if allinactive:
|
||||||
|
prev_focused.command("opacity " + inactive_opacity)
|
||||||
|
elif workspace == prev_workspace:
|
||||||
prev_focused.command("opacity " + inactive_opacity)
|
prev_focused.command("opacity " + inactive_opacity)
|
||||||
prev_focused = focused
|
prev_focused = focused
|
||||||
prev_workspace = workspace
|
prev_workspace = workspace
|
||||||
|
|
@ -52,6 +54,13 @@ if __name__ == "__main__":
|
||||||
default=transparency_val,
|
default=transparency_val,
|
||||||
help="set opacity value in range 0...1",
|
help="set opacity value in range 0...1",
|
||||||
)
|
)
|
||||||
|
parser.add_argument(
|
||||||
|
"--allinactive",
|
||||||
|
"-a",
|
||||||
|
dest="allinactive",
|
||||||
|
action="store_true",
|
||||||
|
help="Whether windows in the inactive workspace should also be made transparent.",
|
||||||
|
)
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
|
|
||||||
ipc = i3ipc.Connection()
|
ipc = i3ipc.Connection()
|
||||||
|
|
@ -65,5 +74,5 @@ if __name__ == "__main__":
|
||||||
window.command("opacity " + args.opacity)
|
window.command("opacity " + args.opacity)
|
||||||
for sig in [signal.SIGINT, signal.SIGTERM]:
|
for sig in [signal.SIGINT, signal.SIGTERM]:
|
||||||
signal.signal(sig, lambda signal, frame: remove_transparency(ipc))
|
signal.signal(sig, lambda signal, frame: remove_transparency(ipc))
|
||||||
ipc.on("window::focus", partial(on_window_focus, args.opacity))
|
ipc.on("window::focus", partial(on_window_focus, args.opacity, args.allinactive))
|
||||||
ipc.main()
|
ipc.main()
|
||||||
Loading…
Add table
Add a link
Reference in a new issue