forked from andreyorst/kde_wallpaper_blur
-
Notifications
You must be signed in to change notification settings - Fork 0
/
wpblur.sh
executable file
·41 lines (35 loc) · 1.82 KB
/
wpblur.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#!/bin/bash
function blur {
echo "Blurring the background"
sleep 2
curActivityId=$(qdbus org.kde.ActivityManager /ActivityManager/Activities CurrentActivity)
while read containmentId; do
lastDesktop=$(kreadconfig5 --file ~/.config/plasma-org.kde.plasma.desktop-appletsrc --group Containments --group $containmentId --key lastScreen)
activityId=$(kreadconfig5 --file ~/.config/plasma-org.kde.plasma.desktop-appletsrc --group Containments --group $containmentId --key activityId)
if [[ $lastDesktop == "0" ]] && [[ $activityId == $curActivityId ]] ; then
CURRENT_WP_PATH=$(kreadconfig5 --file ~/.config/plasma-org.kde.plasma.desktop-appletsrc --group Containments --group $containmentId --group Wallpaper --group org.kde.image --group General --key Image | sed -E 's/(file:\/\/)?//')
fi
done <<< "$(grep -e '\[Containments]\[[0-9]*]\[Wallpaper]\[org.kde.image]\[General]' ~/.config/plasma-org.kde.plasma.desktop-appletsrc | sed 's/\[Containments\]\[//;s/]\[Wallpaper]\[org.kde.image]\[General]//')"
convert "$CURRENT_WP_PATH" -filter Gaussian -resize 5% -define filter:sigma=2.5 -resize 2000% -attenuate 0.2 +noise Gaussian ~/.bg.png
echo "Background blurring finished"
}
if [ $(pidof -x wpblur.sh| wc -w) -gt 2 ]; then
echo wpblur already running, exiting
exit 1
fi
while true; do
inotifywait -q ~/.config/plasma-org.kde.plasma.desktop-appletsrc -e delete_self | while read; do
echo "~/.config/plasma-org.kde.plasma.desktop-appletsrc modified"
blur
done
done &
interface=org.kde.ActivityManager.Activities
member=CurrentActivityChanged
dbus-monitor --profile "interface='$interface',member='$member'" |
while read -r line; do
if [[ $line = *"CurrentActivityChanged"* ]]; then
echo "Activity changed"
blur
fi
done &
sleep infinity