Feature Media Control plugin and toolbar support (#295)
* Add toolbar actions to the break screen * Add media control plugin
This commit is contained in:
parent
107670f9c0
commit
b6c8b504af
|
@ -117,14 +117,14 @@ class BreakScreen(object):
|
|||
timeformat = '{:02d}:{:02d}'.format(mins, secs)
|
||||
GLib.idle_add(lambda: self.__update_count_down(timeformat))
|
||||
|
||||
def show_message(self, break_obj, widget):
|
||||
def show_message(self, break_obj, widget, tray_actions=[]):
|
||||
"""
|
||||
Show the break screen with the given message on all displays.
|
||||
"""
|
||||
message = break_obj.name
|
||||
image_path = break_obj.image
|
||||
self.enable_shortcut = not self.strict_break and self.shortcut_disable_time <= 0
|
||||
GLib.idle_add(lambda: self.__show_break_screen(message, image_path, widget))
|
||||
GLib.idle_add(lambda: self.__show_break_screen(message, image_path, widget, tray_actions))
|
||||
|
||||
def close(self):
|
||||
"""
|
||||
|
@ -136,7 +136,15 @@ class BreakScreen(object):
|
|||
# Destroy other windows if exists
|
||||
GLib.idle_add(lambda: self.__destroy_all_screens())
|
||||
|
||||
def __show_break_screen(self, message, image_path, widget):
|
||||
def __toolbar_action(self, button, action):
|
||||
"""
|
||||
Toolbar action handler.
|
||||
Hides the toolbar button and call the action provided by the plugin.
|
||||
"""
|
||||
button.hide()
|
||||
action()
|
||||
|
||||
def __show_break_screen(self, message, image_path, widget, tray_actions):
|
||||
"""
|
||||
Show an empty break screen on all screens.
|
||||
"""
|
||||
|
@ -162,6 +170,19 @@ class BreakScreen(object):
|
|||
lbl_widget = builder.get_object("lbl_widget")
|
||||
img_break = builder.get_object("img_break")
|
||||
box_buttons = builder.get_object("box_buttons")
|
||||
toolbar = builder.get_object("toolbar")
|
||||
|
||||
separator = Gtk.SeparatorToolItem()
|
||||
toolbar.add(separator)
|
||||
toolbar.child_set(separator, expand=True)
|
||||
separator.show()
|
||||
|
||||
for tray_action in tray_actions:
|
||||
toolbar_button = Gtk.ToolButton.new_from_stock(tray_action.icon)
|
||||
toolbar_button.connect("clicked", lambda button: self.__toolbar_action(button, tray_action.action))
|
||||
toolbar_button.set_tooltip_text(_(tray_action.tooltip))
|
||||
toolbar.add(toolbar_button)
|
||||
toolbar_button.show()
|
||||
|
||||
# Add the buttons
|
||||
if not self.strict_break:
|
||||
|
|
|
@ -73,6 +73,7 @@ class PluginManager(object):
|
|||
self.__plugins_on_countdown = []
|
||||
self.__plugins_update_next_break = []
|
||||
self.__widget_plugins = []
|
||||
self.__tray_actions_plugins = []
|
||||
self.last_break = None
|
||||
self.horizontal_line = '─' * HORIZONTAL_LINE_LENGTH
|
||||
|
||||
|
@ -182,6 +183,19 @@ class PluginManager(object):
|
|||
continue
|
||||
return widget.strip()
|
||||
|
||||
def get_break_screen_tray_actions(self, break_obj):
|
||||
"""
|
||||
Return Tray Actions.
|
||||
"""
|
||||
actions = []
|
||||
for plugin in self.__tray_actions_plugins:
|
||||
if break_obj.plugin_enabled(plugin['id'], plugin['enabled']):
|
||||
action = plugin['module'].get_tray_action(break_obj)
|
||||
if action:
|
||||
actions.append(action)
|
||||
|
||||
return actions
|
||||
|
||||
def __has_method(self, module, method_name, no_of_args=0):
|
||||
"""
|
||||
Check whether the given function is defined in the module or not.
|
||||
|
@ -226,6 +240,7 @@ class PluginManager(object):
|
|||
self.__remove_if_exists(self.__plugins_on_stop_break, plugin_obj)
|
||||
self.__remove_if_exists(self.__plugins_on_countdown, plugin_obj)
|
||||
self.__remove_if_exists(self.__widget_plugins, plugin_obj)
|
||||
self.__remove_if_exists(self.__tray_actions_plugins, plugin_obj)
|
||||
del self.__plugins[plugin['id']]
|
||||
return
|
||||
|
||||
|
@ -277,7 +292,8 @@ class PluginManager(object):
|
|||
# Load the plugin module
|
||||
module = importlib.import_module((plugin['id'] + '.plugin'))
|
||||
logging.info("Successfully loaded %s", str(module))
|
||||
plugin_obj = {'id': plugin['id'], 'module': module, 'config': plugin.get('settings', {}), 'enabled': plugin_enabled, 'break_override_allowed': plugin_config.get('break_override_allowed', False)}
|
||||
plugin_obj = {'id': plugin['id'], 'module': module, 'config': plugin.get(
|
||||
'settings', {}), 'enabled': plugin_enabled, 'break_override_allowed': plugin_config.get('break_override_allowed', False)}
|
||||
self.__plugins[plugin['id']] = plugin_obj
|
||||
if self.__has_method(module, 'enable'):
|
||||
module.enable()
|
||||
|
@ -302,3 +318,5 @@ class PluginManager(object):
|
|||
self.__plugins_on_countdown.append(plugin_obj)
|
||||
if self.__has_method(module, 'get_widget_title', 1) and self.__has_method(module, 'get_widget_content', 1):
|
||||
self.__widget_plugins.append(plugin_obj)
|
||||
if self.__has_method(module, 'get_tray_action', 1):
|
||||
self.__tray_actions_plugins.append(plugin_obj)
|
||||
|
|
|
@ -239,7 +239,8 @@ class SafeEyes(object):
|
|||
"""
|
||||
# Get the HTML widgets content from plugins
|
||||
widget = self.plugins_manager.get_break_screen_widgets(break_obj)
|
||||
self.break_screen.show_message(break_obj, widget)
|
||||
actions = self.plugins_manager.get_break_screen_tray_actions(break_obj)
|
||||
self.break_screen.show_message(break_obj, widget, actions)
|
||||
|
||||
def countdown(self, countdown, seconds):
|
||||
"""
|
||||
|
|
|
@ -444,3 +444,15 @@ msgstr ""
|
|||
#: plugins/trayicon
|
||||
msgid "Quit"
|
||||
msgstr ""
|
||||
|
||||
# plugin/mediacontrol
|
||||
msgid "Media Control"
|
||||
msgstr ""
|
||||
|
||||
# plugin/mediacontrol
|
||||
msgid "Pause media players from the break screen"
|
||||
msgstr ""
|
||||
|
||||
# plugin/mediacontrol
|
||||
msgid "Pause media"
|
||||
msgstr ""
|
||||
|
|
|
@ -430,3 +430,15 @@ msgstr ""
|
|||
#: plugins/trayicon
|
||||
msgid "Quit"
|
||||
msgstr ""
|
||||
|
||||
# plugin/mediacontrol
|
||||
msgid "Media Control"
|
||||
msgstr ""
|
||||
|
||||
# plugin/mediacontrol
|
||||
msgid "Pause media players from the break screen"
|
||||
msgstr ""
|
||||
|
||||
# plugin/mediacontrol
|
||||
msgid "Pause media"
|
||||
msgstr ""
|
||||
|
|
|
@ -434,3 +434,15 @@ msgstr "Fins que es reinicïi"
|
|||
#: plugins/trayicon
|
||||
msgid "Quit"
|
||||
msgstr "Tanca"
|
||||
|
||||
# plugin/mediacontrol
|
||||
msgid "Media Control"
|
||||
msgstr ""
|
||||
|
||||
# plugin/mediacontrol
|
||||
msgid "Pause media players from the break screen"
|
||||
msgstr ""
|
||||
|
||||
# plugin/mediacontrol
|
||||
msgid "Pause media"
|
||||
msgstr ""
|
||||
|
|
|
@ -439,3 +439,15 @@ msgstr "Do restartu"
|
|||
#: plugins/trayicon
|
||||
msgid "Quit"
|
||||
msgstr "Ukončit"
|
||||
|
||||
# plugin/mediacontrol
|
||||
msgid "Media Control"
|
||||
msgstr ""
|
||||
|
||||
# plugin/mediacontrol
|
||||
msgid "Pause media players from the break screen"
|
||||
msgstr ""
|
||||
|
||||
# plugin/mediacontrol
|
||||
msgid "Pause media"
|
||||
msgstr ""
|
||||
|
|
|
@ -432,3 +432,15 @@ msgstr "Indtil genstart"
|
|||
#: plugins/trayicon
|
||||
msgid "Quit"
|
||||
msgstr "Afslut"
|
||||
|
||||
# plugin/mediacontrol
|
||||
msgid "Media Control"
|
||||
msgstr ""
|
||||
|
||||
# plugin/mediacontrol
|
||||
msgid "Pause media players from the break screen"
|
||||
msgstr ""
|
||||
|
||||
# plugin/mediacontrol
|
||||
msgid "Pause media"
|
||||
msgstr ""
|
||||
|
|
|
@ -434,3 +434,15 @@ msgstr "Bis zum Neustart"
|
|||
#: plugins/trayicon
|
||||
msgid "Quit"
|
||||
msgstr "Schließen"
|
||||
|
||||
# plugin/mediacontrol
|
||||
msgid "Media Control"
|
||||
msgstr ""
|
||||
|
||||
# plugin/mediacontrol
|
||||
msgid "Pause media players from the break screen"
|
||||
msgstr ""
|
||||
|
||||
# plugin/mediacontrol
|
||||
msgid "Pause media"
|
||||
msgstr ""
|
||||
|
|
|
@ -434,3 +434,15 @@ msgstr "Until restart"
|
|||
#: plugins/trayicon
|
||||
msgid "Quit"
|
||||
msgstr "Quit"
|
||||
|
||||
# plugin/mediacontrol
|
||||
msgid "Media Control"
|
||||
msgstr ""
|
||||
|
||||
# plugin/mediacontrol
|
||||
msgid "Pause media players from the break screen"
|
||||
msgstr ""
|
||||
|
||||
# plugin/mediacontrol
|
||||
msgid "Pause media"
|
||||
msgstr ""
|
||||
|
|
|
@ -433,3 +433,15 @@ msgstr "Hasta el reinicio"
|
|||
#: plugins/trayicon
|
||||
msgid "Quit"
|
||||
msgstr "Salir"
|
||||
|
||||
# plugin/mediacontrol
|
||||
msgid "Media Control"
|
||||
msgstr ""
|
||||
|
||||
# plugin/mediacontrol
|
||||
msgid "Pause media players from the break screen"
|
||||
msgstr ""
|
||||
|
||||
# plugin/mediacontrol
|
||||
msgid "Pause media"
|
||||
msgstr ""
|
||||
|
|
|
@ -433,3 +433,15 @@ msgstr "Taaskäivitumiseni"
|
|||
#: plugins/trayicon
|
||||
msgid "Quit"
|
||||
msgstr "Välju"
|
||||
|
||||
# plugin/mediacontrol
|
||||
msgid "Media Control"
|
||||
msgstr ""
|
||||
|
||||
# plugin/mediacontrol
|
||||
msgid "Pause media players from the break screen"
|
||||
msgstr ""
|
||||
|
||||
# plugin/mediacontrol
|
||||
msgid "Pause media"
|
||||
msgstr ""
|
||||
|
|
|
@ -430,3 +430,15 @@ msgstr ""
|
|||
#: plugins/trayicon
|
||||
msgid "Quit"
|
||||
msgstr ""
|
||||
|
||||
# plugin/mediacontrol
|
||||
msgid "Media Control"
|
||||
msgstr ""
|
||||
|
||||
# plugin/mediacontrol
|
||||
msgid "Pause media players from the break screen"
|
||||
msgstr ""
|
||||
|
||||
# plugin/mediacontrol
|
||||
msgid "Pause media"
|
||||
msgstr ""
|
||||
|
|
|
@ -442,3 +442,15 @@ msgstr "Jusqu’au redémarrage"
|
|||
#: plugins/trayicon
|
||||
msgid "Quit"
|
||||
msgstr "Quitter"
|
||||
|
||||
# plugin/mediacontrol
|
||||
msgid "Media Control"
|
||||
msgstr ""
|
||||
|
||||
# plugin/mediacontrol
|
||||
msgid "Pause media players from the break screen"
|
||||
msgstr ""
|
||||
|
||||
# plugin/mediacontrol
|
||||
msgid "Pause media"
|
||||
msgstr ""
|
||||
|
|
|
@ -431,3 +431,15 @@ msgstr ""
|
|||
#: plugins/trayicon
|
||||
msgid "Quit"
|
||||
msgstr ""
|
||||
|
||||
# plugin/mediacontrol
|
||||
msgid "Media Control"
|
||||
msgstr ""
|
||||
|
||||
# plugin/mediacontrol
|
||||
msgid "Pause media players from the break screen"
|
||||
msgstr ""
|
||||
|
||||
# plugin/mediacontrol
|
||||
msgid "Pause media"
|
||||
msgstr ""
|
||||
|
|
|
@ -432,3 +432,15 @@ msgstr "Újraindításig"
|
|||
#: plugins/trayicon
|
||||
msgid "Quit"
|
||||
msgstr "Kilépés"
|
||||
|
||||
# plugin/mediacontrol
|
||||
msgid "Media Control"
|
||||
msgstr ""
|
||||
|
||||
# plugin/mediacontrol
|
||||
msgid "Pause media players from the break screen"
|
||||
msgstr ""
|
||||
|
||||
# plugin/mediacontrol
|
||||
msgid "Pause media"
|
||||
msgstr ""
|
||||
|
|
|
@ -427,3 +427,15 @@ msgstr ""
|
|||
#: plugins/trayicon
|
||||
msgid "Quit"
|
||||
msgstr ""
|
||||
|
||||
# plugin/mediacontrol
|
||||
msgid "Media Control"
|
||||
msgstr ""
|
||||
|
||||
# plugin/mediacontrol
|
||||
msgid "Pause media players from the break screen"
|
||||
msgstr ""
|
||||
|
||||
# plugin/mediacontrol
|
||||
msgid "Pause media"
|
||||
msgstr ""
|
||||
|
|
|
@ -439,3 +439,15 @@ msgstr "Fino al riavvio"
|
|||
#: plugins/trayicon
|
||||
msgid "Quit"
|
||||
msgstr "Esci"
|
||||
|
||||
# plugin/mediacontrol
|
||||
msgid "Media Control"
|
||||
msgstr ""
|
||||
|
||||
# plugin/mediacontrol
|
||||
msgid "Pause media players from the break screen"
|
||||
msgstr ""
|
||||
|
||||
# plugin/mediacontrol
|
||||
msgid "Pause media"
|
||||
msgstr ""
|
||||
|
|
|
@ -442,3 +442,15 @@ msgstr "Iki paleidimo iš naujo"
|
|||
#: plugins/trayicon
|
||||
msgid "Quit"
|
||||
msgstr "Išeiti"
|
||||
|
||||
# plugin/mediacontrol
|
||||
msgid "Media Control"
|
||||
msgstr ""
|
||||
|
||||
# plugin/mediacontrol
|
||||
msgid "Pause media players from the break screen"
|
||||
msgstr ""
|
||||
|
||||
# plugin/mediacontrol
|
||||
msgid "Pause media"
|
||||
msgstr ""
|
||||
|
|
|
@ -433,3 +433,15 @@ msgstr ""
|
|||
#: plugins/trayicon
|
||||
msgid "Quit"
|
||||
msgstr ""
|
||||
|
||||
# plugin/mediacontrol
|
||||
msgid "Media Control"
|
||||
msgstr ""
|
||||
|
||||
# plugin/mediacontrol
|
||||
msgid "Pause media players from the break screen"
|
||||
msgstr ""
|
||||
|
||||
# plugin/mediacontrol
|
||||
msgid "Pause media"
|
||||
msgstr ""
|
||||
|
|
|
@ -431,3 +431,15 @@ msgstr "Til omstart"
|
|||
#: plugins/trayicon
|
||||
msgid "Quit"
|
||||
msgstr "Avslutt"
|
||||
|
||||
# plugin/mediacontrol
|
||||
msgid "Media Control"
|
||||
msgstr ""
|
||||
|
||||
# plugin/mediacontrol
|
||||
msgid "Pause media players from the break screen"
|
||||
msgstr ""
|
||||
|
||||
# plugin/mediacontrol
|
||||
msgid "Pause media"
|
||||
msgstr ""
|
||||
|
|
|
@ -437,3 +437,15 @@ msgstr "Tot herstart"
|
|||
#: plugins/trayicon
|
||||
msgid "Quit"
|
||||
msgstr "Afsluiten"
|
||||
|
||||
# plugin/mediacontrol
|
||||
msgid "Media Control"
|
||||
msgstr ""
|
||||
|
||||
# plugin/mediacontrol
|
||||
msgid "Pause media players from the break screen"
|
||||
msgstr ""
|
||||
|
||||
# plugin/mediacontrol
|
||||
msgid "Pause media"
|
||||
msgstr ""
|
||||
|
|
|
@ -439,3 +439,15 @@ msgstr "Do ponownego uruchomienia"
|
|||
#: plugins/trayicon
|
||||
msgid "Quit"
|
||||
msgstr "Wyjście"
|
||||
|
||||
# plugin/mediacontrol
|
||||
msgid "Media Control"
|
||||
msgstr ""
|
||||
|
||||
# plugin/mediacontrol
|
||||
msgid "Pause media players from the break screen"
|
||||
msgstr ""
|
||||
|
||||
# plugin/mediacontrol
|
||||
msgid "Pause media"
|
||||
msgstr ""
|
||||
|
|
|
@ -438,3 +438,15 @@ msgstr "Até reiniciar"
|
|||
#: plugins/trayicon
|
||||
msgid "Quit"
|
||||
msgstr "Sair"
|
||||
|
||||
# plugin/mediacontrol
|
||||
msgid "Media Control"
|
||||
msgstr ""
|
||||
|
||||
# plugin/mediacontrol
|
||||
msgid "Pause media players from the break screen"
|
||||
msgstr ""
|
||||
|
||||
# plugin/mediacontrol
|
||||
msgid "Pause media"
|
||||
msgstr ""
|
||||
|
|
|
@ -437,3 +437,15 @@ msgstr "До перезапуска"
|
|||
#: plugins/trayicon
|
||||
msgid "Quit"
|
||||
msgstr "Выход"
|
||||
|
||||
# plugin/mediacontrol
|
||||
msgid "Media Control"
|
||||
msgstr ""
|
||||
|
||||
# plugin/mediacontrol
|
||||
msgid "Pause media players from the break screen"
|
||||
msgstr ""
|
||||
|
||||
# plugin/mediacontrol
|
||||
msgid "Pause media"
|
||||
msgstr ""
|
||||
|
|
|
@ -419,3 +419,15 @@ msgstr ""
|
|||
#: plugins/trayicon
|
||||
msgid "Quit"
|
||||
msgstr ""
|
||||
|
||||
# plugin/mediacontrol
|
||||
msgid "Media Control"
|
||||
msgstr ""
|
||||
|
||||
# plugin/mediacontrol
|
||||
msgid "Pause media players from the break screen"
|
||||
msgstr ""
|
||||
|
||||
# plugin/mediacontrol
|
||||
msgid "Pause media"
|
||||
msgstr ""
|
|
@ -436,3 +436,15 @@ msgstr "Do reštartu"
|
|||
#: plugins/trayicon
|
||||
msgid "Quit"
|
||||
msgstr "Koniec"
|
||||
|
||||
# plugin/mediacontrol
|
||||
msgid "Media Control"
|
||||
msgstr ""
|
||||
|
||||
# plugin/mediacontrol
|
||||
msgid "Pause media players from the break screen"
|
||||
msgstr ""
|
||||
|
||||
# plugin/mediacontrol
|
||||
msgid "Pause media"
|
||||
msgstr ""
|
||||
|
|
|
@ -430,3 +430,15 @@ msgstr ""
|
|||
#: plugins/trayicon
|
||||
msgid "Quit"
|
||||
msgstr ""
|
||||
|
||||
# plugin/mediacontrol
|
||||
msgid "Media Control"
|
||||
msgstr ""
|
||||
|
||||
# plugin/mediacontrol
|
||||
msgid "Pause media players from the break screen"
|
||||
msgstr ""
|
||||
|
||||
# plugin/mediacontrol
|
||||
msgid "Pause media"
|
||||
msgstr ""
|
||||
|
|
|
@ -436,3 +436,15 @@ msgstr "மீள ஆரம்பிக்கும் வரை"
|
|||
#: plugins/trayicon
|
||||
msgid "Quit"
|
||||
msgstr "நிறுத்து"
|
||||
|
||||
# plugin/mediacontrol
|
||||
msgid "Media Control"
|
||||
msgstr "பல்லூடக கட்டுப்பாடு"
|
||||
|
||||
# plugin/mediacontrol
|
||||
msgid "Pause media players from the break screen"
|
||||
msgstr "இடைவேளை திரையில் இருந்து பல்லூடக செயலிகளை இடைநிறுத்து"
|
||||
|
||||
# plugin/mediacontrol
|
||||
msgid "Pause media"
|
||||
msgstr "பல்லூடகத்தை இடைநிறுத்து"
|
||||
|
|
|
@ -437,3 +437,15 @@ msgstr "Tekrar başlatılana kadar"
|
|||
#: plugins/trayicon
|
||||
msgid "Quit"
|
||||
msgstr "Çıkış"
|
||||
|
||||
# plugin/mediacontrol
|
||||
msgid "Media Control"
|
||||
msgstr ""
|
||||
|
||||
# plugin/mediacontrol
|
||||
msgid "Pause media players from the break screen"
|
||||
msgstr ""
|
||||
|
||||
# plugin/mediacontrol
|
||||
msgid "Pause media"
|
||||
msgstr ""
|
||||
|
|
|
@ -427,3 +427,15 @@ msgstr ""
|
|||
#: plugins/trayicon
|
||||
msgid "Quit"
|
||||
msgstr ""
|
||||
|
||||
# plugin/mediacontrol
|
||||
msgid "Media Control"
|
||||
msgstr ""
|
||||
|
||||
# plugin/mediacontrol
|
||||
msgid "Pause media players from the break screen"
|
||||
msgstr ""
|
||||
|
||||
# plugin/mediacontrol
|
||||
msgid "Pause media"
|
||||
msgstr ""
|
||||
|
|
|
@ -442,3 +442,15 @@ msgstr "До перезавантаження"
|
|||
#: plugins/trayicon
|
||||
msgid "Quit"
|
||||
msgstr "Вихід"
|
||||
|
||||
# plugin/mediacontrol
|
||||
msgid "Media Control"
|
||||
msgstr ""
|
||||
|
||||
# plugin/mediacontrol
|
||||
msgid "Pause media players from the break screen"
|
||||
msgstr ""
|
||||
|
||||
# plugin/mediacontrol
|
||||
msgid "Pause media"
|
||||
msgstr ""
|
||||
|
|
|
@ -434,3 +434,15 @@ msgstr "Cho đến khi khởi động lại"
|
|||
#: plugins/trayicon
|
||||
msgid "Quit"
|
||||
msgstr "Thoát"
|
||||
|
||||
# plugin/mediacontrol
|
||||
msgid "Media Control"
|
||||
msgstr ""
|
||||
|
||||
# plugin/mediacontrol
|
||||
msgid "Pause media players from the break screen"
|
||||
msgstr ""
|
||||
|
||||
# plugin/mediacontrol
|
||||
msgid "Pause media"
|
||||
msgstr ""
|
||||
|
|
|
@ -430,3 +430,15 @@ msgstr "直到重启"
|
|||
#: plugins/trayicon
|
||||
msgid "Quit"
|
||||
msgstr "退出"
|
||||
|
||||
# plugin/mediacontrol
|
||||
msgid "Media Control"
|
||||
msgstr ""
|
||||
|
||||
# plugin/mediacontrol
|
||||
msgid "Pause media players from the break screen"
|
||||
msgstr ""
|
||||
|
||||
# plugin/mediacontrol
|
||||
msgid "Pause media"
|
||||
msgstr ""
|
||||
|
|
|
@ -428,3 +428,15 @@ msgstr ""
|
|||
#: plugins/trayicon
|
||||
msgid "Quit"
|
||||
msgstr ""
|
||||
|
||||
# plugin/mediacontrol
|
||||
msgid "Media Control"
|
||||
msgstr ""
|
||||
|
||||
# plugin/mediacontrol
|
||||
msgid "Pause media players from the break screen"
|
||||
msgstr ""
|
||||
|
||||
# plugin/mediacontrol
|
||||
msgid "Pause media"
|
||||
msgstr ""
|
||||
|
|
|
@ -114,6 +114,11 @@
|
|||
"id": "healthstats",
|
||||
"enabled": false,
|
||||
"version": "0.0.1"
|
||||
},
|
||||
{
|
||||
"id": "mediacontrol",
|
||||
"enabled": true,
|
||||
"version": "0.0.1"
|
||||
}
|
||||
]
|
||||
}
|
|
@ -92,4 +92,9 @@
|
|||
.info_bar_long_break {
|
||||
opacity: 0.9;
|
||||
border-radius: 5px;
|
||||
}
|
||||
|
||||
.toolbar {
|
||||
background: black;
|
||||
opacity: 0.9;
|
||||
}
|
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!-- Generated with glade 3.18.3 -->
|
||||
<!-- Generated with glade 3.22.1 -->
|
||||
<!--
|
||||
~ Safe Eyes is a utility to remind you to take break frequently
|
||||
~ to protect your eyes from eye strain.
|
||||
|
@ -39,16 +39,6 @@
|
|||
<property name="can_focus">False</property>
|
||||
<property name="row_homogeneous">True</property>
|
||||
<property name="column_homogeneous">True</property>
|
||||
<child>
|
||||
<object class="GtkLabel" id="lbl_top">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left_attach">0</property>
|
||||
<property name="top_attach">0</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkBox" id="box_center_parent">
|
||||
<property name="visible">True</property>
|
||||
|
@ -196,6 +186,45 @@
|
|||
<property name="height">2</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkBox">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="orientation">vertical</property>
|
||||
<child>
|
||||
<object class="GtkToolbar" id="toolbar">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="valign">start</property>
|
||||
<property name="toolbar_style">icons</property>
|
||||
<property name="icon_size">2</property>
|
||||
<style>
|
||||
<class name="toolbar"/>
|
||||
</style>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">False</property>
|
||||
<property name="position">0</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkLabel" id="lbl_top">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">True</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left_attach">0</property>
|
||||
<property name="top_attach">0</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
<style>
|
||||
|
|
|
@ -295,3 +295,14 @@ class Config(object):
|
|||
Set the value.
|
||||
"""
|
||||
self.__user_config[key] = value
|
||||
|
||||
|
||||
class TrayAction(object):
|
||||
"""
|
||||
Data object wrapping tooltip, icon and action.
|
||||
"""
|
||||
|
||||
def __init__(self, tooltip, icon, action):
|
||||
self.tooltip = tooltip
|
||||
self.icon = icon
|
||||
self.action = action
|
||||
|
|
|
@ -0,0 +1,16 @@
|
|||
{
|
||||
"meta": {
|
||||
"name": "Media Control",
|
||||
"description": "Pause media players from the break screen",
|
||||
"version": "0.0.1"
|
||||
},
|
||||
"dependencies": {
|
||||
"python_modules": ["dbus"],
|
||||
"shell_commands": [],
|
||||
"operating_systems": [],
|
||||
"desktop_environments": [],
|
||||
"resources": []
|
||||
},
|
||||
"settings": [],
|
||||
"break_override_allowed": true
|
||||
}
|
Binary file not shown.
After Width: | Height: | Size: 320 B |
|
@ -0,0 +1,72 @@
|
|||
#!/usr/bin/env python
|
||||
# Safe Eyes is a utility to remind you to take break frequently
|
||||
# to protect your eyes from eye strain.
|
||||
|
||||
# Copyright (C) 2019 Gobinath
|
||||
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
|
||||
# This program 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 General Public License for more details.
|
||||
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
"""
|
||||
Media Control plugin lets users to pause currntly playing media player from the break screen.
|
||||
"""
|
||||
|
||||
import logging
|
||||
import os
|
||||
import dbus
|
||||
import re
|
||||
import gi
|
||||
from safeeyes.model import TrayAction
|
||||
gi.require_version('Gtk', '3.0')
|
||||
from gi.repository import Gtk
|
||||
|
||||
|
||||
def __active_players():
|
||||
"""
|
||||
List of all media players which are playing now.
|
||||
"""
|
||||
players = []
|
||||
bus = dbus.SessionBus()
|
||||
|
||||
for service in bus.list_names():
|
||||
if re.match('org.mpris.MediaPlayer2.', service):
|
||||
player = bus.get_object(service, "/org/mpris/MediaPlayer2")
|
||||
interface = dbus.Interface(player, 'org.freedesktop.DBus.Properties')
|
||||
status = str(interface.Get('org.mpris.MediaPlayer2.Player', 'PlaybackStatus')).lower()
|
||||
if status == "playing":
|
||||
players.append(player)
|
||||
return players
|
||||
|
||||
|
||||
def __pause_players(players):
|
||||
"""
|
||||
Pause all playing media players using dbus.
|
||||
"""
|
||||
for player in players:
|
||||
interface = dbus.Interface(player, dbus_interface='org.mpris.MediaPlayer2.Player')
|
||||
interface.Pause()
|
||||
|
||||
|
||||
def init(ctx, safeeyes_config, plugin_config):
|
||||
"""
|
||||
Initialize the screensaver plugin.
|
||||
"""
|
||||
pass
|
||||
|
||||
|
||||
def get_tray_action(break_obj):
|
||||
"""
|
||||
Return TrayAction only if there is a media player currently playing.
|
||||
"""
|
||||
players = __active_players()
|
||||
if players:
|
||||
return TrayAction("Pause media", Gtk.STOCK_MEDIA_PAUSE, lambda: __pause_players(players))
|
Loading…
Reference in New Issue