Page 3 of 4 FirstFirst 1234 LastLast
Results 21 to 30 of 34

Thread: Who can drop few lines of code?Send you beer!

  1. #21
    Join Date
    Jan 2007
    Beans
    Hidden!
    Distro
    Kubuntu 11.04 Natty Narwhal

    Re: Who can drop few lines of code?Send you beer!

    Ok,got that.
    Rain does start (after 5 seconds),but it does not stop by keybord input
    or mouse movement.When I stop script with ctrl+c,I got this:

    kerzin@holzhaus:~$ idlerain.py
    ^CTraceback (most recent call last):
    File "/home/kerzin/bin/idlerain.py", line 18, in <module>
    time.sleep(sleep_seconds)
    KeyboardInterrupt
    kerzin@holzhaus:~$

    ..and it still rains...

    Edit: idlerain.py :

    #!/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])

    sleep_seconds=1
    max_idle=5
    last_idle=0
    while True:
    idle=get_idle_time()
    if (last_idle<max_idle and max_idle<idle) or (idle<last_idle):
    os.system('xdotool key shift+F9')
    last_idle=idle
    time.sleep(sleep_seconds)
    Last edited by realzippy; August 30th, 2009 at 03:10 PM.

  2. #22
    Join Date
    Mar 2008
    Beans
    4,715
    Distro
    Ubuntu 9.10 Karmic Koala

    Re: Who can drop few lines of code?Send you beer!

    Hm. Put this in ~/bin/test.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=Truestdout=PIPE, )
        return 
    float(proc.communicate()[0])

    sleep_seconds=1    
    max_idle
    =5
    last_idle
    =0
    while True:
        
    idle=get_idle_time()
        print(
    idle)
        if ((
    last_idle<max_idle and max_idle<=idle) or
            (
    idle<max_idle and max_idle<=last_idle)):
            print(
    'Shift+F9')
        
    last_idle=idle
        time
    .sleep(sleep_seconds
    Make it executable:

    Code:
    chmod +x ~/bin/test.py
    And the run it:

    Code:
    test.py
    Wait for >5 seconds, then move the mouse.

    Do you see output like this:

    Code:
    % test.py
    0.047
    1.002
    2.006
    3.01
    4.013
    5.014
    Shift+F9              <----   First Shift+F9 happens after 5 seconds
    6.018
    7.022
    0.682
    Shift+F9              <----   Mouse movement causes a Shift+F9
    1.686
    2.69
    ^CTraceback (most recent call last):
      File "/home/cyrano/pybin/idlerain.py", line 21, in <module>
        time.sleep(sleep_seconds)
    KeyboardInterrupt
    Note this program does not issue any real Shift+F9, it's just to see if the
    mechanics of the program are working.
    Last edited by unutbu; August 30th, 2009 at 03:14 PM.

  3. #23
    Join Date
    Jan 2007
    Beans
    Hidden!
    Distro
    Kubuntu 11.04 Natty Narwhal

    Re: Who can drop few lines of code?Send you beer!

    kerzin@holzhaus:~$ test.py
    0.026
    0.991
    1.996
    3.002
    4.008
    5.013
    Shift+F9
    6.018
    7.024
    8.029
    0.002
    Shift+F9
    0.64
    1.645
    2.65
    3.655
    4.66
    5.666
    Shift+F9
    6.671
    0.005
    Shift+F9
    0.738
    1.744
    ^CTraceback (most recent call last):
    File "/home/kerzin/bin/test.py", line 20, in <module>
    time.sleep(sleep_seconds)
    KeyboardInterrupt
    kerzin@holzhaus:~$


    Hm,that seems to work.Update: idlerain.py now stops by ctrl+c,no more rain...,but still not reacts on mouse/keyboard..

    I set the max_idle in idlerain.py to 20 (when compiz rainplugin is stopped by "manual" shift+F9,rain does not stop immediatly,it takes a few seconds til all drops are gone),and so I noticed that a really short mouse movement indeed stops the rain,moving the mouse a bit more,rain starts immediatly;like shift+F9 is "hit" twice by idlerain ...

    Also just noticed (with max_idle in idlerain.py to 20),that the script does start the rain,but also stops it...after 20 seconds it starts again and stops,and so on...
    Edit: that seems not to be reproducible;sometimes it stops,sometimes not...


    Did not think that it's so hard to do...my girlfriend likes the rainplugin and suggested it would be a nice screensaver for her desktop...thought it was easy because of the existing compiz screensaver (rotating cube,e.g.)....just thought to change a few lines in compiz screensaver plugin from "rotate cube" to "rain"...might be pretty naive..
    Last edited by realzippy; August 30th, 2009 at 04:12 PM. Reason: further tests

  4. #24
    Join Date
    Mar 2008
    Beans
    4,715
    Distro
    Ubuntu 9.10 Karmic Koala

    Re: Who can drop few lines of code?Send you beer!

    I fixed an error in the original idlerain.py. Try copying it again:
    http://ubuntuforums.org/showpost.php...4&postcount=18

    Does that work?

  5. #25
    Join Date
    Jan 2007
    Beans
    Hidden!
    Distro
    Kubuntu 11.04 Natty Narwhal

    Re: Who can drop few lines of code?Send you beer!

    No.
    after 20 seconds rain starts and stops after 1 second...after 20 seconds it starts,stops..
    and so on....
    Last edited by realzippy; August 31st, 2009 at 09:40 AM.

  6. #26
    Join Date
    Mar 2008
    Beans
    4,715
    Distro
    Ubuntu 9.10 Karmic Koala

    Re: Who can drop few lines of code?Send you beer!

    Did not think that it's so hard to do...my girlfriend likes the rainplugin and suggested it would be a nice screensaver for her desktop...thought it was easy because of the existing compiz screensaver (rotating cube,e.g.)....just thought to change a few lines in compiz screensaver plugin from "rotate cube" to "rain"...might be pretty naive..
    realzippy, I think your intuition is right.
    I don't have compiz working on my machine, so I'm clueless about how it is configured.
    Moreover, running a program (xidle) every second to check if the machine is idle does give me the feeling that this is ugly hackery. Perhaps I'm not the right chipmunk for the job!

    Have you asked in the Absolute Beginner or General forum if there is a way to configure compiz to run the rain plug as screensaver? Or perhaps on the compiz forum? (http://forum.compiz.org/)
    Last edited by unutbu; August 30th, 2009 at 07:05 PM.

  7. #27
    Join Date
    Jan 2007
    Beans
    Hidden!
    Distro
    Kubuntu 11.04 Natty Narwhal

    Re: Who can drop few lines of code?Send you beer!

    Yes,I asked for it in Desktop Environments(no reply,http://ubuntuforums.org/showthread.php?t=1243554),so I thought Programming Talk would be right.
    I searched the compiz forum (very first);somebody had asked for it,but did also get no reply...

    "Moreover, running a program (xidle) every second to check if the machine is idle does give me the feeling that this is ugly hackery"

    ...do the default gnome screensavers check idle by another way?

    Would not mind that ugly hackery,so my girlfriends quadCPU would have something to do at last...
    Anyway it is no real essential problem not to have a rain screensaver,so I
    feel kind of guilty for the time you spent.So,what about some beer?

  8. #28
    Join Date
    Mar 2008
    Beans
    4,715
    Distro
    Ubuntu 9.10 Karmic Koala

    Re: Who can drop few lines of code?Send you beer!

    realzippy, yours has been a fun problem to work on. I'm puzzled why the program is misbehaving as it is. I'll think about it and post if I have any ideas.
    So,what about some beer?
    Thanks for the offer. How about a virtual one for a virtual solution?

  9. #29
    Join Date
    Mar 2008
    Beans
    4,715
    Distro
    Ubuntu 9.10 Karmic Koala

    Re: Who can drop few lines of code?Send you beer!

    I've modified idlerain.py so that it spits out some debugging information: http://ubuntuforums.org/showpost.php...4&postcount=18

    Would you please run the program for about a minute and
    mark in the output when the rain plugin starts and stops?

  10. #30
    Join Date
    Jan 2007
    Beans
    Hidden!
    Distro
    Kubuntu 11.04 Natty Narwhal

    Re: Who can drop few lines of code?Send you beer!

    First this one....

    kerzin@holzhaus:~$ idlerain.py
    0.027
    0.961
    1.966
    2.971
    3.976
    4.982
    5.987
    6.992
    7.997
    9.003
    10.008
    11.013
    12.018
    13.024
    14.029
    15.034
    16.039
    17.045
    18.049999
    19.055
    20.059999
    Shift+F9 Rain starts
    1.006
    Shift+F9 Rain stops
    1.006
    2.012
    3.017
    4.022
    5.027
    6.032
    7.037
    8.042
    9.048
    10.053
    11.058
    12.063
    13.068
    14.073
    15.079
    16.084
    17.089001
    18.094
    19.1
    20.105
    Shift+F9 Rain starts
    1.006
    Shift+F9 Rain stops
    1.008
    2.013
    3.018
    4.023
    5.029
    6.034
    7.039
    8.045
    9.05
    10.055
    11.06
    12.066
    13.071
    14.076
    15.081
    16.086
    17.091999
    18.097
    19.101999
    20.108
    Shift+F9 Rain starts
    1.006
    Shift+F9 Rain stops
    1.007
    2.013
    3.02
    ^CTraceback (most recent call last):
    File "/home/kerzin/bin/idlerain.py", line 21, in <module>
    time.sleep(sleep_seconds)
    KeyboardInterrupt
    ----------------------------------------------

    sleep_seconds=1 causes shift+F9 after rain starts?This is sleep_seconds=5 :

    kerzin@holzhaus:~$ idlerain.py
    0.024
    4.969
    9.979
    14.988
    19.997
    25.006001 25 seconds?? (max_idle=20;sleep_seconds=5)???
    Shift+F9 Rain starts
    5.008
    Shift+F9 Rain stops
    0.005
    0.117
    ^CTraceback (most recent call last):
    File "/home/kerzin/bin/idlerain.py", line 21, in <module>
    time.sleep(sleep_seconds)
    KeyboardInterrupt
    Last edited by realzippy; August 31st, 2009 at 09:39 AM.

Page 3 of 4 FirstFirst 1234 LastLast

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •