the phrygian cap


luisbg

@luisbg

luis@debethencourt.com



Ohloh profile for Luis de Bethencourt
Blogalia




<Agosto 2019
Lu Ma Mi Ju Vi Sa Do
      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  
             

Creative Commons License


planet gnome
planet ubuntu
alberto ruiz
andy wingo
jeff fortin
slomo's blog
jan schmidt
vincent's random waffle



"all religions, arts and sciences are branches of the same tree. all these aspirations are directed toward ennobling man's life, lifting it from the sphere of mere physical existence and leading the individual towards freedom." albert einstein

HOWTO: Disable the Gnome screensaver from your application



A broad group of applications have some sort of display running without user feedback, an obvious example are multimedia applications. For instance the user of a video editor is viewing his work in-progress, in such use cases it would be frustrating if the screensaver kicked in, blocking the video. So how do we disable the screensaver temporarily from our application?

Recently there have been some changes around GNOME's screensaver and which component handles the requests to disable it. It used to be gnome-screensaver directly but now it is managed by gnome-session. What you need to do is simply send the DBus message "Inhibit" to org.gnome.SessionManager, and later send "Uninhibit" to reactivate it.

Sebastian Dröge implemented this in snappy, basing his code heavily in that of totem. We have the following function that depending on the second argument, disables or enables the screensaver:

static void
screensaver_inhibit_dbus (ScreenSaver * screensaver, gboolean inhibit)
{
  if (!screensaver->gs_proxy)
    return;

  if (inhibit) {
    guint xid;

    xid = screensaver->window;

    g_dbus_proxy_call (screensaver->gs_proxy,
        "Inhibit",
        g_variant_new ("(susu)",
            g_get_application_name (),
            xid,
            REASON,
            GS_NO_IDLE_FLAG),
        G_DBUS_CALL_FLAGS_NO_AUTO_START, -1, NULL, on_inhibit_cb, screensaver);
  } else {
    if (screensaver->cookie > 0) {
      g_dbus_proxy_call (screensaver->gs_proxy,
          "Uninhibit",
          g_variant_new ("(u)", screensaver->cookie),
          G_DBUS_CALL_FLAGS_NO_AUTO_START, -1, NULL, on_uninhibit_cb,
          screensaver);
    }
  }
}


When the "Inhibit" request is satisfied asynchronously, the on_inhibit_cb () callback is called. This checks if the operation happened succesfully, and saves the cookie that we see used above when uninhibiting. gnome-session uses this cookie to track the disabling and enabling of the screensaver by multiple applications. If two applications request a screensaver disable and later only one has enabled it, it will still wait for the second one before doing so.

static void
on_inhibit_cb (GObject * source_object, GAsyncResult * res, gpointer user_data)
{
  GDBusProxy *proxy = G_DBUS_PROXY (source_object);
  ScreenSaver *screensaver = (ScreenSaver *) user_data;
  GVariant *value;
  GError *error = NULL;

  value = g_dbus_proxy_call_finish (proxy, res, &error);
  if (!value) {
    g_warning ("Problem inhibiting the screensaver: %s", error->message);
    g_error_free (error);
    return;
  }

  /* save the cookie */
  if (g_variant_is_of_type (value, G_VARIANT_TYPE ("(u)")))
    g_variant_get (value, "(u)", &screensaver->cookie);
  else
    screensaver->cookie = 0;

  g_variant_unref (value);
}


on_uninhibit_cb () does the reverse, checks if operation finished succesfully and it clears the cookie.

For those who want the whole picture... getting the GDBusProxy (screensaver->gs_proxy) which needs to be set before running the proxy call in screensaver_inhibit_dbus () above, is set by:

static void
screensaver_init_dbus (ScreenSaver * screensaver)
{
  g_dbus_proxy_new_for_bus (G_BUS_TYPE_SESSION,
      G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES,
      NULL,
      GS_SERVICE,
      GS_PATH, GS_INTERFACE, NULL, screensaver_dbus_proxy_new_cb, screensaver);
}


The screensaver_dbus_proxy_new_cb callback checks the operation and then runs:
screensaver->gs_proxy = g_dbus_proxy_new_for_bus_finish (result, NULL);

Here is the full code if you want to take a look at it.


pd: Soon part II, the XTst variant of screensaver disabling for x11.

15 Comentarios


Referencias (TrackBacks)

URL de trackback de esta historia http://luisbg.blogalia.com//trackbacks/69989

Comentarios

1
De: Aaron Seigo Fecha: 2011-07-12 09:56

This also works with the screen saver in a KDE session using the org.freedesktop.ScreenSaver service which is under object /ScreenSaver. We harmonized this DBus interface a few years back, and hopefully the GNOME implementation advertises with the same service+object address on the session bus.



2
De: Anon Fecha: 2011-07-12 10:39

Is this change really recent? - https://bugzilla.gnome.org/show_bug.cgi?id=472812



