updated on Thu Jan 26 16:09:46 UTC 2012
[aur-mirror.git] / acpi-eee / asusosd-osd_configurable.patch
bloba522749a1728a50e3a766516d6404d3eead7425b
1 # Make asusosd's screen position configurable patch
2 # by Mika Hynnä <igheax@gmail.com>
3 --- asusosd_image.c.orig 2008-03-26 19:55:55.000000000 +0200
4 +++ asusosd_image.c 2008-03-26 21:30:07.000000000 +0200
5 @@ -17,6 +17,7 @@
6 static int xwindow_create(void);
7 static int ximage_create(void);
8 static int ximage_display(void);
9 +static void read_pos_from_config(char config[], int *x, int *y);
10 void destroy_osd(void);
11 //static void destroy_image(void);
12 static int x_msb(unsigned long u32val);
13 @@ -236,6 +237,9 @@
14 attr.border_pixel = 0;
15 x = 2;//(XDefaultScreenOfDisplay(display)->width - image_width)/2;
16 y = 2;//(XDefaultScreenOfDisplay(display)->height - image_height)/2;
18 + read_pos_from_config("/etc/acpi/eee.conf", &x, &y);
20 window = XCreateWindow(display, root, x, y, image_width, image_height, 0,
21 depth, InputOutput, visual, attrmask, &attr);
23 @@ -545,3 +549,46 @@
25 return i;
28 +static void read_pos_from_config(char config[], int *x, int *y)
30 + FILE *configfile;
31 + char line[80];
33 + configfile = fopen(config, "r");
34 + if (configfile != NULL)
35 + {
36 + while(fgets(line, 80, configfile) != NULL)
37 + {
38 + if (line[0] == '#')
39 + {
40 + //try to ignore comments
41 + }
42 + else if (strstr(line, "ASUSOSD_XPOS=center") != NULL)
43 + {
44 + *x = (XDefaultScreenOfDisplay(display)->width - image_width)/2;
45 + }
46 + else if (strstr(line, "ASUSOSD_XPOS=") != NULL)
47 + {
48 + sscanf(line,"ASUSOSD_XPOS=%i" , x);
49 + }
50 + else if (strstr(line, "ASUSOSD_YPOS=center") != NULL)
51 + {
52 + *y = (XDefaultScreenOfDisplay(display)->height - image_height)/2;
53 + }
54 + else if (strstr(line, "ASUSOSD_YPOS=") != NULL)
55 + {
56 + sscanf(line,"ASUSOSD_YPOS=%i" , y);
57 + }
58 + }
59 + }
60 + else
61 + {
62 + printf("Unable to open configuration file '%s': defaulting.", config);
63 + }
65 + fclose(configfile);