diff options
| author | Nathan Reiner <nathan@nathanreiner.xyz> | 2023-07-22 22:58:15 +0200 |
|---|---|---|
| committer | Nathan Reiner <nathan@nathanreiner.xyz> | 2023-07-22 22:58:15 +0200 |
| commit | e946a60ecc289db6c1570f5177ef0c9c1ad0a039 (patch) | |
| tree | 0db4d324a767e8d4875f1b619e4cea67a8dd22d4 /dmenu-wl.c | |
| parent | 896bb1e6576fe32b754341ddf0b49fbcfd1c116a (diff) | |
Diffstat (limited to 'dmenu-wl.c')
| -rw-r--r-- | dmenu-wl.c | 32 |
1 files changed, 23 insertions, 9 deletions
@@ -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); |