dotfiles/.local/bin/weather_background

34 lines
1.5 KiB
Bash
Executable File

#!/usr/bin/env bash
# based on: https://bbs.archlinux.org/viewtopic.php?id=215899
# and: https://git.reviewboard.kde.org/r/125648/
# and: https://github.com/chubin/wttr.in
WALLPATH=/home/ericonr/Pictures/Wallpaper
# download png
curl wttr.in/Campinas_tqp0.png --output $WALLPATH/weather.png --silent
convert $WALLPATH/weather.png -resize 130% $WALLPATH/weather.png
echo DOWNLOADED
# create the background image
convert $WALLPATH/wallpaper_default.jpg $WALLPATH/weather.png -geometry '+50+50' -composite $WALLPATH/wallpaper_weather.jpg
# run script that changes the wallpaper - convoluted mess
qdbus org.kde.plasmashell /PlasmaShell org.kde.PlasmaShell.evaluateScript \
'var allDesktops = desktops();
print (allDesktops);
wallpath = "file:///home/ericonr/Pictures/Wallpaper/";
// allDesktops.lentgh not used, changing only the main background
for (i=0; i < 1; i++) {
d = allDesktops[i];
d.wallpaperPlugin = "org.kde.image";
d.currentConfigGroup = Array("Wallpaper", "org.kde.image", "General");
d.writeConfig("Image", wallpath + "wallpaper_default.jpg")
d.writeConfig("Image", wallpath + "wallpaper_weather.jpg")
}'
echo CHANGED_BACKGROUND