forked from virt-mirrors/wayneko
add option to set what neko is doing at startup
This commit is contained in:
parent
d3ce51a8ba
commit
5777bf2670
2 changed files with 32 additions and 0 deletions
25
wayneko.c
25
wayneko.c
|
@ -35,6 +35,7 @@ const char usage[] =
|
|||
" --idle-sleep seconds\n"
|
||||
" --sleep-phase seconds-seconds\n"
|
||||
" --awake-phase seconds-seconds\n"
|
||||
" --currently awake|asleep|random\n"
|
||||
" --layer background|bottom|top|overlay\n"
|
||||
" --survive-close\n"
|
||||
"\n";
|
||||
|
@ -1440,6 +1441,7 @@ int main (int argc, char *argv[])
|
|||
{
|
||||
char* a = get_argument(argc, argv, &i);
|
||||
char* b = a;
|
||||
if (a == NULL) return EXIT_FAILURE;
|
||||
|
||||
while (*b != '-' && *b != 0) b++;
|
||||
if (*b == 0) {
|
||||
|
@ -1463,6 +1465,7 @@ int main (int argc, char *argv[])
|
|||
{
|
||||
char* a = get_argument(argc, argv, &i);
|
||||
char* b = a;
|
||||
if (a == NULL) return EXIT_FAILURE;
|
||||
|
||||
while (*b != '-' && *b != 0) b++;
|
||||
if (*b == 0) {
|
||||
|
@ -1482,6 +1485,28 @@ int main (int argc, char *argv[])
|
|||
return EXIT_FAILURE;
|
||||
}
|
||||
}
|
||||
else if ( strcmp(argv[i], "--currently") == 0 )
|
||||
{
|
||||
const char *t = get_argument(argc, argv, &i);
|
||||
if ( t == NULL )
|
||||
return EXIT_FAILURE;
|
||||
|
||||
/* yes, the phases are swapped because the first thing that will happen is a phase change */
|
||||
if ( strcmp(t, "awake") == 0 )
|
||||
current_phase = PHASE_SLEEP;
|
||||
else if ( strcmp(t, "asleep") == 0 )
|
||||
current_phase = PHASE_AWAKE;
|
||||
else if ( strcmp(t, "random") == 0 )
|
||||
current_phase = rand() % 2 == 0 ? PHASE_SLEEP : PHASE_AWAKE;
|
||||
else
|
||||
{
|
||||
fprintf(stderr, "ERROR: Unknown argument '%s' for flag '--currently'.\n", t);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
if (current_phase == PHASE_AWAKE)
|
||||
current_neko = NEKO_SLEEP_1;
|
||||
}
|
||||
else
|
||||
{
|
||||
fprintf(stderr, "ERROR: Unknown option: %s\n", argv[i]);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue