diff --git a/README.md b/README.md index c549c02..f480c1e 100755 --- a/README.md +++ b/README.md @@ -67,6 +67,11 @@ Server written in C, based on libevent2, OpenGL, GLFW and pthreads. It won't get make ./pixelnuke +Commandline Arguments: + +* `H`: Show help for commandline arguments +* `F[screen_id]`: Start fullscreened. You can additionally specify the fullscreen monitor by adding a screen id from 0 to 9 after the F + Keyboard controls: * `F11`: Toggle between fullscreen and windowed mode diff --git a/pixelnuke/pixelnuke.c b/pixelnuke/pixelnuke.c index d879328..bf59bc7 100644 --- a/pixelnuke/pixelnuke.c +++ b/pixelnuke/pixelnuke.c @@ -183,13 +183,37 @@ void px_on_window_close() { net_stop(); } +uint8_t args_parse_and_act(int argc, char **argv) { + for (int arg = 1; arg < argc; ++arg) { + switch (argv[arg][0]) { //compare first char of argument + case 'H': + printf("==pixelnuke commandline arguments==\nH\t\tshows this help\nF[screen_id]\tStart fullscreened. You can additionally specify the fullscreen monitor\n\t\tby adding a screen id from 0 to 9 after the F, the default is 0.\n"); + return 1; //1 means please quit + case 'F': + ; //funny C quirk not allowing lables before declarations + int target_fs_disp = 0; + if (argv[arg][1] != 0) { //if not null + int possible_num = argv[arg][1] - '0'; //convert to number if in range 0-9 + if (possible_num >= 0 && possible_num <= 9) { //check if range fits + target_fs_disp = possible_num; + } + } + printf("Fullscreening on display %d due to cmdline arg\n", target_fs_disp); + canvas_fullscreen(target_fs_disp); //fullscreen pxnuke on the target screen + return 0; + } + } + return 0; +} + int main(int argc, char **argv) { canvas_setcb_key(&px_on_key); canvas_setcb_resize(&px_on_resize); canvas_start(1024, &px_on_window_close); + if (args_parse_and_act(argc, argv)) return 0; //handle args and quit if needed + net_start(1337, &px_on_connect, &px_on_read, &px_on_close); return 0; } -