picom: just set a small corner-radius

This commit is contained in:
Vincent Bernat 2024-09-11 08:26:53 +02:00
parent ad25a8d915
commit 48abe47cfb
3 changed files with 3 additions and 44 deletions

View file

@ -5,6 +5,7 @@ dpi=$(xrdb -query | sed -nE 's/^Xft\.dpi:\s*//p')
POLYBAR_HEIGHT=$((20 * dpi / 96))
SHADOW_RADIUS=$((12 * dpi / 96))
SHADOW_OFFSET=$((SHADOW_RADIUS*2/3))
CORNER_RADIUS=$((4 * dpi / 96))
# Configure picom
mkdir -p $XDG_RUNTIME_DIR/i3
@ -12,6 +13,7 @@ cat ~/.config/i3/dotfiles/picom.conf \
| sed -e "s/@POLYBAR_HEIGHT@/$POLYBAR_HEIGHT/" \
| sed -e "s/@SHADOW_RADIUS@/$SHADOW_RADIUS/" \
| sed -e "s/@SHADOW_OFFSET@/$SHADOW_OFFSET/" \
| sed -e "s/@CORNER_RADIUS@/$CORNER_RADIUS/" \
> $XDG_RUNTIME_DIR/i3/picom.conf.new
# Put new configuration file in place

View file

@ -68,5 +68,4 @@ shadow-exclude = [
];
fade-exclude = [ ];
corner-radius = @SHADOW_RADIUS@
window-shader-fg = "rounded-borders.glsl"
corner-radius = @CORNER_RADIUS@

View file

@ -1,42 +0,0 @@
#version 330
in vec2 texcoord;
uniform sampler2D tex;
uniform float corner_radius;
vec4 default_post_processing(vec4 c);
vec4 add_rounded_corners(
vec4 win_color,
vec2 tex_coord,
vec2 tex_size,
float radius,
float thickness)
{
// If we're far from corners, we just pass window texels through
vec2 corner_distance = min(abs(tex_coord), abs(tex_size - 1 - tex_coord));
if (any(greaterThan(corner_distance, vec2(radius))))
return win_color;
// Distance from the closest arc center
vec2 center_distance = min(
abs(vec2(radius) - tex_coord),
abs(vec2(tex_size - radius) - tex_coord));
// Do some simple anti-aliasing
float inner_radius = radius - thickness;
float feather = 1 / inner_radius;
float r = length(center_distance) / inner_radius;
float blend = smoothstep(1, 1 + feather, r);
vec4 border_color = texture2D(tex, vec2(0), 0);
return blend * border_color + (1.0 - blend) * win_color;
}
vec4 window_shader()
{
vec2 tex_size = textureSize(tex, 0);
vec4 c = texture2D(tex, texcoord / tex_size, 0);
vec4 with_corners = add_rounded_corners(c, texcoord, tex_size, corner_radius, 6);
return default_post_processing(with_corners);
}