Puppy Linux Discussion Forum Forum Index Puppy Linux Discussion Forum
Puppy HOME page : puppylinux.com
"THE" alternative forum : puppylinux.info
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

The time now is Thu 27 Nov 2014, 06:41
All times are UTC - 4
 Forum index » Off-Topic Area » Programming
How to set puppy linux to beep/play sound on window popup ?
Post_new_topic   Reply_to_topic View_previous_topic :: View_next_topic
Page 1 of 1 Posts_count  
Author Message
george2002

Joined: 20 Sep 2010
Posts: 22

PostPosted: Tue 21 Sep 2010, 20:01    Post_subject:  How to set puppy linux to beep/play sound on window popup ?  

Hello there,
i have question - is there and chance to play a sound(mp3/wav etc) or simply system beep when specific window popup ? i need this option because in jdownloader (nice application for downloading from rapidshare etc witch has captcha recognition) when program can't recognize the captcha then he popups window with you can type recognized letters from captch but i wanted to have sound when this window appers - because i don't want to sit all day and watch when it appears, it would be more simply to have sound when this window appear.
Asumming is there and possibility to play sound if you get a popup window in puppy ? (i have installed version 4.1 but if this can help i can install 5.1)

Thx in advance for any solution
george2002
Back to top
View user's profile Send_private_message 
Ian
Official Dog Handler


Joined: 04 May 2005
Posts: 1237
Location: Queensland

PostPosted: Wed 22 Sep 2010, 06:44    Post_subject:  

I would suggest that you look at the JDownloader site and see if there is a Java add-on that would do what you wish.
Back to top
View user's profile Send_private_message 
george2002

Joined: 20 Sep 2010
Posts: 22

PostPosted: Wed 22 Sep 2010, 12:12    Post_subject:  

Ian wrote:
I would suggest that you look at the JDownloader site and see if there is a Java add-on that would do what you wish.

Ian thx for reply Smile
I done that before posting this topic on this friendly forum Smile
I even write suggestion for that type of plugin/option but i get ansfer that this can't be done now because there are more important things than my sugestion Sad
In my opinion there is a way to do this that when window popup then make any sound but as i mentioned i'm beginner in linux Sad
If anyone have any proposition or suggestion or ready solution that could be awesome Smile - for me and for other users who missing this option

PS
Some guy from jdownloader forum suggestrd me i can try that code:
Quote:

The PS command (with the appropriate parameters) allows you to list information about all of the processes (and I think threads). If you grep the output of ps -e (I think) grep will return a different value when it finds an occurrence than when it does not.

It has been years since I did this, so this is probably not right (the parameters changed) You are looking for a script something like:

Code:


while (`ps -e | grep "java.*"') {
    if (`ps -e --windowtitle | grep "*.?\Please Enter"') beep 700 2
    sleep 2
    }


sleep sleeps up to that number of seconds. It is like cron in that it uses the end of a second to update, rather than the passage of time. So `sleep 2` should sleep 1 to 2 seconds.

If the beep parameters are as I remember them, this is a request for a 2 second beep at 700Hz (A above middle C). That is the same frequency as most beeping alarm clocks. Almost nobody can sleep through it. We used to play songs by using beep followed by pairs of numbers.

Note that the conditionals are enclosed in accent characters ` ` so that they will be interpreted each time. This would be more efficient in TEMACS or AWK, but a lot harder to write.

As to regular expressions, they have changed a little over the years. Look at the documentation in the JDownloader Wiki.


but how can i use it ? i must create some file with that code and then run it ?

Thx for any help
george2002
Back to top
View user's profile Send_private_message 
george2002

Joined: 20 Sep 2010
Posts: 22

PostPosted: Fri 01 Oct 2010, 09:49    Post_subject:  

Any suggestions ?

George2002
Back to top
View user's profile Send_private_message 
Flash
Official Dog Handler


Joined: 04 May 2005
Posts: 11164
Location: Arizona USA

PostPosted: Fri 01 Oct 2010, 11:26    Post_subject:  

I don't know how to try out that code, but if I were to attempt it, I'd do it while running Puppy entirely in RAM (boot from a live CD with puppy pfix=ram boot option, or, better yet, from a multisession CD or DVD.) Running entirely in RAM means you can try things out without so much risk of borking your hd installation. Once you get your project to work, then you boot from hd and install it. Smile
Back to top
View user's profile Send_private_message 
george2002