3
De: luisbg Fecha: 2011-07-12 10:55

Aaron: cool! good to know. I should add that to snappy soon.

Anon: there have been multiple changes AFAIK.



4
De: Anon Fecha: 2011-07-12 15:25

PS: Aaron has raised a familiar political point which boils down to "there is no way to use one command to control the screensaver of KDE and GNOME (outside something like xdg-screensaver).



5
De: Robbie Koffler Fecha: 2018-06-21 15:25


Read More Camp Apk Android Games APK



6
De: Dylan Hanson Fecha: 2018-07-18 07:57

A historical patch of the country is studied for the identification of the mistakes. The arrangement of the superior writing services is done for the injunction for all individuals on the phase of the right and fundamental matter.



7
De: Anna Shetty Fecha: 2018-09-21 05:09

I agree with what you share. It will be very useful information for everyone. Hope your next posts are as well
run 3 cool math



8
De: Ema Fecha: 2018-10-13 13:21

Interesting to know about gnome-screensaver and it is a new screensaver that can replace xscreensaver. This is designed to integrate well with the desktop and provide a control interface that is desktop neutral. Thanks for this article. directv family package



9
De: wiliam Fecha: 2018-10-21 16:22

watches for women
watches for men
mens watches



10
De: Hotman Naiborhu Fecha: 2018-12-20 05:05

wa dia biasanya pergi tidur larut, sudah tertidur, dalink 8
jual baja h beam
jual pipa boiler
jual plat abrex 400
jual plat asme516 grade70
jual plat astm a285 c
jual plat astm516 70
jual plat boiler
jual plat hardox
jual plat hb 400
jual plat high strenght
jual plat high tensile sm490 yb
Pabrik besi beton jcac
Pabrik besi hollow
Pabrik besi hollow
Toko besi wf
Toko besi unp
undangan pernikahan batik
Pabrik Bondek Cor
Pabrik Wiremesh Besi baja
Pabrik plat kapal besi baja
Pabrik besi beton interworld steel is
Distributor pipa besi
Distributor pipa besi
Toko wiremesh
Toko besi siku
undangan pernikahan murah
Pabrik Atap Spandek Sni
Distributor Besi Siku Baja
Distributor besi siku baja
Pabrik besi beton gunung garuda
Harga pipa besi
Harga pipa besi
Toko besi unp
Toko Plat besi plat kapal
undangan pernikahan online
Pabrik Plat Bordes Kembang
Supplier Besi Siku Baja
Harga besi siku baja
Pabrik besi beton delcoprima
Jual pipa besi
Jual pipa besi
Toko besi cnp
Toko besi h beam baja
undangan pernikahan anti mainstream
Pabrik Plat Besi Hitam
Agen Besi Siku Baja
Jual besi siku baja
Pabrik besi beton cakra steel cs
Supplier pipa besi
Supplier pipa besi
Toko besi hollow
Toko besi cnp
undangan pernikahan cantik dan murah
Pabrik Plat Kapal Bki Krakatau Steel
Toko Besi Siku Baja
Supplier besi siku baja
Pabrik besi beton bjku
Toko pipa besi
Toko pipa besi
Toko besi beton Sni Ulir Polos
www.gudangbesibaja.com
undangan pernikahan unik
Pabrik Jual Besi Siku Baja
Jual Besi Siku Baja
Toko besi siku baja
Pabrik besi beton Sni Ulir Polos
Agen pipa besi
Agen pipa besi
ironsteelcenter.com
Supplier besi Wf Baja
undangan pernikahan yang unik
Pabrik Besi Unp Baja Profil Kanal
Harga Besi Siku Baja
Agen besi siku baja
Pabrik besi beton ais
Pabrik pipa besi
Pabrik pipa besi
Supplier stainless steel
Supplier bondek
undangan pernikahan lucu
Jual Besi Siku Baja
Toko besi siku baja
Pabrik besi beton Sni Ulir Polos
Agen pipa besi
Agen pipa besi
ironsteelcenter.com
Supplier besi Wf Baja
undangan pernikahan yang unik
Pabrik Besi Unp Baja Profil Kanal
Harga Besi Siku Baja
Agen besi siku baja
Pabrik besi beton ais
Pabrik pipa besi
Pabrik pipa besi
Supplier stainless steel
Supplier bondek
undangan pernikahan lucu
Pabrik Besi Cnp Profil Baja Gording
Pabrik Besi Siku Baja
Pabrik besi siku baja
Pabrik besi beton
Distributor sch 40
Distributor sch 40
Supplier atap spandek
Supplier wiremesh
undangan pernikahan bunga
Pabrik Besi Hollow
Distributor Besi Unp Baja
Distributor besi wf
Harga sch 40
Harga sch 40
Supplier baja ringan
Supplier pipa besi baja sch 40 sch 80
undangan pernikahan islami



11
De: web development company in patna Fecha: 2019-02-28 17:31

