Skip to content

Commit

Permalink
fix linux memory leak #3 (#4)
Browse files Browse the repository at this point in the history
  • Loading branch information
bithavoc authored Dec 7, 2017
1 parent 46e2ee6 commit 32b9812
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,12 @@ var desktopIdle = require('desktop-idle');
console.log(desktopIdle.getIdleTime());
```

### Linux Requirements

X server development package and pkg-config are required:

`apt install libxss-dev pkg-config`

### Test

```
Expand Down
5 changes: 4 additions & 1 deletion src/linux/idle.cc
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,8 @@ double desktop_idle_get_time() {
}
XScreenSaverInfo *info = XScreenSaverAllocInfo();
XScreenSaverQueryInfo(dpy, DefaultRootWindow(dpy), info);
return info->idle / 1000; // to seconds
unsigned long idle = info->idle;
XFree(info);
XCloseDisplay(dpy);
return idle / 1000; // to seconds
}

0 comments on commit 32b9812

Please sign in to comment.