Guest BloodyMary Report post Posted September 26, 2007 Hello there, When I was harvesting, I did someting else with my PC. When I returned to EL I got 10 peaces of the thing I was harvesting, because I was stung by a bee or sth. Because of this I have written a small script, wich plays a soundfile when I stop harvesting. It controls the "chat_log.txt" and when the string "You stopped harvesting" appears, it plays a Soundfile. THERE IS NO AUTOMATION! I asked molime, an he says it would be legal. Here is the script: #!/bin/sh # +++++++++++++++++++++++++++++++++++++++++++++++ # +Eternal Lands Notityer v0.9, (c) 2007 by HTHO+ # +++++++++++++++++++++++++++++++++++++++++++++++ #---------------------------------------------------------------------------------------------------------------------- # License: # 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/>. #---------------------------------------------------------------------------------------------------------------------- # Description: # This handy tool will tell you when you stop harvesting, so you can do someting useful while harvesting. #---------------------------------------------------------------------------------------------------------------------- # Info: # This tool will split up your chat_log.txt an save the older parts with date and time. # While working it will use the files el_notifyer_temp_1.tmp and el_notifyer_temp_2.tmp #---------------------------------------------------------------------------------------------------------------------- #Configuraton: logfile="/home/htho/.elc/chat_log.txt" #Normaly the Logfiles in your home directory and then in the directory logpath="/home/htho/.elc/" #Harvesting search_harvest="You stopped harvesting" #The String that appears when you stop harvesting sound_harvest="niesen.wav" # The Played Sound text_harvest='..::YOU STOPPED HARVESTING::..' #The string that appears in the shell #PMs search_PM="PM from" sound_PM="hallo.wav" text_PM="_.-=< YOU GOT A PERSONAL MESSAGE >=-._" # Have Fun! #---------------------------------------------------------------------------------------------------------------------- textnotify () { echo "$1" } soundnotify () { playsound $1 } echo "Eternal Lands Notifyer v0.9" #cp $logfile $logpath"chat_log_$(date +%X-%d.%m.%y).txt" #tail $logpath"chat_log_$(date +%X-%d.%m.%y).txt" > $logfile temp_harvest_old=$(grep -c "$search_harvest" $logfile) temp_PM_old=$(grep -c "$search_PM" $logfile) i=0 while [ $i != 1 ]; do temp_harvest_new=$(grep -c "$search_harvest" $logfile) if [ $temp_harvest_new -ne $temp_harvest_old ]; then soundnotify $sound_harvest; textnotify "$text_harvest"; temp_harvest_old=$temp_harvest_new; fi; temp_PM_new=$(grep -c "$search_PM" $logfile) if [ $temp_PM_new -ne $temp_PM_old ]; then soundnotify $sound_PM; textnotify "$text_PM"; temp_PM_old=$temp_PM_new; fi; sleep 2 done; As you can see, it doesnt only play a sound when you stop harvesting, it plays too when you gat a PM. Well here is the link. You will have set the values for $logfile and $logpath fitting to your system http://intertrigo.de/DATENAUSTAUSCH/el_notifyer.tar.gz What do you (the other programmers) say to this tool, is it legal or not. What could be done better? Share this post Link to post Share on other sites
Placid Report post Posted September 26, 2007 There are many versions of scripts like this. In my opinion, it would be better to implement such a feature as part of EL's sound system. You might want to wonder over to this thread and discuss it there. Share this post Link to post Share on other sites
majestyk Report post Posted September 26, 2007 (edited) On a quick glance, you're doing a "grep -c" on your chat log every 2 seconds. I don't know how big your chat log is, but mine is many million lines, and you need to read them all every two seconds just to know if there was a harvesting stop or not. A smarter approach would be to tail the file, and then act on each new line you receive. Would save lots of IO. Edit: typo Edited September 26, 2007 by majestyk Share this post Link to post Share on other sites
bkc56 Report post Posted September 26, 2007 I agree. My version of this script does a "tail -f" on the log file (also playing sounds for harvest stops and PMs). Share this post Link to post Share on other sites
Florian Report post Posted September 26, 2007 My script tails the logs and growls (http://www.growl.info/) on events ... Share this post Link to post Share on other sites
Guest BloodyMary Report post Posted September 26, 2007 On a quick glance, you're doing a "grep -c" on your chat log every 2 seconds. I don't know how big your chat log is, but mine is many million lines, and you need to read them all every two seconds just to know if there was a harvesting stop or not. A smarter approach would be to tail the file, and then act on each new line you receive. Would safe lots of IO. Oh, I forgot to kill the "#" Ill update the file and load it up again: #cp $logfile $logpath"chat_log_$(date +%X-%d.%m.%y).txt" #tail $logpath"chat_log_$(date +%X-%d.%m.%y).txt" > $logfile Share this post Link to post Share on other sites
kailomonkey Report post Posted November 27, 2007 Is there a way to get this working for windows? Share this post Link to post Share on other sites
sanlay Report post Posted November 27, 2007 Cygwin? Share this post Link to post Share on other sites
2coolfool Report post Posted November 27, 2007 for windows, I use this: http://el.asgardsrealm.net/dokuwiki/doku.p...=event%20sounds Share this post Link to post Share on other sites
bluap Report post Posted November 27, 2007 for windows, I use this: Or everyone could use the new sound system which can play user defined sounds when the client sees user defined text in chat: The sound_warnings.txt should be placed in the same directory as your el.ini file and other personal files. Here's the content of mine: # This file is configuring sounds based on text displayed in the console # # Format for this file: # Sound = Text to match # # The default sounds available are: # alert1, alert2, alert3, alert4 # alert1 = You stopped harvesting. Drop Item = PM from You'll need to restart the client after editing this file. We should all thank Torg Share this post Link to post Share on other sites
LabRat Report post Posted April 9, 2009 (edited) I know this is older than Noah's hammer but I just rewrote this to use Ubuntu Jaunty's new notification system: File harvest #!/bin/bash # +++++++++++++++++++++++++++++++++++++++++++++++ # +Eternal Lands Notifier v1.0, (c) 2007 by HTHO+ # +Rewritten 2009 by LabRat labby@labby.co.uk # +++++++++++++++++++++++++++++++++++++++++++++++ #---------------------------------------------------------------------------------------------------------------------- # License: # 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/>. #---------------------------------------------------------------------------------------------------------------------- # Description: # This handy tool will tell you when you stop harvesting, so you can do something useful while harvesting. #---------------------------------------------------------------------------------------------------------------------- #Configuration: logfile="~/.elc/main/chat_log.txt" pidfile="~/.elc/main/pidfile" #Harvesting search_harvest="You stopped harvesting." #The String that appears when you stop harvesting sound_harvest="niesen.wav" # The Played Sound text_harvest='You stopped harvesting.' #The string that appears in the shell el="Eternal Lands" icon="~/el_linux/elc.ico" #---------------------------------------------------------------------------------------------------------------------- textnotify () { notify "$1" "$2" "$3" } soundnotify () { playsound $1 } title="Eternal Lands Notifyer v1.0" if [ -f $pidfile ]; then textnotify "Terminating" "process already running" "$icon"; exit else textnotify "$title" "$pidfile" "$icon"; fi; echo 1>$pidfile temp_harvest_old=$(tail $logfile | grep "$search_harvest" | tail -n 1) i=0 seconds=0 newline=" "#$(awk '{print "\n"}') while [ $i != 1 ]; do temp_harvest_new=$(tail $logfile | grep "$search_harvest" | tail -n 1) if [ "$temp_harvest_new" != "$temp_harvest_old" ]; then if [ "$temp_harvest_new" != "" ]; then #soundnotify $sound_harvest; textnotify "$el" "after $seconds seconds $text_harvest" "$icon"; seconds=0 #echo "$temp_harvest_old $temp_harvest_new" temp_harvest_old=$temp_harvest_new; fi; fi; if [ -f $pidfile ]; then seconds=`expr $seconds + 1`; else textnotify "Terminating" "pidfile deleted" "$icon"; sleep 1; exit fi; sleep 1 done; file test-notify.cc #include <libnotifymm.h> #include <iostream> int main(int argc,char *argv[]) { Notify::init("Basic"); char *p1="",*p2="",*p3=""; int e = 0; switch(argc) { case 2: p1 = "Notification"; p2 = argv[1]; p3 = ""; break; case 3: p1 = argv[1]; p2 = argv[2]; p3 = ""; break; case 4: p1 = argv[1]; p2 = argv[2]; p3 = argv[3]; break; default: printf("Usage\n%s Text|Title Text|Title Text Icon\n\n",argv[0]); e = 1; break; } if(e == 1) return 1; Notify::Notification n(p1,p2,p3); if (!n.show()) { std::cerr << "Could not show notification" << std::endl; return 1; } } /* g++ -o notify test-notify.cc `pkg-config gtkmm-2.4 --libs --cflags` `pkg-config libnotifymm-1.0 --libs --cflags` sudo mv notify /bin/notify */ Edited April 9, 2009 by LabRat Share this post Link to post Share on other sites
ladrilho Report post Posted April 9, 2009 Hi, really nice script, thank you. I would like to suggest you a package called "libnotify-bin" that has a binary "notify-send" that allows you to send notifications from the console. Just in case you don't know it. Bruno Ramos Share this post Link to post Share on other sites
LabRat Report post Posted April 9, 2009 I am aware of that package, I rewrote the script yesterday to use that but found the popup window too restrictive. As the new notification system is standard in 9.04 I coded for that. Share this post Link to post Share on other sites
Dugur Report post Posted August 14, 2009 for windows, I use this: Or everyone could use the new sound system which can play user defined sounds when the client sees user defined text in chat: The sound_warnings.txt should be placed in the same directory as your el.ini file and other personal files. Here's the content of mine: # This file is configuring sounds based on text displayed in the console # # Format for this file: # Sound = Text to match # # The default sounds available are: # alert1, alert2, alert3, alert4 # alert1 = You stopped harvesting. Drop Item = PM from You'll need to restart the client after editing this file. We should all thank Torg This works great. Only problem is that the sounds are client type, and the warning I set to sound_warnings play with all other misc client sounds enabled. Is there a way to make is so that the alert sounds play as their own type? Game options does have text warning sounds volume for user defined warnings, so I'm prolly missing something here :S Share this post Link to post Share on other sites
Choris Report post Posted August 14, 2009 This works great. Only problem is that the sounds are client type, and the warning I set to sound_warnings play with all other misc client sounds enabled. Is there a way to make is so that the alert sounds play as their own type?Game options does have text warning sounds volume for user defined warnings, so I'm prolly missing something here :S Yes, there's a bug with the xml files, the alert sounds seem to have the wrong sound type. Just open snds_client.xml (in the sounds folder) and find the part <sound name = "alert1"> <variant> <main_sound>sound/inventory02.ogg</main_sound> </variant> <distance>35</distance> <priority>3</priority> <type>client</type> </sound> and change the <type>client</type> to <type>warnings</type> for all the 4 alert sounds. That was enough to fix it for me, hope it helps Share this post Link to post Share on other sites
Dugur Report post Posted August 14, 2009 That solved it, ty Choris and ty Torg Share this post Link to post Share on other sites
psihokiller4 Report post Posted December 3, 2011 thank you very much for this this helps me alot Share this post Link to post Share on other sites