Added --monitor

This commit is contained in:
Scoopta 2020-07-18 13:32:05 -07:00
parent e7672ff694
commit 3ab6a0d668
4 changed files with 30 additions and 2 deletions

View File

@ -109,6 +109,9 @@ Instructs wofi to use the dark variant of the current GTK theme, if available.
.TP .TP
.B \-Q, \-\-search .B \-Q, \-\-search
Specifies something to search for immediately on opening Specifies something to search for immediately on opening
.TP
.B \-o, \-\-monitor
Sets the monitor to open on
.SH CONFIGURATION .SH CONFIGURATION
Wofi has 3 main files used for configuration. All files are completely optional. Wofi has 3 main files used for configuration. All files are completely optional.

View File

@ -103,9 +103,12 @@ Specifies the default sort order. There are currently two orders, default and al
.B gtk_dark=\fIBOOL\fR .B gtk_dark=\fIBOOL\fR
If true, instructs wofi to use the dark variant of the current GTK theme (if available). Default is false. If true, instructs wofi to use the dark variant of the current GTK theme (if available). Default is false.
.TP .TP
.B search=\fISTRING\f .B search=\fISTRING\fR
Specifies something to search for immediately on opening Specifies something to search for immediately on opening
.TP .TP
.B monitor=\fISTRING\fR
Sets the monitor to open on
.TP
.B orientation=\fIORIENTATION\fR .B orientation=\fIORIENTATION\fR
Specifies the orientation, it can be either horizontal or vertical, default is vertical. Specifies the orientation, it can be either horizontal or vertical, default is vertical.
.TP .TP

View File

@ -95,6 +95,7 @@ static void print_usage(char** argv) {
printf("--sort-order\t-O\tSets the sort order\n"); 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("--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("--search\t-Q\tSearch for something immediately on open\n");
printf("--monitor\t-o\tSets the monitor to open on\n");
exit(0); exit(0);
} }
@ -414,6 +415,12 @@ int main(int argc, char** argv) {
.flag = NULL, .flag = NULL,
.val = 'Q' .val = 'Q'
}, },
{
.name = "monitor",
.has_arg = required_argument,
.flag = NULL,
.val = 'o'
},
{ {
.name = NULL, .name = NULL,
.has_arg = 0, .has_arg = 0,
@ -449,13 +456,14 @@ int main(int argc, char** argv) {
char* sort_order = NULL; char* sort_order = NULL;
char* gtk_dark = NULL; char* gtk_dark = NULL;
char* search = NULL; char* search = NULL;
char* monitor = NULL;
struct wl_list options; struct wl_list options;
wl_list_init(&options); wl_list_init(&options);
struct option_node* node; struct option_node* node;
int opt; 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) { switch(opt) {
case 'h': case 'h':
print_usage(argv); print_usage(argv);
@ -561,6 +569,9 @@ int main(int argc, char** argv) {
case 'Q': case 'Q':
search = optarg; search = optarg;
break; break;
case 'o':
monitor = optarg;
break;
} }
} }
@ -747,6 +758,9 @@ int main(int argc, char** argv) {
if(search != NULL) { if(search != NULL) {
map_put(config, "search", search); map_put(config, "search", search);
} }
if(monitor != NULL) {
map_put(config, "monitor", monitor);
}
struct sigaction sigact = {0}; struct sigaction sigact = {0};
sigact.sa_handler = sig; sigact.sa_handler = sig;

View File

@ -1617,6 +1617,7 @@ void wofi_init(struct map* _config) {
bool hide_search = strcmp(config_get(config, "hide_search", "false"), "true") == 0; bool hide_search = strcmp(config_get(config, "hide_search", "false"), "true") == 0;
char* search = map_get(config, "search"); char* search = map_get(config, "search");
dynamic_lines = strcmp(config_get(config, "dynamic_lines", "false"), "true") == 0; dynamic_lines = strcmp(config_get(config, "dynamic_lines", "false"), "true") == 0;
char* monitor = map_get(config, "monitor");
keys = map_init_void(); keys = map_init_void();
@ -1713,6 +1714,13 @@ void wofi_init(struct map* _config) {
break; 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); GdkWindow* gdk_win = gtk_widget_get_window(window);