|
marcOcram
Anmeldungsdatum: Jan. 26, 2012
Beiträge: 5
|

3. Juli 2012 15:23
Moin, ich habe mir den fglrx-Treiber für mein Notebook installiert und bin nun auf das Problem gestoßen, dass nun die Tasten für die Helligkeitsregelung funktionslos sind.
Wenn ich die Tasten benutze, kommt diese Einblendung und der Wert wird auch unter "/sys/class/backlight/toshiba/brightness" (0-7) geändert. Jedoch muss der Wert nicht dort geändert werden, sondern unter "/sys/class/backlight/acpi_video0/brightness", wenn ich dort die Werte nämlich manuell ändere, ändert sich auch die Bildschirmhelligkeit. Wie kann ich nun den Ort von "toshiba" auf "acpi_video0" mappen bzw. die Tasten auf "acpi_video0" umlenken, sodass die Tasten wieder funktionieren? Vielen Dank für die Hilfe !
|
|
marcOcram
(Themenstarter)
Anmeldungsdatum: Jan. 26, 2012
Beiträge: 5
|

4. Juli 2012 09:14
Guten Tag, ich habe es jetzt geschafft den gsd-backlight-helper so umzuschreiben, dass dieser den Ort mit "acpi_video0" nimmt. Dafür habe ich den Code wie in diesem Forum erläutert, geändert. Nun kann ich mit Hilfe des gsd-backlight-helper im Terminal die Helligkeit ändern, jedoch funktionieren die Tasten immer noch nicht, hat jemand einen Ratschlag? 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260 | /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
*
* Copyright (C) 2010-2011 Richard Hughes <richard@hughsie.com>
*
* Licensed under the GNU General Public License Version 2
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#include "config.h"
#include <unistd.h>
#include <glib-object.h>
#include <locale.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <string.h>
#include <gudev/gudev.h>
#define GSD_BACKLIGHT_HELPER_EXIT_CODE_SUCCESS 0
#define GSD_BACKLIGHT_HELPER_EXIT_CODE_FAILED 1
#define GSD_BACKLIGHT_HELPER_EXIT_CODE_ARGUMENTS_INVALID 3
#define GSD_BACKLIGHT_HELPER_EXIT_CODE_INVALID_USER 4
#define GSD_BACKLIGHT_HELPER_SYSFS_LOCATION "/sys/class/backlight"
static gchar *
gsd_backlight_helper_get_best_backlight ()
{
gchar *filename;
guint i;
gboolean ret;
GDir *dir = NULL;
GError *error = NULL;
const gchar *first_device;
/* available kernel interfaces in priority order */
static const gchar *backlight_interfaces[] = {
"nv_backlight",
"asus_laptop",
"acpi_video0",
"toshiba",
"eeepc",
"thinkpad_screen",
"acpi_video1",
"mbp_backlight",
"fujitsu-laptop",
"nvidia_backlight",
"samsung",
NULL,
};
/* search each one */
for (i=0; backlight_interfaces[i] != NULL; i++) {
filename = g_build_filename (GSD_BACKLIGHT_HELPER_SYSFS_LOCATION,
backlight_interfaces[i], NULL);
ret = g_file_test (filename, G_FILE_TEST_EXISTS);
if (ret)
goto out;
g_free (filename);
}
/* nothing found in the ordered list */
filename = NULL;
/* find any random ones */
dir = g_dir_open (GSD_BACKLIGHT_HELPER_SYSFS_LOCATION, 0, &error);
if (dir == NULL) {
g_warning ("failed to find any devices: %s", error->message);
g_error_free (error);
goto out;
}
/* get first device if any */
first_device = g_dir_read_name (dir);
if (first_device != NULL) {
filename = g_build_filename (GSD_BACKLIGHT_HELPER_SYSFS_LOCATION,
first_device, NULL);
}
out:
if (dir != NULL)
g_dir_close (dir);
return filename;
}
static gboolean
gsd_backlight_helper_write (const gchar *filename, gint value, GError **error)
{
gchar *text = NULL;
gint retval;
gint length;
gint fd = -1;
gboolean ret = TRUE;
fd = open (filename, O_WRONLY);
if (fd < 0) {
ret = FALSE;
g_set_error (error, 1, 0, "failed to open filename: %s", filename);
goto out;
}
/* convert to text */
text = g_strdup_printf ("%i", value);
length = strlen (text);
/* write to device file */
retval = write (fd, text, length);
if (retval != length) {
ret = FALSE;
g_set_error (error, 1, 0, "writing '%s' to %s failed", text, filename);
goto out;
}
out:
if (fd >= 0)
close (fd);
g_free (text);
return ret;
}
int
main (int argc, char *argv[])
{
GOptionContext *context;
gint uid;
gint euid;
guint retval = 0;
GError *error = NULL;
gboolean ret = FALSE;
gint set_brightness = -1;
gboolean get_brightness = FALSE;
gboolean get_max_brightness = FALSE;
gchar *filename = NULL;
gchar *filename_file = NULL;
gchar *contents = NULL;
const GOptionEntry options[] = {
{ "set-brightness", '\0', 0, G_OPTION_ARG_INT, &set_brightness,
/* command line argument */
"Set the current brightness", NULL },
{ "get-brightness", '\0', 0, G_OPTION_ARG_NONE, &get_brightness,
/* command line argument */
"Get the current brightness", NULL },
{ "get-max-brightness", '\0', 0, G_OPTION_ARG_NONE, &get_max_brightness,
/* command line argument */
"Get the number of brightness levels supported", NULL },
{ NULL}
};
/* setup type system */
g_type_init ();
context = g_option_context_new (NULL);
g_option_context_set_summary (context, "GNOME Settings Daemon Backlight Helper");
g_option_context_add_main_entries (context, options, NULL);
g_option_context_parse (context, &argc, &argv, NULL);
g_option_context_free (context);
#ifndef __linux__
/* the g-s-d plugin should only call this helper on linux */
g_critical ("Attempting to call gsb-backlight-helper on non-Linux");
g_assert_not_reached ();
#endif
/* no input */
if (set_brightness == -1 && !get_brightness && !get_max_brightness) {
g_print ("%s\n", "No valid option was specified");
retval = GSD_BACKLIGHT_HELPER_EXIT_CODE_ARGUMENTS_INVALID;
goto out;
}
/* find device */
filename = gsd_backlight_helper_get_best_backlight ();
if (filename == NULL) {
retval = GSD_BACKLIGHT_HELPER_EXIT_CODE_INVALID_USER;
goto out;
}
/* GetBrightness */
if (get_brightness) {
filename_file = g_build_filename (filename, "brightness", NULL);
ret = g_file_get_contents (filename_file, &contents, NULL, &error);
if (!ret) {
g_print ("%s: %s\n",
"Could not get the value of the backlight",
error->message);
g_error_free (error);
retval = GSD_BACKLIGHT_HELPER_EXIT_CODE_ARGUMENTS_INVALID;
goto out;
}
/* just print the contents to stdout */
g_print ("%s", contents);
retval = GSD_BACKLIGHT_HELPER_EXIT_CODE_SUCCESS;
goto out;
}
/* GetSteps */
if (get_max_brightness) {
filename_file = g_build_filename (filename, "max_brightness", NULL);
ret = g_file_get_contents (filename_file, &contents, NULL, &error);
if (!ret) {
g_print ("%s: %s\n",
"Could not get the maximum value of the backlight",
error->message);
g_error_free (error);
retval = GSD_BACKLIGHT_HELPER_EXIT_CODE_ARGUMENTS_INVALID;
goto out;
}
/* just print the contents to stdout */
g_print ("%s", contents);
retval = GSD_BACKLIGHT_HELPER_EXIT_CODE_SUCCESS;
goto out;
}
/* check calling UID */
uid = getuid ();
euid = geteuid ();
if (uid != 0 || euid != 0) {
g_print ("%s\n",
"This program can only be used by the root user");
retval = GSD_BACKLIGHT_HELPER_EXIT_CODE_ARGUMENTS_INVALID;
goto out;
}
/* SetBrightness */
if (set_brightness != -1) {
filename_file = g_build_filename (filename, "brightness", NULL);
ret = gsd_backlight_helper_write (filename_file, set_brightness, &error);
if (!ret) {
g_print ("%s: %s\n",
"Could not set the value of the backlight",
error->message);
g_error_free (error);
retval = GSD_BACKLIGHT_HELPER_EXIT_CODE_ARGUMENTS_INVALID;
goto out;
}
}
/* success */
retval = GSD_BACKLIGHT_HELPER_EXIT_CODE_SUCCESS;
out:
g_free (filename);
g_free (filename_file);
g_free (contents);
return retval;
}
|
|
|
marcOcram
(Themenstarter)
Anmeldungsdatum: Jan. 26, 2012
Beiträge: 5
|

5. Juli 2012 11:04
Hab das ganze jetzt mittelmäßig über rc.local gelöst  | while true; do sleep 0.25; /usr/lib/gnome-settings-daemon/gsd-backlight-helper --set-brightness `cat /sys/class/backlight/toshiba/brightness`; done &
|
|