bump
bump
realzippy, does this command activate your screensaver?
If it does, that might be a start toward a solution:
Code:qdbus org.gnome.ScreenSaver / SetActive True
Wonderful. Now here's (maybe) the tricky part: What does this return
Also, after the screensaver is activated, you want any keypress to have the same effect as pressing Shift+F9, correct? What does pressing Shift+F9 do?Code:sleep 5; qdbus org.gnome.ScreenSaver / GetSessionIdleTime
This is a show-stopper... at least until we find a way to coax the computer into telling us how long the X session has been idle...it returns: 0
PS. When you run
does the rain plugin start, or is your screen saver something else?Code:qdbus org.gnome.ScreenSaver / SetActive True
realzippy, Since compiz seems to crash my machine, I haven't been able to test this completely.
- First install the build-essential, libxss-dev and xdotool packages.
- Then go to http://ubuntuforums.org/showpost.php...64&postcount=2
and copy stroyan's C program to xidle.c
Compile the program:
This will create the executable "xidle".Code:cc xidle.c -o xidle -lX11 -lXext -lXss- Move the executable xidle to ~/bin, so the program will be in your PATH.
- Check that it works by running
You should get a number likeCode:sleep 5; xidle
in response.Code:4.962000- Now save this in ~/bin/idlerain.py
PHP Code:
#!/usr/bin/env python
from subprocess import Popen,PIPE,STDOUT,call
import os
import time
def get_idle_time():
proc=Popen('xidle', shell=True, stdout=PIPE, )
return float(proc.communicate()[0])
is_raining=False
sleep_seconds=1
max_idle=20
last_idle=0
rain_start_time=time.time()
while True:
idle=get_idle_time()
if is_raining:
duration=time.time()-rain_start_time
if(is_raining and duration>1.5*sleep_seconds and
idle<last_idle):
is_raining=False
os.system('xdotool key shift+F9')
else:
if (last_idle<max_idle and max_idle<=idle):
is_raining=True
rain_start_time=time.time()
os.system('xdotool key shift+F9')
last_idle=idle
time.sleep(sleep_seconds)
- Make it executable:
Code:chmod +x ~/bin/idlerain.py- For now, try running it from the terminal. If it works to your liking, it can be set to run automatically when you log in.
Run it by typing:
Wait for 20 seconds. Then the rain should start. Press a key, and the rain should end.Code:idlerain.py
Press Ctrl-C to stop the idlerain.py program.
Last edited by unutbu; September 1st, 2009 at 02:45 PM.
Move the executable xidle to ~/bin, so the program will be in your PATH
Sorry for stupid question:
Is it really ~/bin,not /bin?
(do not have /bin folder in home directory.Should i create it?...if I move xidle to /bin instead of ~/bin,then sleep 5; xidle gives me a number like 4.962000,
otherwise "command not found"...????)
Last edited by realzippy; August 30th, 2009 at 02:18 PM.
No problem, realzippy.
~/bin is the same as /home/realzippy/bin (if your username is realzippy).
/bin is the system's /bin directory. (I don't recommend putting it in there.)
If you don't have a ~/bin directory, make one. Ubuntu is setup for you so that if you have a ~/bin directory, all executables are automatically "in your PATH". That means you can run them by name:
instead of by full path:Code:xidle
It saves some typing.Code:/home/realzippy/bin/xidle
PS. If you make a ~/bin directory, close your gnome-terminal and re-open it so your PATH will be updated.
Last edited by unutbu; August 30th, 2009 at 02:11 PM.
Bookmarks