These are two little scripts, assemble unprofessionally by myself, gleaning pieces of code, here and there. I honestly would prefer that those codes were rewritten, but they are working well.
I mostly want to demonstrate that it can be done easily with KDE4. Any improvement would be most welcome. Thank You.
I use OpenSUSE 13.2 AMD 64, KDE v 4.14.8, compiz-emerald.
That said, you will need **xdotool **to make this work, as it is:
zypper install xdotool
First, the start rain script: “rain”:
#!/bin/bash
while -f ~/bin/.lock ]; do
sleep 0
done
xdotool set_desktop 0 key shift+F9
touch ~/bin/.lock
sleep infinity
exit
Second, the stop rain script: “stoprain”:
#!/bin/bash
xdotool set_desktop 0 key shift+F9 && killall rain && rm ~/bin/.lock
Those scripts should be in the “/home/USER/bin” directory and must be executable:
cd ~/bin
chmod +x rain stoprain
To activate the “rain” script use KDE4’s Power Management settings:
KDE Menu/ Applications/ Configure Desktop/ Power Management/ Energy Saving:
Check the “Run Script” box, select run script “after” from the drop down and show the path to the start rain file (“rain”):
/home/**USER**/bin/rain
Next, link the “stoprain” script to a keyboard shortcut:
Right-click the KDE menu button, select “Edit applications…”.
The top entry is “Applications” click “New Item” and name it, in “General” tab fill up the “Command” line like so:
sh /home/**USER**/bin/stoprain
In the “Advance” tab select the “Current shortcut key”. Your choice, F4 worked for me.
That’s all for the installation.
Important:
When you re-log in, do not turn off the effect with the normal key binding( <Shift>F9),
use instead the F4 shortcut or the one you picked, otherwise the .lock file( see explanations bellow), still present,
will prevent the “rain” script from working again. If the effect is running when the scrip starts, everything will be reverse.
In that case too use “rm ~/bin/.lock”. Rebooting or logging out, won’t remove the file.
Also, when you test this script, set the “run script after” at a minimum of 2 minutes and
your “screen locker( saver)” at least 1 minute more( 3 mins).
So the rain will start at 2 mins, screen saver at 5 mins.
For normal use, for example:
run script= 10 mins, screen locker( saver)= 11 mins, screen energy saving( Power down)= 20 mins.
This setup will get the rain to start at **10 **mins, screen locker( saver) at **21 **mins, screen energy saving at **30 **mins from the fist last input( keyboard or mice).
Because the real last input is when the script starts automaticaly, it equals two keyboard stokes and the coutdown restart.
Explanations:
In compiz-emerald, there are not two commands, like one to start and one to stop, the default binding “Toggle rain” ( <Shift>F9), both start and stop the effect,
in KDE’s power management, “Run Script after X minutes”, do not run only once, it’s repeated at the set interval, as long as the desktop is inactive.
If it wasn’t for the “rain” script .lock file,
the effect would be turn on and off, each time the “Run Script” delay is reached, plus, the screen would wake up. The “stoprain” script turn the effect off,
kill the proccess, before removing the .lock file for the next automatic utilization
of the “rain” script.
Tested on OpenSuse 13.2.
Enjoy!