This is a fork of that replaces pango with for font rendering. Note: do not use the master branch; use one of the fontconfig branches
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

69 lines
2.0 KiB

# 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.
import argparse
import i3ipc
import signal
import sys
from functools import partial
def on_window_focus(inactive_opacity, ipc, event):
global prev_focused
global prev_workspace
focused_workspace = ipc.get_tree().find_focused()
if focused_workspace == None:
focused = event.container
workspace = focused_workspace.workspace().num
if != #
focused.command("opacity 1")
if workspace == prev_workspace:
prev_focused.command("opacity " + inactive_opacity)
prev_focused = focused
prev_workspace = workspace
def remove_opacity(ipc):
for workspace in ipc.get_tree().workspaces():
for w in workspace:
w.command("opacity 1")
if __name__ == "__main__":
transparency_val = "0.80"
parser = argparse.ArgumentParser(
description="This script allows you to set the transparency of unfocused windows in sway."
help="set opacity value in range 0...1",
args = parser.parse_args()
ipc = i3ipc.Connection()
prev_focused = None
prev_workspace = ipc.get_tree().find_focused().workspace().num
for window in ipc.get_tree():
if window.focused:
prev_focused = window
window.command("opacity " + args.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))