Thread: Fixing screen brightness issue in Ubuntu 12.04
this fix vaio vpccw16fg quick key fn f5+f6 brightness bar move backlight no change.
rectify this, follow following procedure:
1) go https://github.com/guillaumezin/nvidiabl/downloads , download nvidia dkms. of today (nvidiabl-dkms_0.73_all.deb — 0.73 deb debian based distributions)
unpack it!
2)discover version number of gnome-settings-daemon.sudo dpkg -i nvidiabl-dkms_0.73_all.deb
alternatively, can through synaptic package manager. if no synaptic installed, code:dpkg-query -w -f '${version}\n' gnome-settings-daemon
when in synaptic, in search bar, type gnome-settings-daemon find version number.sudo apt-get install synaptic
3) download relevant daemon: https://launchpad.net/ubuntu/+source...ttings-daemon/
4) go directory unpacked , edit 'gsd-backlight-helper.c' file. example:
replace code following:sudo gedit ~/gnome-settings-daemon-3.4.1/plugins/power/gsd-backlight-helper.c
close , save./* -*- mode: c; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
*
* copyright (c) 2010-2011 richard hughes <richard@hughsie.com>
*
* licensed under gnu general public license version 2
*
* program free software; can redistribute and/or modify
* under terms of gnu general public license published by
* free software foundation; either version 2 of license, or
* (at option) later version.
*
* program distributed in hope useful,
* without warranty; without implied warranty of
* merchantability or fitness particular purpose. see the
* gnu general public license more details.
*
* should have received copy of gnu general public license
* along program; if not, write 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>
#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",
"toshiba",
"eeepc",
"thinkpad_screen",
"acpi_video1",
"mbp_backlight",
"acpi_video0",
"fujitsu-laptop",
"nvidia_backlight",
"samsung",
null,
};
/* search each 1 */
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 ordered list */
filename = null;
/* find random ones */
dir = g_dir_open (gsd_backlight_helper_sysfs_location, 0, &error);
if (dir == null) {
g_warning ("failed find devices: %s", error->message);
g_error_free (error);
goto out;
}
/* first device if */
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 open filename: %s", filename);
goto out;
}
/* convert text */
text = g_strdup_printf ("%i", value);
length = strlen (text);
/* write device file */
retval = write (fd, text, length);
if (retval != length) {
ret = false;
g_set_error (error, 1, 0, "writing '%s' %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;
const gchar *pkexec_uid_str;
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 current brightness", null },
{ "get-brightness", '\0', 0, g_option_arg_none, &get_brightness,
/* command line argument */
"get current brightness", null },
{ "get-max-brightness", '\0', 0, g_option_arg_none, &get_max_brightness,
/* command line argument */
"get 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__
/* g-s-d plugin should call helper on linux */
g_critical ("attempting 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 specified");
retval = gsd_backlight_helper_exit_code_arguments_invalid;
goto out;
}
/* find device */
filename = gsd_backlight_helper_get_best_backlight ();
if (filename == null) {
g_print ("%s\n", "no backlights found on system");
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 value of backlight",
error->message);
g_error_free (error);
retval = gsd_backlight_helper_exit_code_arguments_invalid;
goto out;
}
/* print contents 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 maximum value of backlight",
error->message);
g_error_free (error);
retval = gsd_backlight_helper_exit_code_arguments_invalid;
goto out;
}
/* print contents stdout */
g_print ("%s", contents);
retval = gsd_backlight_helper_exit_code_success;
goto out;
}
/* calling process */
uid = getuid ();
euid = geteuid ();
if (uid != 0 || euid != 0) {
g_print ("%s\n",
"this program can used root user");
retval = gsd_backlight_helper_exit_code_arguments_invalid;
goto out;
}
/* check we're not being spoofed */
pkexec_uid_str = g_getenv ("pkexec_uid");
if (pkexec_uid_str == null) {
g_print ("%s\n",
"this program must run through pkexec");
retval = gsd_backlight_helper_exit_code_invalid_user;
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 value of 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;
}
5) surf gnome-settings-daemon directory through terminal e.g.
then run following code:cd ~/gnome-settings-daemon-3.4.1
6) replace files manually:sudo apt-get install intltool
sudo apt-get build-dep gnome-settings-daemon
./configure
make
7)sudo mv /usr/lib/gnome-settings-daemon/gsd-backlight-helper /usr/lib/gnome-settings-daemon/gsd-backlight-helper.old
cd ~/gnome-settings-daemon-3.4.1/plugins/power/
sudo cp gsd-backlight-helper /usr/lib/gnome-settings-daemon/.![]()
i have different laptop found can control screen brightness using command
sudo setpci -s 00:02.0 f4.b=xx xx the hex code brightness level. 00 = black ff=brightest.
Forum The Ubuntu Forum Community Ubuntu Official Flavours Support General Help [ubuntu] Fixing screen brightness issue in Ubuntu 12.04
Ubuntu
Comments
Post a Comment