C Prog to change wallpaper in every 30 seconds.

2009-12-08 1 min read Gnome

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 <stdio.h>
#include <sys/types.h>
#include <dirent.h>
#include <string.h>
#include <gconf/gconf-client.h>

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

if (argc<=1)
{
printf(&#8221;%d is argc\n&#8221;, argc);
fflush (stdout);
dp = opendir(&#8221;.&#8221;);
strcpy(dirname, &#8221;.&#8221;);
}
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(&#8221;%s \n&#8221;,buffer);
if (ep->d_type == 8) {
sprintf(buffer, &#8221;%s/%s&#8221;, dirname, ep->d_name);
printf(&#8221;%s \n&#8221;,buffer);
gconf_client_set_string(client,
&#8221;/desktop/gnome/background/picture_filename&#8221;,
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 (&#8221;Could not open directory&#8221;);

return 0;
}

comments powered by Disqus