From 3ab6a0d6684a4b7fda079ccc7e0d3583c0814e4f Mon Sep 17 00:00:00 2001 From: Scoopta Date: Sat, 18 Jul 2020 13:32:05 -0700 Subject: [PATCH] Added --monitor --- man/wofi.1 | 3 +++ man/wofi.5 | 5 ++++- src/main.c | 16 +++++++++++++++- src/wofi.c | 8 ++++++++ 4 files changed, 30 insertions(+), 2 deletions(-) diff --git a/man/wofi.1 b/man/wofi.1 index 9212676..a4039ba 100644 --- a/man/wofi.1 +++ b/man/wofi.1 @@ -109,6 +109,9 @@ Instructs wofi to use the dark variant of the current GTK theme, if available. .TP .B \-Q, \-\-search Specifies something to search for immediately on opening +.TP +.B \-o, \-\-monitor +Sets the monitor to open on .SH CONFIGURATION Wofi has 3 main files used for configuration. All files are completely optional. diff --git a/man/wofi.5 b/man/wofi.5 index 3d1ce98..6e77e68 100644 --- a/man/wofi.5 +++ b/man/wofi.5 @@ -103,9 +103,12 @@ Specifies the default sort order. There are currently two orders, default and al .B gtk_dark=\fIBOOL\fR If true, instructs wofi to use the dark variant of the current GTK theme (if available). Default is false. .TP -.B search=\fISTRING\f +.B search=\fISTRING\fR Specifies something to search for immediately on opening .TP +.B monitor=\fISTRING\fR +Sets the monitor to open on +.TP .B orientation=\fIORIENTATION\fR Specifies the orientation, it can be either horizontal or vertical, default is vertical. .TP diff --git a/src/main.c b/src/main.c index 582ec10..6c7843d 100644 --- a/src/main.c +++ b/src/main.c @@ -95,6 +95,7 @@ static void print_usage(char** argv) { printf("--sort-order\t-O\tSets the sort order\n"); printf("--gtk-dark\t-G\tUses the dark variant of the current GTK theme\n"); printf("--search\t-Q\tSearch for something immediately on open\n"); + printf("--monitor\t-o\tSets the monitor to open on\n"); exit(0); } @@ -414,6 +415,12 @@ int main(int argc, char** argv) { .flag = NULL, .val = 'Q' }, + { + .name = "monitor", + .has_arg = required_argument, + .flag = NULL, + .val = 'o' + }, { .name = NULL, .has_arg = 0, @@ -449,13 +456,14 @@ int main(int argc, char** argv) { char* sort_order = NULL; char* gtk_dark = NULL; char* search = NULL; + char* monitor = NULL; struct wl_list options; wl_list_init(&options); struct option_node* node; int opt; - while((opt = getopt_long(argc, argv, "hfc:s:C:dS:W:H:p:x:y:nImk:t:P::ebM:iqvl:aD:L:w:O:GQ:", opts, NULL)) != -1) { + while((opt = getopt_long(argc, argv, "hfc:s:C:dS:W:H:p:x:y:nImk:t:P::ebM:iqvl:aD:L:w:O:GQ:o:", opts, NULL)) != -1) { switch(opt) { case 'h': print_usage(argv); @@ -561,6 +569,9 @@ int main(int argc, char** argv) { case 'Q': search = optarg; break; + case 'o': + monitor = optarg; + break; } } @@ -747,6 +758,9 @@ int main(int argc, char** argv) { if(search != NULL) { map_put(config, "search", search); } + if(monitor != NULL) { + map_put(config, "monitor", monitor); + } struct sigaction sigact = {0}; sigact.sa_handler = sig; diff --git a/src/wofi.c b/src/wofi.c index 0dee82c..8d68fb5 100644 --- a/src/wofi.c +++ b/src/wofi.c @@ -1617,6 +1617,7 @@ void wofi_init(struct map* _config) { bool hide_search = strcmp(config_get(config, "hide_search", "false"), "true") == 0; char* search = map_get(config, "search"); dynamic_lines = strcmp(config_get(config, "dynamic_lines", "false"), "true") == 0; + char* monitor = map_get(config, "monitor"); keys = map_init_void(); @@ -1713,6 +1714,13 @@ void wofi_init(struct map* _config) { break; } } + } else if(monitor != NULL) { + wl_list_for_each(node, &outputs, link) { + if(strcmp(monitor, node->name) == 0) { + output = node->output; + break; + } + } } GdkWindow* gdk_win = gtk_widget_get_window(window);