Skip to content

Instantly share code, notes, and snippets.

@joshuabergeron
Last active December 22, 2015 06:19
Show Gist options
  • Save joshuabergeron/6430490 to your computer and use it in GitHub Desktop.
Save joshuabergeron/6430490 to your computer and use it in GitHub Desktop.
Sometimes my mouse is stuck after a resume on Ubuntu, this fixes it.
/* replace the filename with appropriate usb device info for your computer. get device info from lsusb. */
#include <stdio.h>
#include <fcntl.h>
#include <errno.h>
#include <sys/ioctl.h>
#include <linux/usbdevice_fs.h>
#include <sys/types.h>
#include <unistd.h>
int main(void)
{
const char *filename = "/dev/bus/usb/005/002";
int fd;
seteuid(0);
fd = open(filename, O_WRONLY);
ioctl(fd, USBDEVFS_RESET, 0);
close(fd);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment