Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Go fullscreen by dbus

  • Loading branch information...
commit c839888c793a267a47653a376cc1e5013e5f6960 1 parent 183c39c
@quite quite authored committed
View
3  README.rst
@@ -61,6 +61,9 @@ Currently, the following things have been changed since the Berlios's version:
This is the `refactor-launcher` branch.
+* "Daniel <quite@hack.org>" added support to toggle fullscreen status from the
+ command line.
+
Personal todo list
------------------
View
13 sonata/cli.py
@@ -22,7 +22,7 @@ def parse(self, argv):
Separates options and arguments from the given argument list,
checks their validity."""
- # toggle and popup need d-bus and don't always need gui
+ # toggle and popup and fullscreen need d-bus and don't always need gui
# version and help don't need anything and exit without gui
# hidden and visible are only applicable when gui is launched
# profile and no-start don't need anything
@@ -47,8 +47,10 @@ def parse(self, argv):
help=_("popup song notification (requires D-Bus)"))
parser.add_option("-t", "--toggle", dest="toggle",
action="store_true",
- help=_(('toggles whether the app is minimized to the '
- 'tray or visible (requires D-Bus)')))
+ help=_("toggles whether the app is minimized to the tray or visible (requires D-Bus)"))
+ parser.add_option("-f", "--fullscreen", dest="fullscreen",
+ action="store_true",
+ help=_("go fullscreen (requires D-Bus)"))
parser.add_option("-n", "--no-start", dest="start",
action="store_false",
help=_("don't start app if D-Bus commands fail"))
@@ -65,7 +67,7 @@ def parse(self, argv):
if options.toggle:
options.start_visibility = True
- if options.popup and options.start_visibility is None:
+ if options.popup or options.fullscreen and options.start_visibility is None:
options.start_visibility = False
self.start_visibility = options.start_visibility
self.arg_profile = options.profile
@@ -76,7 +78,7 @@ def parse(self, argv):
else:
parser.error(_("unknown command %s") % cmd)
- if options.toggle or options.popup:
+ if options.toggle or options.popup or options.fullscreen:
import dbus_plugin as dbus
if not dbus.using_dbus():
print _("toggle and popup options require D-Bus. Aborting.")
@@ -84,6 +86,7 @@ def parse(self, argv):
dbus.execute_remote_commands(options.toggle,
options.popup,
+ options.fullscreen,
options.start)
def execute_cmds(self):
View
14 sonata/dbus_plugin.py
@@ -12,7 +12,7 @@
Example usage:
import dbus_plugin as dbus
self.dbus_service = dbus.SonataDBus(self.dbus_show, self.dbus_toggle,
- self.dbus_popup)
+ self.dbus_popup, self.dbus_fullscreen)
dbus.start_dbus_interface(toggle_arg, popup_arg)
dbus.init_gnome_mediakeys(self.mpd_pp, self.mpd_stop, self.mpd_prev,
self.mpd_next)
@@ -106,7 +106,8 @@ def get_session_bus():
raise
-def execute_remote_commands(toggle=False, popup=False, start=False):
+def execute_remote_commands(toggle=False, popup=False, fullscreen=False,
+ start=False):
try:
bus = get_session_bus()
obj = bus.get_object('org.MPD', '/org/MPD/Sonata')
@@ -114,6 +115,8 @@ def execute_remote_commands(toggle=False, popup=False, start=False):
obj.toggle(dbus_interface='org.MPD.SonataInterface')
if popup:
obj.popup(dbus_interface='org.MPD.SonataInterface')
+ if fullscreen:
+ obj.fullscreen(dbus_interface='org.MPD.SonataInterface')
sys.exit()
except Exception:
print _("Failed to execute remote commands.")
@@ -158,10 +161,11 @@ def start_dbus_interface():
class SonataDBus(dbus.service.Object):
- def __init__(self, dbus_show, dbus_toggle, dbus_popup):
+ def __init__(self, dbus_show, dbus_toggle, dbus_popup, dbus_fullscreen):
self.dbus_show = dbus_show
self.dbus_toggle = dbus_toggle
self.dbus_popup = dbus_popup
+ self.dbus_fullscreen = dbus_fullscreen
session_bus = get_session_bus()
bus_name = dbus.service.BusName('org.MPD', bus=session_bus)
object_path = '/org/MPD/Sonata'
@@ -178,3 +182,7 @@ def toggle(self):
@dbus.service.method('org.MPD.SonataInterface')
def popup(self):
self.dbus_popup()
+
+ @dbus.service.method('org.MPD.SonataInterface')
+ def fullscreen(self):
+ self.dbus_fullscreen()
View
6 sonata/main.py
@@ -134,7 +134,8 @@ def __init__(self, args, window=None, _sugar=False):
try:
self.dbus_service = dbus.SonataDBus(self.dbus_show,
self.dbus_toggle,
- self.dbus_popup)
+ self.dbus_popup,
+ self.dbus_fullscreen)
except Exception:
pass
dbus.start_dbus_interface()
@@ -3563,5 +3564,8 @@ def dbus_toggle(self):
def dbus_popup(self):
self.on_currsong_notify(force_popup=True)
+ def dbus_fullscreen(self):
+ self.fullscreen_cover_art(None)
+
def main(self):
gtk.main()
Please sign in to comment.
Something went wrong with that request. Please try again.