GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — [timer] Make notification stay. · DenverCoderOne/albert-python@2f2de70

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • timer
    • __init__.py
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎timer/__init__.py‎

Copy file name to clipboardExpand all lines: timer/__init__.py
+9-19Lines changed: 9 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,16 @@
99
1010
Synopsis: <trigger> [[[hours]:][minutes]:]seconds [name]"""
1111

12-
from albert import *
12+
from albert import warning, Item, FuncAction
1313
from threading import Timer
1414
from time import strftime, time, localtime
1515
import dbus
1616
import os
17+
from datetime import timedelta
1718
import subprocess
1819

1920
__title__ = "Timer"
20-
__version__ = "0.4.2"
21+
__version__ = "0.4.3"
2122
__triggers__ = "timer "
2223
__authors__ = ["manuelschneid3r", "googol42"]
2324
__py_deps__ = ["dbus-python"]
@@ -26,10 +27,9 @@
2627
soundPath = os.path.dirname(__file__)+"/bing.wav"
2728
timers = []
2829

29-
dbusItem = "org.freedesktop.Notifications"
30-
dbusPath = "/org/freedesktop/Notifications"
31-
dbusInterface = "org.freedesktop.Notifications"
32-
30+
bus_name = "org.freedesktop.Notifications"
31+
object_path = "/org/freedesktop/Notifications"
32+
interface = bus_name
3333

3434
class AlbertTimer(Timer):
3535

@@ -39,13 +39,10 @@ def timeout():
3939
subprocess.Popen(["aplay", soundPath])
4040
global timers
4141
timers.remove(self)
42-
4342
title = 'Timer "%s"' % self.name if self.name else 'Timer'
4443
text = "Timed out at %s" % strftime("%X", localtime(self.end))
45-
46-
bus = dbus.SessionBus()
47-
notify = dbus.Interface(bus.get_object(dbusItem, dbusPath), dbusInterface)
48-
notify.Notify(__title__, 0, iconPath, title, text, '', '', 0)
44+
notify = dbus.Interface(dbus.SessionBus().get_object(bus_name, object_path), interface)
45+
notify.Notify(__title__, 0, iconPath, title, text, [], {"urgency":2}, 0)
4946

5047
super().__init__(interval=interval, function=timeout)
5148
self.interval = interval
@@ -65,13 +62,6 @@ def deleteTimer(timer):
6562
timers.remove(timer)
6663
timer.cancel()
6764

68-
69-
def formatSeconds(seconds):
70-
m, s = divmod(seconds, 60)
71-
h, m = divmod(m, 60)
72-
return "%02d:%02d:%02d" % (h, m, s)
73-
74-
7565
def handleQuery(query):
7666
if query.isTriggered:
7767

@@ -94,7 +84,7 @@ def handleQuery(query):
9484

9585
return Item(
9686
id=__title__,
97-
text=formatSeconds(seconds),
87+
text=str(timedelta(seconds=seconds)),
9888
subtext='Set a timer with name "%s"' % name if name else 'Set a timer',
9989
icon=iconPath,
10090
actions=[FuncAction("Set timer", lambda sec=seconds: startTimer(sec, name))]

0 commit comments

Comments
0 (0)
You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.