Author Topic: Notification sound for /greets or other actions targeted at you.  (Read 402 times)

netforce10

  • Hydlaa Resident
  • *
  • Posts: 61
    • View Profile
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)
Larili Soriol

zarre

  • Hydlaa Resident
  • *
  • Posts: 90
    • View Profile
Re: Notification sound for /greets or other actions targeted at you.
« Reply #1 on: July 01, 2017, 09:49:23 am »
 :thumbup: Thanks. Would be a nice option offered from the PS download in the future.

Migg

  • Hydlaa Citizen
  • *
  • Posts: 223
    • View Profile
Re: Notification sound for /greets or other actions targeted at you.
« Reply #2 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.

LigH

  • Forum Legend
  • *
  • Posts: 7096
    • View Profile
Re: Notification sound for /greets or other actions targeted at you.
« Reply #3 on: July 03, 2017, 01:27:15 am »
I would possibly play the "ah-oh!" notification (was it IRC or Skype?!)  ;D

Gag Harmond
Knight and Ambassador
The Royal House of Purrty