aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xadjbacklight51
-rw-r--r--info/adjbacklight.texinfo8
2 files changed, 47 insertions, 12 deletions
diff --git a/adjbacklight b/adjbacklight
index 8adc413..c709c35 100755
--- a/adjbacklight
+++ b/adjbacklight
@@ -18,9 +18,15 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
+all=0
+devices=()
+
if (( $# > 0 )); then
for arg in "$@"; do
case "$arg" in
+ ("-a" | "--all")
+ all=1
+ ;;
("-c" | "--copyright" | "--copying")
cat <<.
@@ -59,16 +65,22 @@ GNU General Public License for more details.
.
exit 0
;;
+ (*)
+ if [ ! "${arg::1}" = "-" ]; then
+ devices+=( "$arg" )
+ fi
+ ;;
esac
done
- cat <<.
+ if [ $all = 0 ] && [ ${#devices[@]} = 0 ]; then
+ cat <<.
adjbacklight – Convient method for adjusting the backlight on your portable computer
-USAGE: adjbacklight [ -c | -w ]
+USAGE: adjbacklight [ -c | -w | -a | DEVICE...]
-Run with options to adjust the backlight on your screens.
+Run with options to adjust the backlight on your monitors.
OPTIONS:
@@ -80,6 +92,9 @@ OPTIONS:
-w
--warranty Display warranty disclaimer
+-a
+--all Run for all devices, including ACPI devices
+
KEYBOARD:
@@ -102,7 +117,8 @@ it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
.
- exit 0
+ exit 0
+ fi
fi
@@ -113,7 +129,7 @@ If the program is abnormally aborted there may be effects
on the terminal, the following commands should reset it:
stty icanon echo
- echo -en '\033[?25h'
+ echo -en '\e[?25h'
@@ -121,12 +137,25 @@ on the terminal, the following commands should reset it:
.
stty -icanon -echo
-if [[ $? = 0 ]]; then
- echo -en '\033[?25l'
- for dir in $(exec ls -1 --color=no "/sys/class/backlight/" | grep -v '^acpi_video'); do
- sudo java -cp ${BASH_SOURCE%/*} Adjbacklight `stty size` "$dir"
- done
- echo -en '\033[?25h'
+if [ $? = 0 ]; then
+ echo -en '\e[?25l'
+ if [ ! ${#devices[@]} = 0 ]; then
+ for dir in "${devices[@]}"; do
+ if [ "${dir::21}" = "/sys/class/backlight/" ]; then
+ dir="${dir:21}"
+ fi
+ sudo java -cp ${BASH_SOURCE%/*} Adjbacklight `stty size` "$dir"
+ done
+ elif [ $all = 0 ]; then
+ for dir in $(exec ls -1 --color=no "/sys/class/backlight/" | grep -v '^acpi_video'); do
+ sudo java -cp ${BASH_SOURCE%/*} Adjbacklight `stty size` "$dir"
+ done
+ else
+ for dir in $(exec ls -1 --color=no "/sys/class/backlight/"); do
+ sudo java -cp ${BASH_SOURCE%/*} Adjbacklight `stty size` "$dir"
+ done
+ fi
+ echo -en '\e[?25h'
stty icanon echo
else
echo -e '\e[1;31m::\e[39m Epic failure\e[21m'
diff --git a/info/adjbacklight.texinfo b/info/adjbacklight.texinfo
index be30c2d..8142b82 100644
--- a/info/adjbacklight.texinfo
+++ b/info/adjbacklight.texinfo
@@ -92,12 +92,16 @@ code. Just @code{sed -i s/200/400/g Adjbacklight.java}, if you want 0.25 % preci
@cindex starting
@cindex options
@cindex arguments
+@cindex device
+@cindex selecting device
@cindex @command{adjbacklight}
@cindex @option{-c}
@cindex @option{--copying}
@cindex @option{--copyright}
@cindex @option{-w}
@cindex @option{--warranty}
+@cindex @option{-a}
+@cindex @option{--all}
@command{adjbacklight} can be started with @option{-c}, @option{--copying} or
@option{--copyright} for displaying copyright information, @option{-w} or
@@ -105,7 +109,9 @@ code. Just @code{sed -i s/200/400/g Adjbacklight.java}, if you want 0.25 % preci
is used, help information is displayed.
To actually use the program, just execute @command{adjbacklight} without any
-arguments.
+arguments, or with @option{-a} or @option{--all} to not limit the devices to
+those that are not ACPI video devices. Alternatively you can list the devices
+either by full path or just the name in the directory @file{/sys/class/backlight}.
@node Using