Joined: 20 Sep 2010
Posts: 22

PostPosted: Fri 01 Oct 2010, 13:10    Post_subject:  

Code:
I don't know how to try out that code, but if I were to attempt it, I'd do it while running Puppy entirely in RAM (boot from a live CD with puppy pfix=ram  boot option, or, better yet, from a multisession CD or DVD.) Running entirely in RAM means you can try things out without so much risk of borking your hd installation. Once you get your project to work, then you boot from hd and install it. Smile


Ehhh this ansfer will not help me Smile - i don;t have problems with instalation/speed of instalation but with enabling sound on window popup Smile

George2002
Back to top
View user's profile Send_private_message 
seaside

Joined: 11 Apr 2007
Posts: 887

PostPosted: Sun 03 Oct 2010, 20:05    Post_subject: Job-Alert
Sub_title: Poll for a window name appearance
 

I decided to give this a try and develop a general script which can be used for any reason, including Jdownloader.

So here's Job-Alert, for those occasions where you'd like to have a popup with a repeated warning sound when a selected window appears.

Set the following variables in the script-

WINDOWNAME='<--put title of the window sought here-->'
( Apparently for Jdownloader that would be 'Please' )

SOUNDFILE='<---put the /path/soundfile here-->'
( Default is SOUNDFILE='/usr/share/audio/2barks.wav' )

Some Puppies have "xdotool", which is required, but if you don't, it can be found here in Pastelist http://208.109.22.214/puppy/viewtopic.php?mode=attach&id=26051&sid=e3947003ca6d91203adaa0cabb7e7895.

Start the Job-Alert script before launching any programs that might produce a window name of interest.

Job-Alert will poll every 2 seconds for a window with WINDOWNAME in it. When it finds one, it pops a Job-Alert window and starts a repeating sound every 6 seconds until the user stops it.

One extremely handy use is to run this script when away from home as a deterrent to burglars. Very Happy Very Happy

Cheers,
s



Code:
#!/bin/sh

# Loop polls for window title in WINDOWNAME
# If a window with WINDOWNAME is found, a Job Alert popup
# window occurs and SOUNDFILE is played every 6 seconds until
# the Job Alert window is closed.
# Requires: xdotool

### set WINDOWNAME to title of window and SOUNDFILE to /path/soundfile
     

    WINDOWNAME='<--put title of the window sought here-->'
    SOUNDFILE='/usr/share/audio/2barks.wav'
   
    while : : ; do
    ID=`xdotool search $WINDOWNAME | head -1`
    [ "$ID" != "" ] && break
    sleep 2
    done
       
    while : : ; do
        aplay $SOUNDFILE $SOUNDFILE
        sleep 6
    done &
    SPID=$!
   
Xdialog --title "Job Alert" --wrap \
--yes "Press YES/NO, ENTER or ESC to stop sound and Exit" 10 30

kill $SPID
 
exit   
Back to top
View user's profile Send_private_message 
technosaurus


Joined: 18 May 2008
Posts: 4380

PostPosted: Mon 04 Oct 2010, 13:47    Post_subject:  

I wonder why you chose to have the sound continue until the processed finished instead of just once afterward
__something__ like this using pidof (busybox) instead of xdotool
Code:
PROGRAMS="program1 program2"
PID=NONE

while $PID != "" do
PID=`for x in $PROGRAMS; do pidof $x; done;`
sleep 2
done

minimp3 /usr/share/audio/actioncomplete.mp3 #or use busybox beep
Can't test at the moment, so it may not work.
_________________
Web Programming - Pet Packaging 100 & 101
Back to top
View user's profile Send_private_message 
seaside

Joined: 11 Apr 2007
Posts: 887

PostPosted: Mon 04 Oct 2010, 15:38    Post_subject:  

technosaurus,

Apparently, in the case of jdownloader, there is a window that appears asking for captcha input and since supposedly this happens when the user is away from their PC, a continuing alert is desirable until turned off.

Not sure about looking for PID, since it may not be known in this case.

Regards,
s
Back to top
View user's profile Send_private_message 
george2002

Joined: 20 Sep 2010
Posts: 22

PostPosted: Tue 05 Oct 2010, 18:52    Post_subject:  

