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
.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.

View File

@ -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

View File

@ -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;

View File

@ -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);