From: Michael D. Lowis Date: Tue, 30 May 2017 15:16:21 +0000 (-0400) Subject: updated xcpd cd to root on daemonization X-Git-Url: https://git.mdlowis.com/?a=commitdiff_plain;h=999a56c944bfa4b124652840b396fb6593c59a4d;p=projs%2Ftide.git updated xcpd cd to root on daemonization --- diff --git a/TODO.md b/TODO.md index 1b39ab2..11411e5 100644 --- a/TODO.md +++ b/TODO.md @@ -5,7 +5,6 @@ Up Next: * move by words is inconsistent. Example: var infoId = 'readerinfo'+reader.id; * Add a way to CD using a builtin (buffers will track original dir) -* cd to root in xcpd * Ctrl+; Shortcut to warp cursor to middle of current screen. * shortcut to jump to previous edit diff --git a/xcpd.c b/xcpd.c index e92b819..e5e45ac 100644 --- a/xcpd.c +++ b/xcpd.c @@ -23,10 +23,10 @@ void serve_selection(void) { if (SelTarget == None) SelTarget = XInternAtom(XDisplay, "STRING", 0); XSetSelectionOwner(XDisplay, SelType, XWindow, CurrentTime); - + for (XEvent e;;) { XNextEvent(XDisplay, &e); - if (e.type == SelectionRequest) { + if (e.type == SelectionRequest) { XEvent s; s.xselection.type = SelectionNotify; s.xselection.property = e.xselectionrequest.property; @@ -46,10 +46,10 @@ void serve_selection(void) { } else if (target == SelTarget || target == xastring) { XChangeProperty( XDisplay, s.xselection.requestor, s.xselection.property, - SelTarget, 8, PropModeReplace, + SelTarget, 8, PropModeReplace, (unsigned char*)SelText, strlen(SelText)); } - XSendEvent(XDisplay, s.xselection.requestor, True, 0, &s); + XSendEvent(XDisplay, s.xselection.requestor, True, 0, &s); } else if (e.type == SelectionClear) { break; // Someone else took over. We're done here. } @@ -64,6 +64,7 @@ int main(int argc, char** argv) { close(STDIN_FILENO); close(STDOUT_FILENO); close(STDERR_FILENO); + chdir("/"); serve_selection(); } else if (pid < 0) { die("fork() failed");