Skip to content

Instantly share code, notes, and snippets.

@Cybolic
Last active November 28, 2018 21:30
Show Gist options
  • Save Cybolic/ac300c78b9f98d43f28e85a9e90f4650 to your computer and use it in GitHub Desktop.
Save Cybolic/ac300c78b9f98d43f28e85a9e90f4650 to your computer and use it in GitHub Desktop.
This script makes opaque all windows that are currently completely transparent. Compton sometimes sets the transparency of windows to zero, so this helps get out of when this happens.
#!/usr/bin/env bash
WINDOW_IDS=$(xwininfo -root -tree | grep -v '("i3-frame"' | grep -oP '(?:[[:space:]]+)(0x[[:alnum:]]+)(?= ".*?":)')
for w_id in $WINDOW_IDS; do
w_prop="$(xprop -id $w_id)"
if (echo "$w_prop" | grep '_NET_WM_WINDOW_OPACITY' | grep ' = 0') &>/dev/null; then
xprop -f _NET_WM_WINDOW_OPACITY 32c -set _NET_WM_WINDOW_OPACITY "0xffffffff" -id $w_id
fi;
done
@Cybolic
Copy link
Author

Cybolic commented Nov 28, 2018

Upon further testing, the following addition to compton.conf seems to fix the issue:

opacity-rule = [ 
    # If not hidden and active (active-opacity)
    "100:!_NET_WM_STATE@:32a *= '_NET_WM_STATE_HIDDEN' && _NET_WM_STATE@:32a *= '_NET_WM_STATE_FOCUSED'",
    # If not hidden and not active (inactive-opacity)
    "80:!_NET_WM_STATE@:32a *= '_NET_WM_STATE_HIDDEN' && !_NET_WM_STATE@:32a *= '_NET_WM_STATE_FOCUSED'",
    # Hidden
    "0:_NET_WM_STATE@:32a *= '_NET_WM_STATE_HIDDEN'"
];

Using active-opacity or inactive-opacity on their own doesn't make a difference and using the latest i3-gaps doesn't fix it either but the above works for me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment