-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathespeak-script.py
executable file
·60 lines (49 loc) · 2.05 KB
/
espeak-script.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#!/usr/bin/env python3
# This file is part of the Finna Pomodoro Project
# Copyright (C) 2014 Vinícius dos Santos Oliveira <vini.ipsmaker@gmail.com>
#
# This software is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 3 of the License, or (at your option) any
# later version.
#
# This software is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with this library. If not, see <http://www.gnu.org/licenses/>.
import dbus
import dbus.mainloop.glib
from gi.repository import GObject
from espeak import espeak
mainloop = GObject.MainLoop()
dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
bus = dbus.SessionBus()
bus_name = 'io.github.finna_pomodoro_project' #< The service name
object_path = '/io/github/finna_pomodoro_project/Pomodoro'
dbus_interface = 'io.github.finna_pomodoro_project.Pomodoro'
try:
import getpass
user = getpass.getuser()
except:
user = 'Anonymous'
def available_slot():
espeak.synth(user + ', time to procrastinate!')
def unavailable_slot():
espeak.synth(user + ', time to work!')
bus.add_signal_receiver(available_slot,
signal_name='pomodoro_paused',
dbus_interface=dbus_interface, bus_name=bus_name,
path=object_path)
bus.add_signal_receiver(unavailable_slot,
signal_name='work_session_started',
dbus_interface=dbus_interface, bus_name=bus_name,
path=object_path)
bus.add_signal_receiver(available_slot,
signal_name='work_session_stopped',
dbus_interface=dbus_interface, bus_name=bus_name,
path=object_path)
mainloop.run()