From 3d1438f65777797a2241c951956c2075344b19a8 Mon Sep 17 00:00:00 2001 From: Marty Oehme Date: Mon, 18 Nov 2019 22:52:25 +0100 Subject: [PATCH] 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. --- .config/i3/config | 6 +++--- .config/picom/picom.conf | 26 ++++++++++++++--------- .local/bin/picom_toggle_inactive_opacity | 27 ++++++++++++++++++++++++ .xinitrc | 2 +- 4 files changed, 47 insertions(+), 14 deletions(-) create mode 100755 .local/bin/picom_toggle_inactive_opacity diff --git a/.config/i3/config b/.config/i3/config index a7a326e..fb695b3 100644 --- a/.config/i3/config +++ b/.config/i3/config @@ -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. diff --git a/.config/picom/picom.conf b/.config/picom/picom.conf index 482ac09..e9146e6 100644 --- a/.config/picom/picom.conf +++ b/.config/picom/picom.conf @@ -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; +}; ################################# # diff --git a/.local/bin/picom_toggle_inactive_opacity b/.local/bin/picom_toggle_inactive_opacity new file mode 100755 index 0000000..e1c656e --- /dev/null +++ b/.local/bin/picom_toggle_inactive_opacity @@ -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 diff --git a/.xinitrc b/.xinitrc index 97be0a4..e9e1c00 100644 --- a/.xinitrc +++ b/.xinitrc @@ -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