C Prog to change wallpaper in every 30 seconds.
2009-12-08
154 words
1 min read
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(”%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;
}
Related Articles:
- 2009/12/02 gnome-shell and gnome-do on F11 Screenshots
Authored By Amit Agarwal
Amit Agarwal, Linux and Photography are my hobbies.Creative Commons Attribution 4.0 International License.