PlaneShift

Development => PlaneShift Mods => Topic started by: netforce10 on June 30, 2017, 08:13:21 am

Title: Notification sound for /greets or other actions targeted at you.
Post by: netforce10 on June 30, 2017, 08:13:21 am
Because I'm often tabbed out I tend to miss someone greeting me occasionally, to remedy I made a small python program which plays a sound whenever I'm targeted by an action. It looks at every new line in the logs and checks if your character's first name is the second last word.

In case anyone wants to use it I've included it below, just copy it all into a text file, change the first couple variable to suit you and then run it with python(3.5). It should work on both linux and windows but I have only tested it for myself, if it doesn't work for you please say so then I can try to fix it.

Code: [Select]
#version 1
log="/home/Larili/.PlaneShift/logs/Larili_Soriol_System_Base.txt"   #change this path to wherever your System Base is logging to.
name="Larili" #replace with your character's first name
sound="/usr/share/sounds/freedesktop/stereo/bell.oga" #soundfile to be played. Required for linux, optional for windows.
volume="1"
BorF=0      #for windows if you want it to play a sound file instead of a beep set this to 1

import platform
import os

if platform.system() == "windows":
    from winsound import Beep, PlaySound

from time import sleep
f= open(log, "r")
for line in f:
    pass
print(line)
while 1:
    line=f.readline()
    if len(line.split())>2:
        if name == line.split()[-2]:
            print(line)
            if platform.system() == "Linux":
                os.system("play -q -v "+volume+" "+sound)
            elif platform.system() == "windows":
                if BorF==1:
                    PlaySound(sound)
                else:
                    Beep(310, 500)      #make a beep with a freq 310hz for a duration of 500ms
               
    sleep(1)
Title: Re: Notification sound for /greets or other actions targeted at you.
Post by: zarre on July 01, 2017, 09:49:23 am
 :thumbup: Thanks. Would be a nice option offered from the PS download in the future.
Title: Re: Notification sound for /greets or other actions targeted at you.
Post by: Migg on July 01, 2017, 12:53:56 pm
Thanks for the script, Larili! it is really usefull! Just a note for Linux users: This script spawns a "play" command to play the sound. If you don't have that, then install sox. The sound in my case is part of the sound-theme-freedesktop package, so if you miss the sound file make sure you also install that.
Title: Re: Notification sound for /greets or other actions targeted at you.
Post by: LigH on July 03, 2017, 01:27:15 am
I would possibly play the "ah-oh!" notification (was it IRC or Skype?!)  ;D