Hello there and thanks for all solutions and suggestions Smile but my buddy from work wroted for me this code:
Code:
#    title_window
#    Copyright (C) 2010  Rafal Pogorzelec (mail:http://www.google.com/recaptcha/mailhide/d?k=01we46RSAUuqHSIbxuEMpsSQ==&c=SGoWxLS_x56S5_ScSXPXwCtmTBN5-ln181pkuq2_xpg=)
#
#    This program is free software: you can redistribute it and/or modify
#    it under the terms of the GNU General Public License as published by
#    the Free Software Foundation, either version 3 of the License, or
#    (at your option) any later version.
#
#    This program is distributed in the hope that it will be useful,
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#    GNU General Public License for more details.
#
#    You should have received a copy of the GNU General Public License
#    along with this program.  If not, see <http://www.gnu.org/licenses/>.

import subprocess,re

if __name__ == '__main__':
    xprop = subprocess.Popen(('xprop', '-root', '-spy'),stdout=subprocess.PIPE, stderr=subprocess.PIPE)
    while True:
        line = xprop.stdout.readline()
        if not line:
            break
        if re.match('_NET_ACTIVE_WINDOW', line):
            try:
                id = re.split(' ', line)[4]
                xwininfo = subprocess.Popen(('xwininfo', '-id', id),stdout=subprocess.PIPE, stderr=subprocess.PIPE)
                while True:
                    line = xwininfo.stdout.readline()
                    if not line:
                        break
                    if re.match('xwininfo', line):
                        m = re.compile('".*"').search(line)
                        if m:
                            title = m.group()
                            print title
                            if re.search('', title):                           
                                play = subprocess.Popen(('aplay','sound/sound.wav'),stdout=subprocess.PIPE, stderr=subprocess.PIPE)
                       
            except IndexError:
                pass
             


and i must say it works awesome Smile
Its writed in python language and for working python 2.6 must be installed - pet file of python 2.6 can be found here:http://dotpups.de/puppy4/dotpups/Programming/python-2.6.4-i386.pet
Small description/howto:
In attached file there is 2 catalogs:
license - GPL license
tw - in that catalog there is python script that plays sound when wanted window popups and catalog with sound file (default - sound.wav, i added 2 more sounds from windows Wink )
edit line
Code:
if re.search('', title):
for eg jdownloader
Code:
if re.search('Please enter', title):
- for english language version of course Wink eg for Polish it will be:
Code:
if re.search('Prosz wprowadzi', title):


and one file:
start_tw - it's start file for python script - i added this file to my-documents/Startup (autostart catalog in puppy)


PS
Whole popup catalog must be in root catalog Smile

PS2
Ups i can't attache file Sad it can be found here:http://www.megaupload.com/?d=OQ2WLJX9

PS3
Thx abushcrafter for mail antyspam info Smile

Best Regards
George2002

Edited_time_total
Back to top
View user's profile Send_private_message 
abushcrafter


Joined: 30 Oct 2009
Posts: 1447
Location: England

PostPosted: Wed 06 Oct 2010, 07:10    Post_subject:  

@george2002 Thanks to you you buddy now has spam. Replace the email with this URL "http://www.google.com/recaptcha/mailhide/d?k=01we46RSAUuqHSIbxuEMpsSQ==&c=SGoWxLS_x56S5_ScSXPXwCtmTBN5-ln181pkuq2_xpg=" to protect it. reCAPTCHA: Stop Spam, Read Books
_________________
adobe flash is rubbish!
My Quote:"Humans are stupid, though some are clever but stupid." http://www.dependent.de/media/audio/mp3/System_Syn_Heres_to_You.zip http://www.systemsyn.com/
Back to top
View user's profile Send_private_message Visit_website 
george2002

Joined: 20 Sep 2010
Posts: 22

PostPosted: Thu 07 Oct 2010, 16:34    Post_subject:  

Hello there again Smile
I uploaded here:http://www.megaupload.com/?d=500C3JBQ new version of script.
My buddy added very cool feature:
Now sound is played in loop with additional delay between played sound as long as window appears, if window disappears then sound stops playing and waiting for next appear of window


Best Regards
George2002
Back to top
View user's profile Send_private_message 
Display_posts:   Sort by:   
Page 1 of 1 Posts_count  
Post_new_topic   Reply_to_topic View_previous_topic :: View_next_topic
 Forum index » Off-Topic Area » Programming
Jump to:  

Rules_post_cannot
Rules_reply_cannot
Rules_edit_cannot
Rules_delete_cannot
Rules_vote_cannot
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group
[ Time: 0.0993s ][ Queries: 11 (0.0070s) ][ GZIP on ]