From 3770929742496f61a8d488e581a8f7253ffb4e8b Mon Sep 17 00:00:00 2001 From: Vincent Bernat Date: Tue, 2 Nov 2021 10:12:56 +0100 Subject: [PATCH] picom: use a wrapper script to template picom configuration file --- bin/picom-configure | 13 +++++++++++++ dotfiles/picom.conf | 4 ++-- dotfiles/systemd/picom.service | 4 +++- dotfiles/systemd/xsettingsd.service | 3 ++- dotfiles/xsession | 1 - 5 files changed, 20 insertions(+), 5 deletions(-) create mode 100755 bin/picom-configure diff --git a/bin/picom-configure b/bin/picom-configure new file mode 100755 index 0000000..a7fb270 --- /dev/null +++ b/bin/picom-configure @@ -0,0 +1,13 @@ +#!/bin/sh -e + +DPI=$(xrdb -query | sed -nE 's/^Xft\.dpi:\s*//p') +POLYBAR_HEIGHT=$((20 * DPI / 96)) + +# Configure picom +cat ~/.config/i3/dotfiles/picom.conf \ + | sed -e "s/@POLYBAR_HEIGHT@/$POLYBAR_HEIGHT/" \ + > $XDG_RUNTIME_DIR/i3/picom.conf.new + +# Put new configuration file in place +cmp $XDG_RUNTIME_DIR/i3/picom.conf.new $XDG_RUNTIME_DIR/i3/picom.conf 2> /dev/null || \ + mv $XDG_RUNTIME_DIR/i3/picom.conf.new $XDG_RUNTIME_DIR/i3/picom.conf diff --git a/dotfiles/picom.conf b/dotfiles/picom.conf index 3752515..777da41 100644 --- a/dotfiles/picom.conf +++ b/dotfiles/picom.conf @@ -37,11 +37,11 @@ opacity-rule = [ # Shadow and fading fade-in-step = 0.08; fade-out-step = 0.08; -shadow-opacity = 0.3; +shadow-opacity = 0.5; shadow-radius = 10; shadow-offset-x = -3; shadow-offset-y = -3; -xinerama-shadow-crop = false; +shadow-exclude-reg = "x@POLYBAR_HEIGHT@+0+0" wintypes: { normal = { shadow = true; }; diff --git a/dotfiles/systemd/picom.service b/dotfiles/systemd/picom.service index 853fa86..29babdd 100644 --- a/dotfiles/systemd/picom.service +++ b/dotfiles/systemd/picom.service @@ -3,5 +3,7 @@ Description=Compositor for X11 PartOf=graphical-session.target [Service] -ExecStart=/usr/bin/picom +ExecStartPre=%h/.config/i3/bin/picom-configure +ExecStart=/usr/bin/picom --config ${XDG_RUNTIME_DIR}/i3/picom.conf +ExecReload=%h/.config/i3/bin/picom-configure Restart=on-failure diff --git a/dotfiles/systemd/xsettingsd.service b/dotfiles/systemd/xsettingsd.service index 57283e9..9f7fe2e 100644 --- a/dotfiles/systemd/xsettingsd.service +++ b/dotfiles/systemd/xsettingsd.service @@ -10,5 +10,6 @@ ExecReload=%h/.config/i3/bin/xsettingsd-setup ExecReload=/usr/bin/kill -HUP $MAINPID # Restart i3 (it uses Xft.dpi) ExecReload=-/usr/bin/i3-msg restart -# Restart polybar (it uses an environment variable) +# Restart polybar and reload picom (they use an environment variable) ExecReload=/bin/systemctl --user try-restart polybar.service +ExecReload=/bin/systemctl --user try-reload picom.service diff --git a/dotfiles/xsession b/dotfiles/xsession index 29c9d7e..77c8141 100755 --- a/dotfiles/xsession +++ b/dotfiles/xsession @@ -31,7 +31,6 @@ gtk3.css .config/gtk-3.0/gtk.css qt5ct.conf .config/qt5ct/qt5ct.conf systemd .config/systemd/user dunstrc .config/dunst/dunstrc -picom.conf .config/picom.conf polybar.conf .config/polybar/config rofi.conf .config/rofi/config.rasi fonts.conf .config/fontconfig/fonts.conf