mirror of
https://github.com/swaywm/sway.git
synced 2026-04-23 06:46:27 -04:00
contrib/inactive-windows-transparency: Add active window opacity
Opacity of active window can now be set with the -a or --active-ocacity flag. Previous inactive opacity flag (-o) has changed to -i or --inactive-opacity. Change will break for users using the old flag.
This commit is contained in:
parent
47023befbf
commit
a5cab2bb5d
1 changed files with 21 additions and 15 deletions
|
|
@ -1,9 +1,7 @@
|
|||
#!/usr/bin/python
|
||||
|
||||
# This script requires i3ipc-python package (install it from a system package manager
|
||||
# or pip).
|
||||
# It makes inactive windows transparent. Use `transparency_val` variable to control
|
||||
# transparency strength in range of 0…1 or use the command line argument -o.
|
||||
# This script requires i3ipc-python package (install it from a system package manager or pip).
|
||||
# Use with --help flag for usage isntructions.
|
||||
|
||||
import argparse
|
||||
import i3ipc
|
||||
|
|
@ -11,7 +9,7 @@ import signal
|
|||
import sys
|
||||
from functools import partial
|
||||
|
||||
def on_window_focus(inactive_opacity, ipc, event):
|
||||
def on_window_focus(args, ipc, event):
|
||||
global prev_focused
|
||||
|
||||
focused_workspace = ipc.get_tree().find_focused()
|
||||
|
|
@ -24,8 +22,8 @@ def on_window_focus(inactive_opacity, ipc, event):
|
|||
# on_window_focus not called only when focused is changed,
|
||||
# but also when a window is moved
|
||||
if focused.id != prev_focused.id:
|
||||
focused.command("opacity 1")
|
||||
prev_focused.command("opacity " + inactive_opacity)
|
||||
focused.command("opacity " + args.active_opacity)
|
||||
prev_focused.command("opacity " + args.inactive_opacity)
|
||||
prev_focused = focused
|
||||
|
||||
|
||||
|
|
@ -41,17 +39,25 @@ def remove_opacity(ipc):
|
|||
|
||||
|
||||
if __name__ == "__main__":
|
||||
transparency_val = "0.80"
|
||||
default_inactive_opacity = "0.80"
|
||||
default_active_opacity = "1.0"
|
||||
|
||||
parser = argparse.ArgumentParser(
|
||||
description="This script allows you to set the transparency of unfocused windows in sway."
|
||||
description="This script allows you to set the transparency of focused and unfocused windows in sway."
|
||||
)
|
||||
parser.add_argument(
|
||||
"--opacity",
|
||||
"-o",
|
||||
"--inactive-opacity",
|
||||
"-i",
|
||||
type=str,
|
||||
default=transparency_val,
|
||||
help="set opacity value in range 0...1",
|
||||
default=default_inactive_opacity,
|
||||
help="value between 0 and 1 denoting opacity for inactive windows",
|
||||
)
|
||||
parser.add_argument(
|
||||
"--active-opacity",
|
||||
"-a",
|
||||
type=str,
|
||||
default=default_active_opacity,
|
||||
help="value between 0 and 1 denoting opacity for active windows",
|
||||
)
|
||||
args = parser.parse_args()
|
||||
|
||||
|
|
@ -62,8 +68,8 @@ if __name__ == "__main__":
|
|||
if window.focused:
|
||||
prev_focused = window
|
||||
else:
|
||||
window.command("opacity " + args.opacity)
|
||||
window.command("opacity " + args.inactive_opacity)
|
||||
for sig in [signal.SIGINT, signal.SIGTERM]:
|
||||
signal.signal(sig, lambda signal, frame: remove_opacity(ipc))
|
||||
ipc.on("window::focus", partial(on_window_focus, args.opacity))
|
||||
ipc.on("window::focus", partial(on_window_focus, args))
|
||||
ipc.main()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue