diff options
author | Brian Ashworth <bosrsf04@gmail.com> | 2019-04-14 00:27:47 -0400 |
---|---|---|
committer | Simon Ser <contact@emersion.fr> | 2019-04-14 12:41:59 +0300 |
commit | 6961bf2e4ce2c116e41a8db158691f6c993707ce (patch) | |
tree | a381146599a5f19e565006cafeb23edc04247d2b /common | |
parent | swaynag: fix pointer management (diff) | |
download | sway-6961bf2e4ce2c116e41a8db158691f6c993707ce.tar.gz sway-6961bf2e4ce2c116e41a8db158691f6c993707ce.tar.zst sway-6961bf2e4ce2c116e41a8db158691f6c993707ce.zip |
Spawn swaynag as a wayland client
This spawns swaynag as a wayland client similar to how swaybar and
swaybg are already done
Diffstat (limited to 'common')
-rw-r--r-- | common/util.c | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/common/util.c b/common/util.c index c43c5ddf..3a807edb 100644 --- a/common/util.c +++ b/common/util.c | |||
@@ -1,5 +1,6 @@ | |||
1 | #define _POSIX_C_SOURCE 200809L | 1 | #define _POSIX_C_SOURCE 200809L |
2 | #include <float.h> | 2 | #include <float.h> |
3 | #include <fcntl.h> | ||
3 | #include <math.h> | 4 | #include <math.h> |
4 | #include <stdlib.h> | 5 | #include <stdlib.h> |
5 | #include <string.h> | 6 | #include <string.h> |
@@ -75,3 +76,21 @@ const char *sway_wl_output_subpixel_to_string(enum wl_output_subpixel subpixel) | |||
75 | sway_assert(false, "Unknown value for wl_output_subpixel."); | 76 | sway_assert(false, "Unknown value for wl_output_subpixel."); |
76 | return NULL; | 77 | return NULL; |
77 | } | 78 | } |
79 | |||
80 | bool set_cloexec(int fd, bool cloexec) { | ||
81 | int flags = fcntl(fd, F_GETFD); | ||
82 | if (flags == -1) { | ||
83 | sway_log_errno(SWAY_ERROR, "fcntl failed"); | ||
84 | return false; | ||
85 | } | ||
86 | if (cloexec) { | ||
87 | flags = flags | FD_CLOEXEC; | ||
88 | } else { | ||
89 | flags = flags & ~FD_CLOEXEC; | ||
90 | } | ||
91 | if (fcntl(fd, F_SETFD, flags) == -1) { | ||
92 | sway_log_errno(SWAY_ERROR, "fcntl failed"); | ||
93 | return false; | ||
94 | } | ||
95 | return true; | ||
96 | } | ||