C Prog to change wallpaper in every 30 seconds.

I wrote a good length of description on the below but somehow my browser closed without saving that. So I am just putting the program below:

#include
#include
#include
#include
#include

int main(int argc, char ** argv)
{
DIR *dp;
struct dirent *ep;
char dirname[80];
GConfClient* client;
int s;

if (argc<=1)
{
printf(\”%d is argc\\n\”, argc);
fflush (stdout);
dp = opendir(\”.\”);
strcpy(dirname, \”.\”);
}
else
{
dp = opendir(argv[1]);
strcpy(dirname, argv[1]);
}
if (argc <=2 )
s = 30;
else if ( argc >2 ) s = atoi(argv[2]);
//g_type_init();
client = gconf_client_get_default();
//client = gconf_client_get_for_engine (gconf_engine_get_default());

if (dp != NULL)
{
while (ep = readdir (dp))
{
char buffer[80];
//printf(\”%s \\n\”,buffer);
if (ep->d_type == 8) {
sprintf(buffer, \”%s/%s\”, dirname, ep->d_name);
printf(\”%s \\n\”,buffer);
gconf_client_set_string(client,
\”/desktop/gnome/background/picture_filename\”,
buffer,NULL);
//gconf_client_suggest_sync(client, NULL);
sleep(s);
}
// else if (ep->d_type == DT_DIR) main(1, ep->d_name);
}
closedir(dp);
}
else
perror (\”Could not open directory\”);

return 0;
}

About Amit Agarwal

2 Comments on “C Prog to change wallpaper in every 30 seconds.”

  1. ravikumar b

    i am executed the above program in gcc compiler, but i get following errors, please give me suggestion & how to get GConf libraray.
    error:‘GConfClient’ undeclared (first use in this function)
    error: (Each undeclared identifier is reported only once
    error: for each function it appears in.)
    13: error: ‘client’ undeclared (first use in this function)