plasma-applets icon indicating copy to clipboard operation
plasma-applets copied to clipboard

[eventcalendar] Repeat timer sfx __ times (or loop until notification dismiss if possible)

Open Zren opened this issue 9 years ago • 2 comments

Loop until...?

  • 5 times? I could probably add a configurable uninterruptible loop.
  • Until you press a button? I don't I can do this as I'm not quite sure how to add a button to the notification that signals back to the widget.

Have you tried a different sound effect? There's a few longer ones you could try.

  • Default SFX: /usr/share/sounds/freedesktop/stereo/complete.oga
  • 3 Beeps over 2 seconds: /usr/share/sounds/freedesktop/stereo/phone-outgoing-busy.oga
  • 4 second jingle: /usr/share/sounds/KDE-Im-Phone-Ring.ogg

It seems Audio.loops will repeat infinitely when > 1, so I'll need to implement remainingLoops myself.

Zren avatar Sep 24 '16 02:09 Zren

Probably worth mentioning two other (not necessarily better) ways of approaching this:

  1. run custom command on timer completion
  2. use Plasma's integrated notification and event system, which would also allow custom command on timer completion:

Screenshot_20191025_164019

Here's an example simple script I might use for the timer if I can:

#!/usr/bin/env python3
from plumbum.cmd import mpv, kdialog, kill, notify_send
from plumbum import BG


fut = mpv['--loop', '/usr/share/sounds/freedesktop/stereo/complete.oga'] & BG
try:
    kdialog(
        '--title', "Timer",
        '--icon', 'kalarm',
        '--msgbox', "Your time's run out!"
    )
except (Exception, KeyboardInterrupt) as e:
    notify_send(
        '-a', "Timer",
        '-i', 'kalarm',
        '-t', 0,
        "Timer Error",
        str(e)
    )
finally:
    kill(fut.proc.pid)

AndydeCleyre avatar Oct 25 '19 21:10 AndydeCleyre

I'm thinking of something similar, where it returns which "action" was clicked. I spin up canberra-gtk-play which is part of libcanberra which is a plasma-pa dependency (the volume widget). With it printing which action was clicked, I could dynamically add buttons like "sleep 5min" or something along those lines.

$ dpkg -S `which canberra-gtk-play`
$ pacman -Qo `which canberra-gtk-play`
/usr/bin/canberra-gtk-play is owned by libcanberra 0.30+2+gc0620e4-2
#!/usr/bin/python3
import subprocess

import gi
gi.require_version('GLib', '2.0')
gi.require_version('Notify', '0.7')
from gi.repository import GLib, Notify

appName = "Event Calendar"

# https://notify2.readthedocs.io/en/latest/
loop = GLib.MainLoop()
Notify.init(appName)
# print(Notify.get_server_caps())

n = Notify.Notification.new(
	appName,
	"This is an example notification.",
	icon="view-calendar"
)

def on_action(notification, action, *user_data):
	print(action, *user_data)
	sfxProc.terminate()
	loop.quit()

def closed(notification):
	on_action(notification, "closed")

n.connect("closed", closed)
n.add_action("default", "default", on_action)
n.add_action("dismiss", "Dismiss", on_action)

n.show()

sfxProc = subprocess.Popen([
	"canberra-gtk-play",
	# "--id", "phone-incoming-call",
	"--file", "/usr/share/sounds/freedesktop/stereo/complete.oga",
	"--description", appName,
	"--loop", "3",
])

loop.run()

Zren avatar Nov 02 '19 03:11 Zren