View Single Post
qwerty12's Avatar
Posts: 4,274 | Thanked: 5,358 times | Joined on Sep 2007 @ Looking at y'all and sighing
#80
Originally Posted by qwerty12 View Post
Status area plugin? (Yes, I know...)
OK, it turns out I wasn't joking...

This thing is hackish, but works beautifully:

gcc --shared theme-updater-object.c `pkg-config --cflags --libs libhildondesktop-1` -Wall -o theme-updater-object.so
PHP Code:
/*
 * theme-updater-object
 *
 * Copyright (C) 2010 Faheem Pervez <Don't really feel like spam on this lovely morning>. All rights reserved.
 *
 * Licensed under:
 *
 *             DO WHAT THE **** YOU WANT TO PUBLIC LICENSE
 *                   Version 2, December 2004
 *
 *    Copyright (C) 2004 Sam Hocevar
 *    14 rue de Plaisance, 75014 Paris, France
 *    Everyone is permitted to copy and distribute verbatim or modified
 *    copies of this license document, and changing it is allowed as long
 *    as the name is changed.
 *
 *           DO WHAT THE **** YOU WANT TO PUBLIC LICENSE
 *  TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
 *
 *     0. You just DO WHAT THE **** YOU WANT TO. 
 *
 * This program is free software. It comes without any warranty, to
 * the extent permitted by applicable law. You can redistribute it
 * and/or modify it under the terms of the Do What The **** You Want
 * To Public License, Version 2, as published by Sam Hocevar. See
 * http://sam.zoy.org/wtfpl/COPYING for more details.
 *
 */

/* theme-updater-object.c */

#include <stdlib.h>
#include <glib.h>
#include <glib-object.h>
#include <libhildondesktop/libhildondesktop.h>

typedef struct
{
    
HDStatusPluginItem parent;
ThemeUpdaterObject;

typedef struct
{
    
HDStatusPluginItemClass parent_class;
ThemeUpdaterObjectClass;

HD_DEFINE_PLUGIN_MODULE (ThemeUpdaterObjecttheme_updater_objectHD_TYPE_STATUS_PLUGIN_ITEM)

static 
void theme_updater_object_class_init (ThemeUpdaterObjectClass *klass G_GNUC_UNUSED)
{
}

static 
void theme_updater_object_class_finalize (ThemeUpdaterObjectClass *klass G_GNUC_UNUSED)
{
}

static 
void on_theme_changed (GObject *obj G_GNUC_UNUSEDGParamSpec *pspec G_GNUC_UNUSEDgpointer user_data G_GNUC_UNUSED)
{
    static 
gboolean first_emission TRUE/* We recieve notification of the bloody theme changing twice! */

    
first_emission = !first_emission;

    if (!
first_emission)
        return;

    if (!
system ("pidof catorise"))
        return;

    
g_spawn_command_line_async ("/usr/bin/sudo /opt/catorise/catorise"NULL);
}

static 
void theme_updater_object_init (ThemeUpdaterObject *plugin G_GNUC_UNUSED)
{
    
g_signal_connect (G_OBJECT (gtk_settings_get_default ()), "notify::gtk-theme-name"G_CALLBACK (on_theme_changed), NULL);

As you will have realised, this does install as a status area plugin (which is why I derive from HDStatusPluginItem, instead) but displays nothing there. For this to work:

/etc/sudoers.d/catorise.sudoers:
Code:
user ALL = NOPASSWD: /opt/catorise/catorise
And then just do a plain "update-sudoers" as root.

Last edited by qwerty12; 2010-01-17 at 11:45.
 

The Following User Says Thank You to qwerty12 For This Useful Post: