forked from andreyorst/kde_wallpaper_blur
-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.sh
executable file
·128 lines (103 loc) · 4.01 KB
/
setup.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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
#!/bin/bash
# I AM BASH NOOB PLS DONT PUNCH ME HARD
BIN_PATH="/usr/bin"
if ! test -f "$BIN_PATH/inotifywait" ; then
echo inotify-tools not found on your system, please install inotify-tools package.
exit
fi
if ! test -f "$BIN_PATH/convert" ; then
echo convert not found on your system, please install imagemagick package.
exit
fi
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]//')"
if ! test -f ~/.bg.png; then
if [ "$CURRENT_WP_PATH" ]; then
echo blurring your current wallpaper
echo
convert "$CURRENT_WP_PATH" -filter Gaussian -resize 5% -define filter:sigma=2.5 -resize 2000% -attenuate 0.2 +noise Gaussian ~/.bg.png
sleep 10
else
PROMPT=1
echo creating dummy .bg.png in $HOME
echo
touch ~/.bg.png
fi
fi
SDDM_THEME_PATH=/usr/share/sddm/themes
SDDM_THEME=$(cat /etc/sddm.conf | grep 'Current' | sed -E 's/.*=//')
if ! [ $SDDM_THEME ]; then
echo No theme found in /etc/sddm.conf
echo You can find all theme names by executing $ ls $SDDM_THEME_PATH
while true; do
echo -n Please specify your theme name: ; read SDDM_THEME
if ! test -d $SDDM_THEME_PATH/$SDDM_THEME; then
echo No theme named $SDDM_THEME found at $SDDM_THEME_PATH/
else
break
fi
done
fi
SDDM_THEME_PATH=$SDDM_THEME_PATH/$SDDM_THEME
if ! test -f $SDDM_THEME_PATH/.bg.png; then
echo creating symlink to .bg.png in $SDDM_THEME_PATH
echo
sudo ln -sf ~/.bg.png $SDDM_THEME_PATH/.bg.png
fi
sudo chmod 777 ~/.bg.png
setfacl -m u:sddm:x ~
echo creating sddm config
if [ ! -f $SDDM_THEME_PATH/theme.conf.user ]; then
sudo cp theme.conf theme.conf.user
fi
cat $SDDM_THEME_PATH/theme.conf.user | sed -E 's/background=.*/background=.bg.png/' | sed -E 's/type=.*/type=image/' >> /tmp/theme.conf.user
sudo mv $SDDM_THEME_PATH/theme.conf.user $SDDM_THEME_PATH/theme.conf.user.prewpblur
sudo mv /tmp/theme.conf.user $SDDM_THEME_PATH/
echo generating kscreenlockerrc file
echo
KSCREENLOCKER=~/.config/kscreenlockerrc
if test -f ~/.config/kscreenlockerrc; then
mv $KSCREENLOCKER $KSCREENLOCKER.prewpblur
echo "[$Version]" > $KSCREENLOCKER
echo $(grep "update_info" $KSCREENLOCKER.prewpblur) >> $KSCREENLOCKER
else
echo "[$Version]" > $KSCREENLOCKER
echo "update_info=kscreenlocker.upd:0.1-autolock" >> $KSCREENLOCKER
fi
cat <<EOF >> $KSCREENLOCKER
[Greeter]
WallpaperPlugin=org.kde.image
[Greeter][Wallpaper][org.kde.image][General]
FillMode=2
Image=file:///home/$USER/.bg.png
EOF
if ! test -d ~/.config/autostart-scripts; then
mkdir ~/.config/autostart-scripts
fi
if test -f ~/.config/autostart-scripts/wpblur.sh; then
rm ~/.config/autostart-scripts/wpblur.sh
fi
echo enabling script autostart
echo
ln -sf $(pwd)/wpblur.sh ~/.config/autostart-scripts/wpblur.sh
echo script will start automatically upon next login
cat <<EOF
Backups created:
$SDDM_THEME_PATH/theme.conf.user.prewpblur
$KSCREENLOCKER.prewpblur
EOF
if ! pgrep -x "wpblur.sh" > /dev/null; then
echo starting script for current session
$(pwd)/wpblur.sh &
fi
if [ $PROMPT ]; then
echo now please change your wallpaper
else
echo ready to use
fi