summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSrikant Patnaik2015-02-22 11:32:52 +0530
committerSrikant Patnaik2015-02-22 11:32:52 +0530
commit5f7fe5de181961eae2bb2bb12bc96a1f49d5c395 (patch)
tree7defb6db5905a263334b3c95874f5df5692db361
parentc1e2d90471e9ffde25091635653c3e53c7ee0afb (diff)
downloadFOSSEE-netbook-tools-5f7fe5de181961eae2bb2bb12bc96a1f49d5c395.tar.gz
FOSSEE-netbook-tools-5f7fe5de181961eae2bb2bb12bc96a1f49d5c395.tar.bz2
FOSSEE-netbook-tools-5f7fe5de181961eae2bb2bb12bc96a1f49d5c395.zip
moved brightness-control to this repository
-rw-r--r--brightness-control/README.rst18
-rw-r--r--brightness-control/brightness-control.desktop11
-rw-r--r--brightness-control/brightness-control.pngbin0 -> 1863 bytes
-rw-r--r--brightness-control/brightness-control.sh41
4 files changed, 70 insertions, 0 deletions
diff --git a/brightness-control/README.rst b/brightness-control/README.rst
new file mode 100644
index 0000000..89296a1
--- /dev/null
+++ b/brightness-control/README.rst
@@ -0,0 +1,18 @@
+Brightness control
+==================
+
+Add the following line in `/etc/rc.local` to make it a startup job ::
+
+ sudo chmod o+w /sys/class/backlight/<somefile>/brightness
+
+Now with a simple bash script we can `echo` suitable values to
+above `brightness` file and change the brightness of the screen. It would
+be a good practice to know the max brightness allowed by reading the file ::
+
+ cat /sys/class/backlight/<somefile>/max_brightness
+
+Now to set brightness we use ::
+
+ echo 50 > /sys/class/backlight/<somefile>/brightness
+
+
diff --git a/brightness-control/brightness-control.desktop b/brightness-control/brightness-control.desktop
new file mode 100644
index 0000000..9220e43
--- /dev/null
+++ b/brightness-control/brightness-control.desktop
@@ -0,0 +1,11 @@
+[Desktop Entry]
+Keywords=Brightness control
+Name=Brightness toggle
+Comment=Brightness control
+Exec=bash /opt/FOSSEE-netbook-tools/brightness-control/brightness-control.sh
+Icon=/opt/FOSSEE-netbook-tools/brightness-control/brightness-icon.png
+#Icon=/usr/share/icons/hicolor/scalable/status/xfpm-brightness-lcd.svg
+Terminal=false
+Type=Application
+MimeType=text/plain
+Categories=GTK;Other;
diff --git a/brightness-control/brightness-control.png b/brightness-control/brightness-control.png
new file mode 100644
index 0000000..72b0d68
--- /dev/null
+++ b/brightness-control/brightness-control.png
Binary files differ
diff --git a/brightness-control/brightness-control.sh b/brightness-control/brightness-control.sh
new file mode 100644
index 0000000..79ff4d9
--- /dev/null
+++ b/brightness-control/brightness-control.sh
@@ -0,0 +1,41 @@
+#!/bin/bash
+
+# A simple script to control screen brightness using 'notify send'
+# copyright Srikant Patnaik
+# GNU GPLv3
+
+# Three brightness modes
+brightness_max=250
+brightness_med=160
+brightness_low=80
+
+# A file to store previous brightness value
+status_file=/tmp/previous_brightness
+
+# If running for first time, then create the status file with med value for brightness
+if [ ! -f $status_file ];
+then
+ echo $brightness_med > $status_file
+fi
+
+previous_brightness=$(cat $status_file)
+
+if (( "$previous_brightness" == "80" ));
+then
+ echo $brightness_med > /sys/class/backlight/pwm-backlight.0/brightness
+ #notify-send "medium brightness"
+ echo -n "medium brightness" | osd_cat --font='-b&h-lucida-medium-r-normal-*-34-*-*-*-p-*-iso10646-1' --color=green --pos=top --align=right --offset=50 --indent=50 -d 1
+ echo $brightness_med > $status_file
+
+elif (( "$previous_brightness" == "160" ));
+then
+ echo $brightness_max > /sys/class/backlight/pwm-backlight.0/brightness
+ #notify-send "full brightness"
+ echo -n "full brightness" | osd_cat --font='-b&h-lucida-medium-r-normal-*-34-*-*-*-p-*-iso10646-1' --color=green --pos=top --align=right --offset=50 --indent=50 -d 1
+ echo $brightness_max > $status_file
+else
+ echo $brightness_low > /sys/class/backlight/pwm-backlight.0/brightness
+ # notify-send "low brightness"
+ echo -n "low brightness" | osd_cat --font='-b&h-lucida-medium-r-normal-*-34-*-*-*-p-*-iso10646-1' --color=green --pos=top --align=right --offset=50 --indent=50 -d 1
+ echo $brightness_low > $status_file
+fi