Web Ocean Design is the best IT services provider for complete mobile and web application development. The young development company based in Bihar, India, owned and managed by Vicky who have a good amount of experience in Information Technology, Management and other related fields. We provide technical and creative services ranging from Internet Marketing to Communication maneuver. We are also skilled in website development which includes brand promotion, web designing and software development.

||website design company in patna||
||website development company in patna||
||website development in patna||

||web design company in patna||
||web development company in patna||
||website design in patna||

||website design patna||
||seo company in patna||
||seo company in bihar||

||best seo company in patna||
||digital marketing company in patna||
||best website design company in patna l,||

||affordable seo service in patna||
||website optimization in patna||
||educational internet marketing company patna||

||social media marketing company patna||
||real estate seo company in patna||
||ecommerce seo company patna||



12
De: jaipur call girls Fecha: 2019-03-14 12:10

===========
sehzadi
===========
||Jaipur Escorts||
||Jaipur Call girls||
||Escort service in Jaipur||

===========
sweeti sinha
===========
||Jaipur Escorts||
||Escorts in Jaipur||
||Escort Services in Jaipur||

===========
saumyaa
===========

||Call girls in Jaipur||
||Jaipur Call girls||
||Jaipur escorts||

===========================================================================================================================

===========
sehzadi
===========
||Independent escorts in Jaipur
||Escort services in Jaipur
||Escorts in Jaipur

===========
sweeti sinha
===========
||Jaipur Escort||
||Escort in Jaipur||
||Escort service in Jaipur||

===========
saumyaa
===========
||Jaipur escort||
||Escorts in Jaipur||
||College escorts in Jaipur||

===========================================================================================================================
===========
sehzadi
===========
||College call girls in Jaipur||
||Call girls in Jaipur||
||Jaipur Escorts||
===========
sweeti sinha
===========
||Jaipur Call girls||
||Call Girls in Jaipur||
||Jaipur escorts||
===========
saumyaa
===========
||Bollywood escorts in Jaipur||
||Celebrity Escorts in Jaipur||
||Air hostess escorts in Jaipur||

===========================================================================================================================

==============
Jaipur escorts
==============

||College escorts in Jaipur
||Escort services in jaipur
||Escorts in jaipur

||Escort service in Jaipur
||Escorts in Jaipur
||Jaipur Escort service


||Call girls in Jaipur||
||Jaipur escorts||
||Call girl in Jaipur||

===============================================================================================================
===========
shreya-singh
===========
||Jaipur escorts||
||Escort service in Jaipur||
||Russian escorts in Jaipur||

||Jaipur call girl||
||Jaipur escorts||
||Model escorts in Jaipur||

||Air hostess escorts in Jaipur||
||Housewife escorts in Jaipur||
||College call girls in Jaipur||



===========
shreya-singh
===========
||Escorts in Jaipur||
||Jaipur call girls||
||Escort service in Jaipur||

||Call girls in Jaipur||
||Celebrity escorts in Jaipur||
||Call girl in Jaipur||



13
De: jaipur call girls Fecha: 2019-03-14 12:25

||Call girls in Faridabad||
||escorts in Faridabad||
||Faridabad escorts||

||Faridabad escorts service||
||escort service in Faridabad||
||call girl Faridabad||

||Faridabad call girls||
||Faridabad escort service||
||independent escorts in Faridabad||

||independent call girls in Faridabad||
||high profile call girls in Faridabad||
||Russian escorts in Faridabad||

||college call girls in Faridabad||
||college escorts in Faridabad||
||air hostess escorts in Faridabad||

||escort agency in Faridabad||
||vip russian escorts in faridabad||
|| vip escorts services in faridabad||



14
De: event planner in delhi Fecha: 2019-03-26 12:45

manpowers in delhi
event planner in delhi
promoters in delhi

crew members in delhi
event planner company in delhi
event managers in delhi

manpower provider in delhi
best manpower provider in delhi
marriage event planner in delhi

===========================================

wedding planner in delhi
birthday planner in delhi
manpower resourses in delhi

auto expo 2019
manpower in delhi
Fabrication in delhi

decors in delhi
events in delhi
manpower resourses in delhi

===========================================
promoters in delhi
part time jobs in delhi
artist in delhi

dance troups in delhi
hostess in delhi
promoters in delhi

hotographers in delhi
images of auto expo 2019
stage events in delhi



15
De: Couritto Fecha: 2019-04-03 22:10

امتع واجمل واحلى شرطة العاب التي توفر لكم متعة كبيرة من دون حدود مع بذل المزيد من التفكير لكي تحققوا الأفضل دائما. نستعرض عليكم كذلك العاب الشرطة حقيقية تناسب جميع الأطفال.



Nombre
Correo-e
URL
Dirección IP: 3.227.233.6 (2648df40e1)
Comentario
¿Cuánto es: diez mil + uno?

©2007-2015 luis de bethencourt guimera
powered by Blogalia