Re: [hackers] [sent] [PATCH] Add toggle fullscreen shortcut: f
Am 2018-03-20 23:13, schrieb Héctor Monacci: 2018-03-20 6:56 GMT-03:00 Markus Teich : The patch is borderline feature-creep, but still fine. As mentioned earlier I currently don't have access to my key, so if no one else want's to do the honor (feel free to!), the author has to wait until some time in April when I'll be able to merge it. Thank you Markus! Sure I can wait! Cool, please resend the fixed patch.
[hackers] [slstatus] Get rid of err.h as it is not portable || Aaron Marcher
commit 96f3a8a54eeb3b2294ed953dad8b15349f3e2703 Author: Aaron Marcher AuthorDate: Wed Mar 28 18:26:56 2018 +0200 Commit: Aaron Marcher CommitDate: Wed Mar 28 18:26:56 2018 +0200 Get rid of err.h as it is not portable Replace warn() and warnx() with fprintf() and add where necessary. diff --git a/components/battery.c b/components/battery.c index aef5b5f..cd1169d 100644 --- a/components/battery.c +++ b/components/battery.c @@ -1,5 +1,4 @@ /* See LICENSE file for copyright and license details. */ -#include #include #if defined(__linux__) #include @@ -29,12 +28,12 @@ battery_perc(const char *bat) fd = open("/dev/apm", O_RDONLY); if (fd < 0) { - warn("Failed to open file /dev/apm"); + fprintf(stderr, "Failed to open file /dev/apm"); return NULL; } if (ioctl(fd, APM_IOC_GETPOWER, &apm_info) < 0) { - warn("Failed to get battery info"); + fprintf(stderr, "Failed to get battery info"); close(fd); return NULL; } diff --git a/components/disk.c b/components/disk.c index 90a8e0b..3d8140e 100644 --- a/components/disk.c +++ b/components/disk.c @@ -1,5 +1,4 @@ /* See LICENSE file for copyright and license details. */ -#include #include #include @@ -11,7 +10,7 @@ disk_free(const char *mnt) struct statvfs fs; if (statvfs(mnt, &fs) < 0) { - warn("Failed to get filesystem info"); + fprintf(stderr, "Failed to get filesystem info"); return NULL; } @@ -25,7 +24,7 @@ disk_perc(const char *mnt) struct statvfs fs; if (statvfs(mnt, &fs) < 0) { - warn("Failed to get filesystem info"); + fprintf(stderr, "Failed to get filesystem info"); return NULL; } @@ -40,7 +39,7 @@ disk_total(const char *mnt) struct statvfs fs; if (statvfs(mnt, &fs) < 0) { - warn("Failed to get filesystem info"); + fprintf(stderr, "Failed to get filesystem info"); return NULL; } @@ -53,7 +52,7 @@ disk_used(const char *mnt) struct statvfs fs; if (statvfs(mnt, &fs) < 0) { - warn("Failed to get filesystem info"); + fprintf(stderr, "Failed to get filesystem info"); return NULL; } diff --git a/components/hostname.c b/components/hostname.c index aed77a6..45dbb5b 100644 --- a/components/hostname.c +++ b/components/hostname.c @@ -1,5 +1,5 @@ /* See LICENSE file for copyright and license details. */ -#include +#include #include #include "../util.h" @@ -8,7 +8,7 @@ const char * hostname(void) { if (gethostname(buf, sizeof(buf)) == -1) { - warn("hostname"); + fprintf(stderr, "gethostbyname failed"); return NULL; } diff --git a/components/ip.c b/components/ip.c index 25071e4..c46ec9e 100644 --- a/components/ip.c +++ b/components/ip.c @@ -1,6 +1,5 @@ /* See LICENSE file for copyright and license details. */ #if defined(__linux__) -#include #include #include #include @@ -16,7 +15,7 @@ ipv4(const char *iface) char host[NI_MAXHOST]; if (getifaddrs(&ifaddr) == -1) { - warn("Failed to get IPv4 address for interface %s", iface); + fprintf(stderr, "Failed to get IPv4 address for interface %s", iface); return NULL; } @@ -27,7 +26,7 @@ ipv4(const char *iface) s = getnameinfo(ifa->ifa_addr, sizeof(struct sockaddr_in), host, NI_MAXHOST, NULL, 0, NI_NUMERICHOST); if ((strcmp(ifa->ifa_name, iface) == 0) && (ifa->ifa_addr->sa_family == AF_INET)) { if (s != 0) { - warnx("Failed to get IPv4 address for interface %s", iface); + fprintf(stderr, "Failed to get IPv4 address for interface %s", iface); return NULL; } return bprintf("%s", host); @@ -47,7 +46,7 @@ ipv6(const char *iface) char host[NI_MAXHOST]; if (getifaddrs(&ifaddr) == -1) { - warn("Failed to get IPv6 address for interface %s", iface); + fprintf(stderr, "Failed to get IPv6 address for interface %s", iface); return NULL; } @@ -58,7 +57,7 @@ ipv6(const char *iface) s = getnameinfo(ifa->ifa_addr, sizeof(struct sockaddr_in6), host, NI_MAXHOST, NULL, 0, NI_NUMERICHOST); if ((strcmp(ifa->ifa_name, iface) == 0) && (ifa->ifa_addr->sa_family == AF_INET6)) { if (s != 0) { - warnx("Failed to get IPv6 address for interface %s", iface); + fprintf(stderr, "Failed to get IPv6 address for interface %s", iface);
[hackers] [slstatus] Remove unnecessary headers || Aaron Marcher
commit aced8326228ea3cf1673828a6e488b8f75108f45 Author: Aaron Marcher AuthorDate: Wed Mar 28 18:14:08 2018 +0200 Commit: Aaron Marcher CommitDate: Wed Mar 28 18:14:08 2018 +0200 Remove unnecessary headers diff --git a/slstatus.c b/slstatus.c index 19bc127..f7c4503 100644 --- a/slstatus.c +++ b/slstatus.c @@ -1,6 +1,4 @@ /* See LICENSE file for copyright and license details. */ -#include -#include #include #include #include
[hackers] [slstatus] Remove program name from error messages || Aaron Marcher
commit 2289798b6d3565d96cc81d5208c50afa2010e296 Author: Aaron Marcher AuthorDate: Wed Mar 28 18:49:27 2018 +0200 Commit: Aaron Marcher CommitDate: Wed Mar 28 18:49:27 2018 +0200 Remove program name from error messages diff --git a/slstatus.c b/slstatus.c index f7c4503..b05d915 100644 --- a/slstatus.c +++ b/slstatus.c @@ -76,7 +76,7 @@ main(int argc, char *argv[]) sigaction(SIGTERM, &act, NULL); if (!sflag && !(dpy = XOpenDisplay(NULL))) { - fprintf(stderr, "slstatus: cannot open display"); + fprintf(stderr, "Cannot open display"); return 1; }
[hackers] [slstatus] Format error messages properly || Aaron Marcher
commit faa52bdcc0221de2d8fae950e409a8ac5e05bfcd Author: Aaron Marcher AuthorDate: Wed Mar 28 19:46:27 2018 +0200 Commit: Aaron Marcher CommitDate: Wed Mar 28 19:46:27 2018 +0200 Format error messages properly Make use of strerror(errno) and format all errors equally: function ['parameters']: error message diff --git a/components/battery.c b/components/battery.c index cd1169d..75f2945 100644 --- a/components/battery.c +++ b/components/battery.c @@ -1,5 +1,7 @@ /* See LICENSE file for copyright and license details. */ +#include #include +#include #if defined(__linux__) #include #include @@ -28,12 +30,12 @@ battery_perc(const char *bat) fd = open("/dev/apm", O_RDONLY); if (fd < 0) { - fprintf(stderr, "Failed to open file /dev/apm"); + fprintf(stderr, "open '/dev/apm': %s\n", strerror(errno)); return NULL; } if (ioctl(fd, APM_IOC_GETPOWER, &apm_info) < 0) { - fprintf(stderr, "Failed to get battery info"); + fprintf(stderr, "ioctl 'APM_IOC_GETPOWER': %s\n", strerror(errno)); close(fd); return NULL; } diff --git a/components/disk.c b/components/disk.c index 3d8140e..8a9caa1 100644 --- a/components/disk.c +++ b/components/disk.c @@ -1,5 +1,7 @@ /* See LICENSE file for copyright and license details. */ +#include #include +#include #include #include "../util.h" @@ -10,7 +12,7 @@ disk_free(const char *mnt) struct statvfs fs; if (statvfs(mnt, &fs) < 0) { - fprintf(stderr, "Failed to get filesystem info"); + fprintf(stderr, "statvfs '%s': %s\n", mnt, strerror(errno)); return NULL; } @@ -24,7 +26,7 @@ disk_perc(const char *mnt) struct statvfs fs; if (statvfs(mnt, &fs) < 0) { - fprintf(stderr, "Failed to get filesystem info"); + fprintf(stderr, "statvfs '%s': %s\n", mnt, strerror(errno)); return NULL; } @@ -39,7 +41,7 @@ disk_total(const char *mnt) struct statvfs fs; if (statvfs(mnt, &fs) < 0) { - fprintf(stderr, "Failed to get filesystem info"); + fprintf(stderr, "statvfs '%s': %s\n", mnt, strerror(errno)); return NULL; } @@ -52,7 +54,7 @@ disk_used(const char *mnt) struct statvfs fs; if (statvfs(mnt, &fs) < 0) { - fprintf(stderr, "Failed to get filesystem info"); + fprintf(stderr, "statvfs '%s': %s\n", mnt, strerror(errno)); return NULL; } diff --git a/components/hostname.c b/components/hostname.c index 45dbb5b..d7c10c8 100644 --- a/components/hostname.c +++ b/components/hostname.c @@ -1,5 +1,7 @@ /* See LICENSE file for copyright and license details. */ +#include #include +#include #include #include "../util.h" @@ -8,7 +10,7 @@ const char * hostname(void) { if (gethostname(buf, sizeof(buf)) == -1) { - fprintf(stderr, "gethostbyname failed"); + fprintf(stderr, "gethostbyname: %s\n", strerror(errno)); return NULL; } diff --git a/components/ip.c b/components/ip.c index c46ec9e..686344b 100644 --- a/components/ip.c +++ b/components/ip.c @@ -1,5 +1,6 @@ /* See LICENSE file for copyright and license details. */ #if defined(__linux__) +#include #include #include #include @@ -15,7 +16,7 @@ ipv4(const char *iface) char host[NI_MAXHOST]; if (getifaddrs(&ifaddr) == -1) { - fprintf(stderr, "Failed to get IPv4 address for interface %s", iface); + fprintf(stderr, "getifaddrs: %s\n", strerror(errno)); return NULL; } @@ -26,7 +27,7 @@ ipv4(const char *iface) s = getnameinfo(ifa->ifa_addr, sizeof(struct sockaddr_in), host, NI_MAXHOST, NULL, 0, NI_NUMERICHOST); if ((strcmp(ifa->ifa_name, iface) == 0) && (ifa->ifa_addr->sa_family == AF_INET)) { if (s != 0) { - fprintf(stderr, "Failed to get IPv4 address for interface %s", iface); + fprintf(stderr, "getnameinfo: %s\n", gai_strerror(s)); return NULL; } return bprintf("%s", host); @@ -46,7 +47,7 @@ ipv6(const char *iface) char host[NI_MAXHOST]; if (getifaddrs(&ifaddr) == -1) { - fprintf(stderr, "Failed to get IPv6 address for interface %s", iface); + fprintf(stderr, "getifaddrs: %s\n", strerror(errno)); return NULL; } @@ -57,7 +58,7 @@ ipv6(const char *iface) s = getnameinfo(ifa->ifa_addr, sizeof(struct sockaddr_in6), host, NI_MAXHOST, NULL, 0, NI_NUMERICHOST); if ((strcmp(ifa->ifa_name, iface) == 0) && (ifa->ifa_addr->sa_family == AF_INET6)) {
[hackers] [st] [PATCH] set sel.alt in selstart instead of selextend
--- When selecting something via doubleclick after entering or leaving the altscreen mode, the selection is not highlighted with st 0.8. But it gets copied to the primary, so the problem is only the highlighting. To reproduce this, enter less and select something with a doubleclick. Afterwards you cannot see in the terminal what you selected. But once you start scrolling, the selection appears. The reason for this behavior is that selextend is only called when the mouse button is released the second time. But during this call the tsetdirt function isn't called, so the terminal isn't redrawn. What gets selected has at that point already been decided during selstart, but the subsequent tsetdirt doesn't have any effect as the function selected returns early if sel.alt != IS_SET(MODE_ALTSCREEN). Thus, setting sel.alt is moved to selstart, which fixes the bug and didn't show any side effects during my testing. st.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/st.c b/st.c index 46c954b..2612c95 100644 --- a/st.c +++ b/st.c @@ -446,6 +446,7 @@ selstart(int col, int row, int snap) selclear(); sel.mode = SEL_EMPTY; sel.type = SEL_REGULAR; + sel.alt = IS_SET(MODE_ALTSCREEN); sel.snap = snap; sel.oe.x = sel.ob.x = col; sel.oe.y = sel.ob.y = row; @@ -474,7 +475,6 @@ selextend(int col, int row, int type, int done) oldsey = sel.ne.y; oldtype = sel.type; - sel.alt = IS_SET(MODE_ALTSCREEN); sel.oe.x = col; sel.oe.y = row; selnormalize(); -- 2.11.0
[hackers] [PATCH] update copyright year
--- x.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/x.c b/x.c index c343ba2..7df20f0 100644 --- a/x.c +++ b/x.c @@ -1925,7 +1925,7 @@ main(int argc, char *argv[]) opt_embed = EARGF(usage()); break; case 'v': - die("%s " VERSION " (c) 2010-2016 st engineers\n", argv0); + die("%s " VERSION " (c) 2010-2018 st engineers\n", argv0); break; default: usage(); -- 2.11.0
Re: [hackers] [sent] [PATCH] Add toggle fullscreen shortcut: f
2018-03-28 5:54 GMT-03:00 Markus Teich >> Thank you Markus! Sure I can wait! > > > Cool, please resend the fixed patch. > Here it goes. I hope it is OK! >From 37637d82867278bad5593db9a2687bc95c1bdb13 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A9ctor=20M=2E=20Monacci?= Date: Sun, 18 Mar 2018 09:04:23 -0300 Subject: [PATCH] Add toggle fullscreen shortcut: f --- README.md| 12 ++-- config.def.h | 1 + sent.c | 21 ++--- 3 files changed, 25 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index c1e9385..4e93d26 100644 --- a/README.md +++ b/README.md @@ -20,7 +20,7 @@ To get a little demo, just type make && ./sent example -You can navigate with the arrow keys and quit with `q`. +You can navigate with the arrow keys, toggle fullscreen with `f`, and quit with `q`. Usage @@ -33,21 +33,21 @@ with `#` will be ignored. A `\` at the beginning of the line escapes `@` and `#`. A presentation file could look like this: sent - + @nyan.png - + depends on - Xlib - Xft - farbfeld - + sent FILENAME one slide per paragraph # This is a comment and will not be part of the presentation \# This and the next line start with backslashes - + \@FILE.png - + thanks / questions? diff --git a/config.def.h b/config.def.h index 60eb376..5dc7d2b 100644 --- a/config.def.h +++ b/config.def.h @@ -46,6 +46,7 @@ static Shortcut shortcuts[] = { { XK_Prior, advance,{.i = -1} }, { XK_n, advance,{.i = +1} }, { XK_p, advance,{.i = -1} }, +{ XK_f, fullscr_togg, {0} }, { XK_r, reload, {0} }, }; diff --git a/sent.c b/sent.c index c50a572..5b0b6cc 100644 --- a/sent.c +++ b/sent.c @@ -97,13 +97,14 @@ static void cleanup(int slidesonly); static void reload(const Arg *arg); static void load(FILE *fp); static void advance(const Arg *arg); +static void fullscr_togg(); static void quit(const Arg *arg); static void resize(int width, int height); static void run(); static void usage(); static void xdraw(); static void xhints(); -static void xinit(); +static void xinit(Bool fs); static void xloadfonts(); static void bpress(XEvent *); @@ -475,6 +476,16 @@ advance(const Arg *arg) } } +void +fullscr_togg() +{ +static Bool toggle; +toggle = !toggle; +XDestroyWindow(xw.dpy, xw.win); +XSync(xw.dpy, False); +xinit(toggle); +} + void quit(const Arg *arg) { @@ -560,7 +571,7 @@ xhints() } void -xinit() +xinit(Bool fs) { XTextProperty prop; unsigned int i; @@ -580,6 +591,10 @@ xinit() InputOutput, xw.vis, CWBitGravity | CWEventMask, &xw.attrs); +Atom wm_state = XInternAtom(xw.dpy, "_NET_WM_STATE", True); +Atom wm_fullscreen = XInternAtom(xw.dpy, "_NET_WM_STATE_FULLSCREEN", True); +XChangeProperty(xw.dpy, xw.win, wm_state, XA_ATOM, 32, PropModeReplace, (unsigned char *)&wm_fullscreen, fs); + xw.wmdeletewin = XInternAtom(xw.dpy, "WM_DELETE_WINDOW", False); xw.netwmname = XInternAtom(xw.dpy, "_NET_WM_NAME", False); XSetWMProtocols(xw.dpy, xw.win, &xw.wmdeletewin, 1); @@ -698,7 +713,7 @@ main(int argc, char *argv[]) load(fp); fclose(fp); -xinit(); +xinit(False); run(); cleanup(0); -- 2.16.2