From 480cca16eda4a174240ac6c3bf9722f762791f03 Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Sun, 20 Jan 2013 19:24:27 +0100 Subject: final touches MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- .gitignore | 8 +++++ Adjbacklight.java | 21 +++++++++++-- Makefile | 25 +++++++++++++-- adjbacklight | 92 +++++++++++++++++++++++++++++++++++++++++++++++++++++-- 4 files changed, 140 insertions(+), 6 deletions(-) diff --git a/.gitignore b/.gitignore index b94d634..e84266e 100644 --- a/.gitignore +++ b/.gitignore @@ -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, maandree@kth.se + * Interactive backlight adjustment + * + * @author Mattias Andrée, maandree@member.fsf.org */ 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 = "──────────────────────────────────"; diff --git a/Makefile b/Makefile index 7ea9bab..a5a182a 100644 --- a/Makefile +++ b/Makefile @@ -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 . +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 . + + +. + 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' -- cgit v1.2.3-70-g09d2