Can someone see what is wrong with it, and maybe explain why?
Bonus question: Bash is the weirdest scripting language I have ever seen. Spaces are important in if statements(!?), and sometimes you need to use parenthesis and sometimes a single bracket and other times double brackets!?!? And what with the semicolon in the if-statement? Who invented that syntax? And the fi keyword!? How about using curly brackets or, since I have coded Visual Basic, I'll even accept end if!? Explain that to me and you'll get a gold star!
It took me hours to get this script to work because of the weird syntax and the white space sensitive syntax, and I have been programming for roughly 30 years now in a bunch of different languages and I have seen some weird sh*t. I haven't been this confused since I coded LISP in the early 90:s.
Just as I was about to press the submit button, I realized that I upgraded to LM 19.1 earlier today. Has something changed because of that? I can see in dconf editor that it changes the picture-uri but the background is not changing.
Code: Select all
#!/bin/bash
# get the current slideshow folder
DESK_BACKGROUND=$(gsettings get org.cinnamon.desktop.background.slideshow image-source)
if [[ $DESK_BACKGROUND == *second* ]]; then
#if its the second folder, change to the first folder, and switch to a random picture
RANDOM_PICTURE=$(ls /home/per/Pictures/backgrounds | shuf -n 1)
gsettings set org.cinnamon.desktop.background.slideshow image-source "directory:///home/per/Pictures/backgrounds"
gsettings set org.cinnamon.desktop.background picture-uri $RANDOM_PICTURE
else
#if its the first folder, change to the second folder, and switch to a random picture
RANDOM_PICTURE=$(ls /home/per/Pictures/backgrounds_second | shuf -n 1)
gsettings set org.cinnamon.desktop.background.slideshow image-source "directory:///home/per/Pictures/backgrounds_second"
gsettings set org.cinnamon.desktop.background picture-uri $RANDOM_PICTURE
fi
# set random, enable slideshow and set delay to 10 minutes
gsettings set org.cinnamon.desktop.background.slideshow random-order true
gsettings set org.cinnamon.desktop.background.slideshow slideshow-enabled true
gsettings set org.cinnamon.desktop.background.slideshow delay 10