Ulauncher / ulauncher-timer

Timer Extension
50 stars 11 forks source link

Timer doesn't fire #2

Closed Perturbatio closed 6 years ago

Perturbatio commented 6 years ago

Hi, whenever I set a timer, the event doesn't actually fire.

System Info: Linux Mint 18.3 Sylvia Python v2.7.12

I can make a notification fire using the following code (cobbled together) which suggests my system has all the required modules/functionality, but it won't fire using the Ulauncher extension.

I do note that the threading.Timer event doesn't fire if the script ends before the timeout (hence the sleep(6) in my example), I'm not a Python dev so can't really figure out any more.

import os
import subprocess
import gi
import time

gi.require_version('Notify', '0.7')

from gi.repository import Notify
from threading import Timer

def show_notification(text):
    print "Notification fired" + text
    Notify.init("TimerExtension")
    Notify.Notification.new("Timer", text).show()
    subprocess.call(("paplay", "/usr/share/sounds/freedesktop/stereo/complete.oga"))

def start_timer(delay, text):
    timer = Timer(delay, lambda:show_notification(text))
    timer.setDaemon(True)
    timer.start()

print "starting timer"
start_timer(5.0, "test")
time.sleep(6) #without this, the timer doesn't fire
print "timer should have completed by now"
gornostal commented 6 years ago

Apologies for the delay. If you run ulauncher like this ulauncher -v and then set a timer (ti 1m hello), do you see lines like this in the console?

com.github.ulauncher.ulauncher-timer | 2018-06-08 09:15:14,855 | DEBUG | timer.ItemEnterEventListener: on_event() | Timer is set. Delay 60
com.github.ulauncher.ulauncher-timer | 2018-06-08 09:16:14,802 | DEBUG | timer.TimerExtension: show_notification() | Show notification: hello

If you do then event is firing but notification is not shown for some reason

Perturbatio commented 6 years ago

if I do ulauncher -v, I get:

/usr/lib/python2.7/dist-packages/ulauncher/util/desktop/notification.py:1: PyGIWarning: Notify was imported without specifying a version first. Use gi.require_version('Notify', '0.7') before import to ensure that the right version gets loaded. from gi.repository import Notify /usr/lib/python2.7/dist-packages/ulauncher/ui/windows/PreferencesUlauncherDialog.py:6: PyGIWarning: WebKit2 was imported without specifying a version first. Use gi.require_version('WebKit2', '4.0') before import to ensure that the right version gets loaded. from gi.repository import Gio, Gtk, WebKit2, GLib

And uLauncher loads, I can create a timer with ti 1m test and I see a timer.

However I did apply some system updates today and can now set a timer normally. There was an update to Python (python3-louis:amd64 (2.6.4-2ubuntu0.1, 2.6.4-2ubuntu0.3)) which may have been the solution.

gornostal commented 6 years ago

Those warnings do not affect performance of Ulauncher or extensions. Anyway, it's good the extension works now.

Please reopen if necessary