Add picom inactive window opacity automatic toggle

Whenever i3 is using gapless mode, all windows will be opaque. When gaps
are shown inactive windows will have some transparency and blur behind
them.

Script can be invoked manually with `picom_toggle_inactive_opacity` to
toggle, `picom_toggle_inactive_opacity on` or
`picom_toggle_inactive_opacity off` to set it respectively.
This commit is contained in:
Marty Oehme 2019-11-18 22:52:25 +01:00
parent 717b9d9096
commit 3d1438f657
4 changed files with 47 additions and 14 deletions

View file

@ -90,11 +90,11 @@ for_window [class="^.*"] border pixel 0
# no gaps if there is only 1 window
smart_gaps on
# by default set some gaps when multiple windows are on the workspace
gaps inner 5
gaps inner 0
gaps outer 0
# enable / disable gaps (g disables, G enables)
bindsym $mod+shift+g gaps inner current set 5; gaps outer current set 0
bindsym $mod+g gaps inner current set 0; gaps outer current set 0
bindsym $mod+shift+g gaps inner current set 15; gaps outer current set 0; exec picom_toggle_inactive_opacity on
bindsym $mod+g gaps inner current set 0; gaps outer current set 0; exec picom_toggle_inactive_opacity off
# Define names for default workspaces for which we configure key bindings later on.
# We use variables to avoid repeating the names in multiple places.

View file

@ -105,25 +105,31 @@ shadow-ignore-shaped = false;
#
#################################
inactive-opacity = 1;
active-opacity = 1;
inactive-opacity = 0.8;
active-opacity = 0.9;
frame-opacity = 1;
inactive-opacity-override = false;
inactive-opacity-override = true;
# Dim inactive windows. (0.0 - 1.0)
#inactive-dim = 0.1;
# Do not let dimness adjust based on window opacity.
# inactive-dim-fixed = true;
# Blur background of transparent windows. Bad performance with X Render backend. GLX backend is preferred.
blur-background = false;
# blur-background = true;
# Blur background of opaque windows with transparent frames as well.
blur-background-frame = false;
# blur-background-frame = false;
# Do not let blur radius adjust based on window opacity.
blur-background-fixed = true;
blur-background-exclude = [
"window_type = 'dock'",
"window_type = 'desktop'"
];
# blur-background-fixed = true;
# blur-background-exclude = [
# "window_type = 'dock'",
# "window_type = 'desktop'"
# ];
blur:
{
method = "gaussian";
size = 10;
deviation = 5.0;
};
#################################
#

View file

@ -0,0 +1,27 @@
#!/bin/bash
# toggle the translucency of inactive windows in the picom compositor
# by substituting the true/false setting in the picom config file.
# picom will automatically reload its settings on any config file changes.
#
# scipt can be called without arguments to toggle the value;
# or with on / off to set it to translucent / opaque, respectively.
piconf="$XDG_CONFIG_HOME"/picom/picom.conf
line=$(grep -n "inactive-opacity-override" "$piconf")
IFS=: read -r line text < <(grep -n "inactive-opacity-override" "$piconf")
_replace() { # line file old new
sed -i "$1 s/$3/$4/" "$2"
}
if [ "$1" = "off" ]; then
_replace "$line" "$piconf" "true" "false"
elif [ "$1" = "on" ]; then
_replace "$line" "$piconf" "false" "true"
elif echo "$text" | grep -q "true"; then
_replace "$line" "$piconf" "true" "false"
elif echo "$text" | grep -q "false"; then
_replace "$line" "$piconf" "false" "true"
fi

View file

@ -54,7 +54,7 @@ type xcape >/dev/null 2>&1 && xcape -e 'Control_L=Escape'
# if unclutter exists start it
type unclutter >/dev/null 2>&1 && unclutter &
# if picom exists then we can start it as our compositor
type picom >/dev/null 2>&1 && picom &
type picom >/dev/null 2>&1 && picom --experimental-backends &
# same deal with flashfocus as our active window indicator
type flashfocus >/dev/null 2>&1 && flashfocus -l never &
# if redshift is installed run it