Compare commits
	
		
			2 Commits
		
	
	
		
			98a5539dca
			...
			1ded64275f
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| 1ded64275f | |||
| 4fe12dfc27 | 
@@ -1,3 +1,4 @@
 | 
			
		||||
[](https://build.jcktrue.dk/jct/ledcontroller-3bit)
 | 
			
		||||
# ledcontroller-3bit #
 | 
			
		||||
 | 
			
		||||
A Linux command line utility to control usb mail notifiers identified as:
 | 
			
		||||
@@ -27,9 +28,8 @@ For example the script `mled-cputemp` will make it respond to your CPU's tempera
 | 
			
		||||
 | 
			
		||||
    $ sudo rm /usr/bin/ledcontroller
 | 
			
		||||
    
 | 
			
		||||
### Have fun: ###
 | 
			
		||||
### Have fun ###
 | 
			
		||||
 | 
			
		||||
Take a look inside the _scripts_ directory.
 | 
			
		||||
 | 
			
		||||
## Requisites: ##
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										60
									
								
								main.c
									
									
									
									
									
								
							
							
						
						
									
										60
									
								
								main.c
									
									
									
									
									
								
							@@ -51,13 +51,11 @@
 | 
			
		||||
 | 
			
		||||
static struct libusb_device_handle *devh = NULL;
 | 
			
		||||
 | 
			
		||||
int
 | 
			
		||||
main (int argc, char **argv)
 | 
			
		||||
int main(int argc, char **argv)
 | 
			
		||||
{
 | 
			
		||||
    int ret;
 | 
			
		||||
    unsigned char code = 0;
 | 
			
		||||
  if (argc != 2)
 | 
			
		||||
    {
 | 
			
		||||
    if (argc != 2) {
 | 
			
		||||
	printf
 | 
			
		||||
	    ("Syntax: %s blue | red | green | aqua | purple | yellow | white |  off\n",
 | 
			
		||||
	     argv[0]);
 | 
			
		||||
@@ -84,55 +82,37 @@ main (int argc, char **argv)
 | 
			
		||||
    1 1 0 yellow 0x6 (more of a mustard - green color)
 | 
			
		||||
    1 1 1 white  0x7 (a very blue-ish white)
 | 
			
		||||
*/
 | 
			
		||||
  if (strcmp (argv[1], "blue") == 0)
 | 
			
		||||
    {
 | 
			
		||||
    if (strcmp(argv[1], "blue") == 0) {
 | 
			
		||||
	code = 1;
 | 
			
		||||
    }
 | 
			
		||||
  else if (strcmp (argv[1], "red") == 0)
 | 
			
		||||
    {
 | 
			
		||||
    } else if (strcmp(argv[1], "red") == 0) {
 | 
			
		||||
	code = 2;
 | 
			
		||||
    }
 | 
			
		||||
  else if (strcmp (argv[1], "green") == 0)
 | 
			
		||||
    {
 | 
			
		||||
    } else if (strcmp(argv[1], "green") == 0) {
 | 
			
		||||
	code = 3;
 | 
			
		||||
    }
 | 
			
		||||
  else if (strcmp (argv[1], "aqua") == 0)
 | 
			
		||||
    {
 | 
			
		||||
    } else if (strcmp(argv[1], "aqua") == 0) {
 | 
			
		||||
	code = 4;
 | 
			
		||||
    }
 | 
			
		||||
  else if (strcmp (argv[1], "purple") == 0)
 | 
			
		||||
    {
 | 
			
		||||
    } else if (strcmp(argv[1], "purple") == 0) {
 | 
			
		||||
	code = 5;
 | 
			
		||||
    }
 | 
			
		||||
  else if (strcmp (argv[1], "yellow") == 0)
 | 
			
		||||
    {
 | 
			
		||||
    } else if (strcmp(argv[1], "yellow") == 0) {
 | 
			
		||||
	code = 6;
 | 
			
		||||
    }
 | 
			
		||||
  else if (strcmp (argv[1], "white") == 0)
 | 
			
		||||
    {
 | 
			
		||||
    } else if (strcmp(argv[1], "white") == 0) {
 | 
			
		||||
	code = 7;
 | 
			
		||||
    }
 | 
			
		||||
  else
 | 
			
		||||
    {
 | 
			
		||||
      printf ("invalid color\n");
 | 
			
		||||
    } else {
 | 
			
		||||
	puts("Invalid color");
 | 
			
		||||
	return -1;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    libusb_init(NULL);
 | 
			
		||||
    devh = libusb_open_device_with_vid_pid(NULL, VID, PID);
 | 
			
		||||
  if (devh == NULL)
 | 
			
		||||
    {
 | 
			
		||||
      printf ("not found\n");
 | 
			
		||||
    if (devh == NULL) {
 | 
			
		||||
	puts("Device not found");
 | 
			
		||||
	return -1;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
  if (libusb_kernel_driver_active (devh, 0))
 | 
			
		||||
    {
 | 
			
		||||
      printf ("detach from kernel\n");
 | 
			
		||||
    if (libusb_kernel_driver_active(devh, 0)) {
 | 
			
		||||
	puts("Detach driver from kernel");
 | 
			
		||||
	ret = libusb_detach_kernel_driver(devh, 0);
 | 
			
		||||
      if (ret < 0)
 | 
			
		||||
	{
 | 
			
		||||
	  printf ("can't detach\n");
 | 
			
		||||
	if (ret < 0) {
 | 
			
		||||
	    puts("Could not detach driver");
 | 
			
		||||
	    return -1;
 | 
			
		||||
	}
 | 
			
		||||
    }
 | 
			
		||||
@@ -147,9 +127,9 @@ main (int argc, char **argv)
 | 
			
		||||
    int dummy;
 | 
			
		||||
    libusb_claim_interface(devh, 0);
 | 
			
		||||
    ret = libusb_interrupt_transfer(devh, 0x2, data, 5, &dummy, 0);
 | 
			
		||||
  if (ret < 0)
 | 
			
		||||
    {
 | 
			
		||||
      perror ("error");
 | 
			
		||||
    if (ret < 0) {
 | 
			
		||||
	perror("libusb error");
 | 
			
		||||
	return -1;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user