diff options
author | Mattias Andrée <maandree@operamail.com> | 2013-01-20 19:24:27 +0100 |
---|---|---|
committer | Mattias Andrée <maandree@operamail.com> | 2013-01-20 19:24:27 +0100 |
commit | 480cca16eda4a174240ac6c3bf9722f762791f03 (patch) | |
tree | 317d6b1ac1caf2496545fd2e3f6b2b5b19220bdd | |
parent | bug fix (diff) | |
download | adjbacklight-480cca16eda4a174240ac6c3bf9722f762791f03.tar.gz adjbacklight-480cca16eda4a174240ac6c3bf9722f762791f03.tar.bz2 adjbacklight-480cca16eda4a174240ac6c3bf9722f762791f03.tar.xz |
final touches
Signed-off-by: Mattias Andrée <maandree@operamail.com>
Diffstat (limited to '')
-rw-r--r-- | .gitignore | 8 | ||||
-rw-r--r-- | Adjbacklight.java | 21 | ||||
-rw-r--r-- | Makefile | 25 | ||||
-rwxr-xr-x | adjbacklight | 92 |
4 files changed, 140 insertions, 6 deletions
@@ -7,3 +7,11 @@ .\#* *.swp *.bak +*.pdf +*.ps +*.dvi +*.info + +/dist/*/*/*/ +*.gz +*.xz diff --git a/Adjbacklight.java b/Adjbacklight.java index 7580208..597b575 100644 --- a/Adjbacklight.java +++ b/Adjbacklight.java @@ -1,7 +1,7 @@ /** * adjbacklight – Convient method for adjusting the backlight on your portable computer * - * Copyright © 2012 Mattias Andrée (maandree@kth.se) + * Copyright © 2012, 2013 Mattias Andrée (maandree@member.fsf.org) * * 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 @@ -21,10 +21,18 @@ import java.util.*; /** - * @author Mattias Andrée, <a href="mailto:maandree@kth.se">maandree@kth.se</a> + * Interactive backlight adjustment + * + * @author Mattias Andrée, <a href="mailto:maandree@member.fsf.org">maandree@member.fsf.org</a> */ public class Adjbacklight { + /** + * The is the main entry point of the program + * + * @param args Expects the three values: terminal height, terminal width, backlight device + * @throws IOException On error + */ public static void main(final String... args) throws IOException { String dir = "/sys/class/backlight/" + args[2] + "/"; @@ -95,6 +103,15 @@ public class Adjbacklight } } + /** + * Print the status + * + * @param min The minimum possible brightness + * @param max The maximum possible brightness + * @param init The brightness used when the program started + * @param cur The current brightness + * @param width The width of the terminal + */ private static void print(int min, int max, int init, int cur, int width) { String line = "──────────────────────────────────"; @@ -1,15 +1,36 @@ +# Copyright © 2012, 2013 Mattias Andrée (maandree@member.fsf.org) +# +# Copying and distribution of this file, with or without modification, +# are permitted in any medium without royalty provided the copyright +# notice and this notice are preserved. This file is offered as-is, +# without any warranty. +# +# [GNU All Permissive License] + + +PREFIX=/usr + + +# compile the package all: javac -cp . Adjbacklight.java +# install to system install: mkdir -p $(DESTDIR)$(PREFIX)/bin - install -m 775 adjbacklight $(DESTDIR)$(PREFIX)/bin/ - install -m 664 Adjbacklight.class $(DESTDIR)$(PREFIX)/bin/ + mkdir -p $(DESTDIR)$(PREFIX)/share/licenses + install -m 755 adjbacklight $(DESTDIR)$(PREFIX)/bin/ + install -m 644 Adjbacklight.class $(DESTDIR)$(PREFIX)/bin/ + install -m 644 COPYING $(DESTDIR)$(PREFIX)/share/licenses/adjbacklight + install -m 644 LICENSE $(DESTDIR)$(PREFIX)/share/licenses/adjbacklight +# remove files created by `install` uninstall: unlink $(DESTDIR)$(PREFIX)/bin/Adjbacklight.class unlink $(DESTDIR)$(PREFIX)/bin/adjbacklight + rm -r $(DESTDIR)$(PREFIX)/share/licenses/adjbacklight +# remove files created by `all` clean: rm Adjbacklight.class diff --git a/adjbacklight b/adjbacklight index 6291986..8adc413 100755 --- a/adjbacklight +++ b/adjbacklight @@ -2,7 +2,7 @@ # adjbacklight – Convient method for adjusting the backlight on your portable computer # -# Copyright © 2012 Mattias Andrée (maandree@kth.se) +# Copyright © 2012, 2013 Mattias Andrée (maandree@member.fsf.org) # # 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 @@ -18,6 +18,94 @@ # along with this program. If not, see <http://www.gnu.org/licenses/>. +if (( $# > 0 )); then + for arg in "$@"; do + case "$arg" in + ("-c" | "--copyright" | "--copying") + cat <<. + + +adjbacklight – Convient method for adjusting the backlight on your portable computer + +Copyright © 2012, 2013 Mattias Andrée (maandree@member.fsf.org) + +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 3 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, see <http://www.gnu.org/licenses/>. + + +. + exit 0 + ;; + ("-w" | "--warranty") + cat <<. + + +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. + + +. + exit 0 + ;; + esac + done + cat <<. + + +adjbacklight – Convient method for adjusting the backlight on your portable computer + +USAGE: adjbacklight [ -c | -w ] + +Run with options to adjust the backlight on your screens. + + +OPTIONS: + +-c +--copyright +--copying Display copyright information + +-w +--warranty Display warranty disclaimer + + +KEYBOARD: + +← +↓ Darken the screen + +→ +↑ Brighten the screen + +q +enter +C-d Continue to next controller, or if at last, quit + + + +Copyright © 2012, 2013 Mattias Andrée (maandree@member.fsf.org) + +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 3 of the License, or +(at your option) any later version. +. + exit 0 +fi + + cat <<. @@ -35,7 +123,7 @@ on the terminal, the following commands should reset it: stty -icanon -echo if [[ $? = 0 ]]; then echo -en '\033[?25l' - for dir in $(ls -1 --color=no "/sys/class/backlight/" | grep -v '^acpi_video'); do + 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' |