Xfce Wiki

Sub domains
 

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
midori:webmedia_now-playing [2015/01/24 00:46] – [Using Shell script] jamesaxlmidori:webmedia_now-playing [2015/02/01 13:44] (current) – [BIG THanks] jamesaxl
Line 31: Line 31:
 echo "You are now playing: $VideoTitle - $VideoUri" echo "You are now playing: $VideoTitle - $VideoUri"
 </code> </code>
-As you see **mediaHerald** is a Dbus service that extension created to store video's title and uri.\\ +As you see **mediaHerald** is a Dbus service that our extension created to store video's title and uri.\\ 
-Let's do an example you first open [[https://www.youtube.com/watch?v=O2cebaY5Wlc]] and run our script shell, the result is:+Let's do an example you should first open [[https://www.youtube.com/watch?v=O2cebaY5Wlc]] and run our shell script, the result is:
 <code> <code>
 You are now playing:  - ‪Midori 0.5.8 : A Fast and Lightweight Web Browser For Linux Mint - YouTube You are now playing:  - ‪Midori 0.5.8 : A Fast and Lightweight Web Browser For Linux Mint - YouTube
Line 77: Line 77:
 You are playing Midori 0.5.8 : A Fast and Lightweight Web Browser For Linux Mint - YouTube, follow me https://www.youtube.com/watch?v=O2cebaY5Wlc You are playing Midori 0.5.8 : A Fast and Lightweight Web Browser For Linux Mint - YouTube, follow me https://www.youtube.com/watch?v=O2cebaY5Wlc
 </code> </code>
 +**C with Glib and Gio Headache Please LOL**
 +<code>
 +#include <glib.h>
 +#include <gio/gio.h>
 +
 +gchar* get_video_title(GDBusProxy *proxy) {
 + GVariant *_inner_reply;
 + _inner_reply = g_dbus_proxy_get_cached_property (proxy, "VideoTitle");
 + gchar* _result;
 + if (!_inner_reply) {
 + GVariant *_arguments;
 + GVariant *_reply;
 + GVariantBuilder _arguments_builder;
 + g_variant_builder_init (&_arguments_builder, G_VARIANT_TYPE_TUPLE);
 + g_variant_builder_add_value (&_arguments_builder, g_variant_new_string ("org.midori.mediaHerald"));
 + g_variant_builder_add_value (&_arguments_builder, g_variant_new_string ("VideoTitle"));
 + _arguments = g_variant_builder_end (&_arguments_builder);
 + _reply = g_dbus_proxy_call_sync (proxy, "org.freedesktop.DBus.Properties.Get", _arguments, G_DBUS_CALL_FLAGS_NONE, -1, NULL, NULL);
 + if (!_reply) {
 + return NULL;
 + }
 + g_variant_get (_reply, "(v)", &_inner_reply);
 + g_variant_unref (_reply);
 + }
 + _result = g_variant_dup_string (_inner_reply, NULL);
 + g_variant_unref (_inner_reply);
 + return _result;
 +
 +}
 +
 +gchar* get_video_uri(GDBusProxy *proxy) {
 + GVariant *_inner_reply;
 + _inner_reply = g_dbus_proxy_get_cached_property (proxy, "VideoUri");
 + gchar* _result;
 + if (!_inner_reply) {
 + GVariant *_arguments;
 + GVariant *_reply;
 + GVariantBuilder _arguments_builder;
 + g_variant_builder_init (&_arguments_builder, G_VARIANT_TYPE_TUPLE);
 + g_variant_builder_add_value (&_arguments_builder, g_variant_new_string ("org.midori.mediaHerald"));
 + g_variant_builder_add_value (&_arguments_builder, g_variant_new_string ("VideoUri"));
 + _arguments = g_variant_builder_end (&_arguments_builder);
 + _reply = g_dbus_proxy_call_sync (proxy, "org.freedesktop.DBus.Properties.Get", _arguments, G_DBUS_CALL_FLAGS_NONE, -1, NULL, NULL);
 + if (!_reply) {
 + return NULL;
 + }
 + g_variant_get (_reply, "(v)", &_inner_reply);
 + g_variant_unref (_reply);
 + }
 + _result = g_variant_dup_string (_inner_reply, NULL);
 + g_variant_unref (_inner_reply);
 + return _result;
 +}
 +
 +
 +int main(void) {
 + GError *error = NULL;
 + GDBusConnection *bus;
 + GDBusProxy *proxy;
 + bus = g_bus_get_sync(G_BUS_TYPE_SESSION, NULL, &error);
 + if (!bus) {
 + g_warning("Failed to connect to session bus: %s", error->message);
 + g_error_free(error);
 + return 1;
 + }
 + proxy  = g_dbus_proxy_new_sync (bus,
 +                       G_DBUS_PROXY_FLAGS_NONE,
 +                       NULL,
 +                       "org.midori.mediaHerald",
 +                       "/org/midori/mediaHerald",
 +                       "org.freedesktop.DBus.Properties",
 +                       NULL,
 +                       &error);
 +    gchar* title = get_video_title(proxy);
 +    gchar* uri = get_video_uri(proxy);
 + g_printf("you are now watching  %s - %s\n", title, uri);
 + return 0;
 +}
 +
 +</code>
 +
 +MakeFile
 +<code>
 +pkg_packages := glib-2.0 gio-2.0
 +CC=gcc
 +PKG_CFLAGS  := $(shell pkg-config --cflags $(pkg_packages))
 +PKG_LDFLAGS := $(shell pkg-config --libs $(pkg_packages))
 +
 +CFLAGS  := $(PKG_CFLAGS) $(ADD_CFLAGS) $(CFLAGS)
 +LDFLAGS := $(PKG_LDFLAGS) $(LDFLAGS)
 +
 +targets = midori-example
 +
 +.PHONY: all clean
 +all: $(targets)
 +
 +dbus-example: midori-example.c
 + $(CC) $(CFLAGS) $< -o $@ $(LDFLAGS)
 +
 +clean:
 + $(RM) $(targets)
 +</code>
 +
 +**Result:**\\
 +<code>
 +you are now watching  ‪Installing Linux on Tegra TK1 - http://coub.com/view/44obz
 +</code>
 +
 +====== BIG THanks ======
 +**kalikiana **: The developer of MIDORI, code helper.\\
 +**pfor**: Code helper.\\
 +**A.R**(owner of the quote): Earth and all that is in it, with knowledge we protect it. And the best of mankind knowledge makes him and he makes it.
 +