tybg: make tybg without argument display the default wallpaper

The ty* tools need some love…
This commit is contained in:
Boris Faure 2015-02-15 20:40:54 +01:00
parent 4ea6bdb04e
commit 5b4e6de54a
1 changed files with 10 additions and 2 deletions

View File

@ -10,15 +10,23 @@ main(int argc, char **argv)
int i, perm = 0;
if (!getenv("TERMINOLOGY")) return 0;
if (argc <= 1)
if (argc > 1 &&
(!strcmp(argv[1], "-h") || !strcmp(argv[1], "--help")))
{
printf("Usage: %s [-p] FILE1 [FILE2 ...]\n"
printf("Usage: %s [-p] [FILE1 FILE2 ...]\n"
" Change the terminal background to the given file/uri\n"
" -p Make change permanent (stored in config)\n"
"\n",
argv[0]);
return 0;
}
if (argc <= 1)
{
char tbuf[32];
snprintf(tbuf, sizeof(tbuf), "%c}bt", 0x1b);
if (write(0, tbuf, strlen(tbuf) + 1) != (signed)(strlen(tbuf) + 1)) perror("write");
return 0;
}
for (i = 1; i < argc; i++)
{
char *path, buf[PATH_MAX * 2], tbuf[PATH_MAX * 3];