From 865794a4af9164df1030b2407448f7c9ed19014c Mon Sep 17 00:00:00 2001 From: Lucero Alvarado Ruiz Date: Sun, 15 May 2022 15:06:22 -0500 Subject: [PATCH] Decrease run time by simulating the blur effect. (#3) Applying a default blur effect was painfully slow, the runtime was decreased up to 70% (65% average) by scaling down the image and then scaling it up to fill the screen, thus simulating a blur effect. --- powermenu.sh | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/powermenu.sh b/powermenu.sh index 8f4cd81..ffc3f3c 100755 --- a/powermenu.sh +++ b/powermenu.sh @@ -27,12 +27,21 @@ y="${DISPLAY_INFO[y]}" width=${DISPLAY_INFO["width"]} height="${DISPLAY_INFO[height]}" -# Fake blurred background -SS_PATH="$HOME/.config/rofi/screenshot" -rm -f "${SS_PATH}.jpg" -scrot -a $x,$y,$width,$height "${SS_PATH}.jpg" # screenshot -convert "${SS_PATH}.jpg" -blur 0x10 -auto-level "${SS_PATH}.jpg" # blur -convert "${SS_PATH}.jpg" "${SS_PATH}.png" # rofi reads png images +# Prepare screenshot path +config_dir=${HOME}/.config/rofi +mkdir -p "${config_dir}" +SS_PATH=${config_dir}/screenshot +rm -f "${SS_PATH}.jpg" && rm -f "${SS_PATH}.png" + +# Take screenshot +scrot -a $x,$y,$width,$height "${SS_PATH}.jpg" + +# Simulate blur effect +convert "${SS_PATH}.jpg" -scale 2.5% -resize 4000% "${SS_PATH}.jpg" + +# Rofi reads png images. +# I found faster to first "blur" the image and then convert it to png +convert "${SS_PATH}.jpg" "${SS_PATH}.png" # Compute font size based on display dimensions DEFAULT_WIDTH=1920