コード例 #1
0
ファイル: systray.cpp プロジェクト: kehugter/Yarock
/* hack for ubuntu unity systray panel whitelist (base on clementine work) */
void SysTray::ubuntu_unity_hack()
{
    // Check if we're on Ubuntu first.
    QFile lsb_release("/etc/lsb-release");
    if (lsb_release.open(QIODevice::ReadOnly)) {
        QByteArray data = lsb_release.readAll();
        if (!data.contains("DISTRIB_ID=Ubuntu")) {
            // It's not Ubuntu - don't do anything.
            return;
        }
    }

    // Get the systray whitelist from gsettings.  If this fails we're probably
    // not running on a system with unity
    QProcess* get = new QProcess(this);
    connect(get, SIGNAL(finished(int)), SLOT(ubuntu_unity_hack_getFinished(int)));
    connect(get, SIGNAL(error(QProcess::ProcessError)), SLOT(ubuntu_unity_hack_getError()));
    
    get->start(kGSettingsFileName, QStringList()
             << "get" << kUnityPanel << kUnitySystrayWhitelist);
}
コード例 #2
0
ファイル: misc.c プロジェクト: bpkroth/cfengine2
int lsb_version(void)
{
#define LSB_RELEASE_COMMAND "lsb_release"

char classname[CF_MAXVARSIZE];
char *distrib  = NULL;
char *release  = NULL;
char *codename = NULL;
int major = 0;
int minor = 0;

char *path, *dir, *rest;
struct stat statbuf;

path = rest = strdup(getenv("PATH"));

if (strlen(path) == 0)
   {
   return 1;
   }

for (; dir = strsep(&rest, ":") ;)
    {
    snprintf(VBUFF, CF_BUFSIZE, "%s/" LSB_RELEASE_COMMAND, dir);
    if (stat(VBUFF,&statbuf) != -1)
        {
        free(path);
        path = strdup(VBUFF);

        Verbose("\nThis appears to be a LSB compliant system.\n");
        AddClassToHeap("lsb_compliant");
        break;
        }
    }

if (!dir)
    {
    free(path);
    return 1;
    }

if ((distrib  = lsb_release(path, "--id")) != NULL)
    {
    snprintf(classname, CF_MAXVARSIZE, "%s", distrib);
    AddClassToHeap(classname);

    if ((codename = lsb_release(path, "--codename")) != NULL)
        {
        snprintf(classname, CF_MAXVARSIZE, "%s_%s", distrib, codename);
        AddClassToHeap(classname);
        }

    if ((release  = lsb_release(path, "--release")) != NULL)
        {
        switch (sscanf(release, "%d.%d\n", &major, &minor))
            {
            case 2:
                snprintf(classname, CF_MAXVARSIZE, "%s_%u_%u", distrib, major, minor);
                AddClassToHeap(classname);
            case 1:
                snprintf(classname, CF_MAXVARSIZE, "%s_%u", distrib, major);
                AddClassToHeap(classname);
            }
        }

    free(path);
    return 0;
    }
else
    {
    free(path);
    return 2;
    }
}