diff options
| -rw-r--r-- | config.h | 2 | ||||
| -rw-r--r-- | dmenu-wl.c | 32 |
2 files changed, 24 insertions, 10 deletions
@@ -15,4 +15,4 @@ static unsigned cursor_width = 1; static unsigned cursor_vertical_offset = 2; static unsigned cursor_horizontal_offset = 1; -static unsigned monitor_offset = 1; +static unsigned monitor_offset = 0; @@ -10,6 +10,7 @@ #include <time.h> #include <sys/timerfd.h> #include <errno.h> +#include <stdlib.h> #include "xdg-shell-protocol.h" #include "dwl-bar-ipc-protocol.h" @@ -578,6 +579,28 @@ setup() wl_registry_add_listener(client.registry, ®istry_listnener, &client); wl_display_roundtrip(client.display); + compositor = process_name_from_fd(client.display); + if (strcmp(compositor, "dwl") == 0) { + for (mon = monitors; mon; mon = mon->next) { + mon->dwl_output = zdwl_manager_v1_get_output(client.dwl_manager, mon->output); + zdwl_output_v1_add_listener(mon->dwl_output, &dwl_output_listener, mon); + } + wl_display_roundtrip(client.display); + } else if (strcmp(compositor, "Hyprland") == 0) { + char nums[3] = ""; + FILE *nfd = popen("hyprctl monitors | grep '\\(Monitor\\|focused\\)' | paste -d ' ' - - | grep -n yes | grep -o '^[0-9]*'", "r"); + + fgets(nums, 3, nfd); + + if (nums[strlen(nums) - 1] == '\n') { + nums[strlen(nums) - 1] = 0; + } + + monitor_offset += atoi(nums) - 1; + + pclose(nfd); + } + for (mon = monitors; mon && count < monitor_offset;) { mon = mon->next; count += 1; @@ -589,15 +612,6 @@ setup() active_monitor = monitors; } - compositor = process_name_from_fd(client.display); - if (strcmp(compositor, "dwl") == 0) { - for (mon = monitors; mon; mon = mon->next) { - mon->dwl_output = zdwl_manager_v1_get_output(client.dwl_manager, mon->output); - zdwl_output_v1_add_listener(mon->dwl_output, &dwl_output_listener, mon); - } - wl_display_roundtrip(client.display); - } - active_monitor->font = create_font(fontpath, fontsize * 1.5); active_monitor->surface = wl_compositor_create_surface(client.compositor); |