Skip to content

Commit

Permalink
Decrease run time by simulating the blur effect. (#3)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
lu0 committed May 15, 2022
1 parent cc6fe3d commit 865794a
Showing 1 changed file with 15 additions and 6 deletions.
21 changes: 15 additions & 6 deletions powermenu.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 865794a

Please sign in to comment.