From 82e972ffa775dd40bcb4268834f2e1125307e840 Mon Sep 17 00:00:00 2001 From: denes Date: Tue, 23 Jul 2019 12:04:21 +0200 Subject: [PATCH] Replacing the links from github to gitea.matetelki.eu --- .../battery-status-led-0.1.ebuild | 4 +- battery-status-led.1 | 4 +- debian/package-deb.sh | 4 +- redhat/build/README.md | 64 +++++++++++++++++ redhat/build/battery-status-led | 70 +++++++++++++++++++ redhat/build/battery-status-led.1 | 38 ++++++++++ redhat/build/battery-status-led.service | 10 +++ redhat/build/battery-status-led.spec | 46 ++++++++++++ redhat/package-rpm | 6 +- 9 files changed, 237 insertions(+), 9 deletions(-) create mode 100644 redhat/build/README.md create mode 100755 redhat/build/battery-status-led create mode 100644 redhat/build/battery-status-led.1 create mode 100644 redhat/build/battery-status-led.service create mode 100644 redhat/build/battery-status-led.spec diff --git a/app-misc/battery-status-led/battery-status-led-0.1.ebuild b/app-misc/battery-status-led/battery-status-led-0.1.ebuild index 006ed03..e503fa5 100644 --- a/app-misc/battery-status-led/battery-status-led-0.1.ebuild +++ b/app-misc/battery-status-led/battery-status-led-0.1.ebuild @@ -6,9 +6,9 @@ EAPI=6 inherit git-r3 systemd linux-info DESCRIPTION="Battery (low/critical) status indication by making a (the capslock) LED blink" -HOMEPAGE="https://github.com/dmatetelki/battery-status-led" +HOMEPAGE="https://gitea.matetelki.eu/denes/battery-status-led" SRC_URI="" -EGIT_REPO_URI="https://github.com/dmatetelki/battery-status-led" +EGIT_REPO_URI="https://gitea.matetelki.eu/denes/battery-status-led.git" LICENSE="GPL-3" SLOT="0" diff --git a/battery-status-led.1 b/battery-status-led.1 index f56110f..f468c6c 100644 --- a/battery-status-led.1 +++ b/battery-status-led.1 @@ -18,14 +18,14 @@ to something else. The default value is .I /sys/class/leds/input4\:\:capslock .SH AUTHOR -.MT denes.matetelki@gmail.com +.MT denes@matetelki.com Denes Matetelki .ME .SH SEE ALSO Homepage: -.UR https://github.com/dmatetelki/battery-status-led/ +.UR https://gitea.matetelki.eu/denes/battery-status-led .UE .br diff --git a/debian/package-deb.sh b/debian/package-deb.sh index 2569ee6..5d7aee7 100755 --- a/debian/package-deb.sh +++ b/debian/package-deb.sh @@ -29,7 +29,7 @@ Version: ${VERSION} Section: misc Priority: optional Architecture: amd64 -Maintainer: Denes Matetelki +Maintainer: Denes Matetelki Description: Blink a LED on low battery Battery (low/critical) status indication by making a (the capslock) LED blink" EOL @@ -65,7 +65,7 @@ battery-status-led (0.1-1) misc; urgency=low * Initial release - -- Denes Matetelki Fri, 31 Aug 2018 12:00:00 +0100 + -- Denes Matetelki Fri, 31 Aug 2018 12:00:00 +0100 EOL mkdir -m 0755 -p build/${NAME}_${VERSION}/lib/systemd/system diff --git a/redhat/build/README.md b/redhat/build/README.md new file mode 100644 index 0000000..ca747b7 --- /dev/null +++ b/redhat/build/README.md @@ -0,0 +1,64 @@ +# Battery Status LED +Battery (low/critical) status indication by making a (the capslock) LED blink + +## Prerequisites: +Make sure you have your laptop's ACPI module compiled into your kernel: +``` +Device Drivers > X86 Platform Specific Device Drivers +``` + +For example: Asus laptop extras, ThinkPad ACPI Laptop Extras, etc. + +## Usage: +Execute the script as a root user: +``` +/usr/bin/battery-status-led.sh +``` + +Or start with systemd: +``` +systemctl start battery-status-led +systemctl enable battery-status-led +``` + +The LED device can be changed by editing the systemd service file's line: +``` +Environment="BATTERY_STATUS_LED_DEV=/sys/class/leds/input4\:\:capslock" +``` + +## Manual install on gentoo: +``` +cd DIR +git clone https://github.com/dmatetelki/battery-status-led +cd /usr/local/portage/app-misc/ +ln -s DIR/battery-status-led/app-misc/battery-status-led battery-status-led +ebuild battery-status-led-0.1.ebuild digest +emerge battery-status-led +``` + +## Creating a debian package and installing it: +``` +cd DIR +git clone https://github.com/dmatetelki/battery-status-led +cd battery-status-led/debian +./package.deb +sudo dpkg -i ./batterystatusled_0.1-1.deb +``` + +## Creating RPM package and installing it: +``` +cd DIR +git clone https://github.com/dmatetelki/battery-status-led +cd battery-status-led/redhat +./package.rpm +sudo rpm -i ./battery-status-led-0.1-1.noarch.rpm +``` + +## Note: +Did you know that the CapsLock key can be turned into another Ctrl? +Add the following lines to `~/.Xmodmap` : +``` +remove Lock = Caps_Lock +keycode 0x42 = Control_L +add Control = Control_L +``` diff --git a/redhat/build/battery-status-led b/redhat/build/battery-status-led new file mode 100755 index 0000000..5bf6a4d --- /dev/null +++ b/redhat/build/battery-status-led @@ -0,0 +1,70 @@ +#!/bin/bash + +# Copyright 2018 Denes Matetelki + +# This file is part of battery-status-led. + +# battery-status-led is free software: you can redistribute it and/or modify it +# under the terms of the GNU General Public License v3 as published by the Free +# Software Foundation. + +# battery-status-led 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 v3 for +# more details. + +# You should have received a copy of the GNU General Public License v3 along +# with battery-status-led. If not, see +# https://www.gnu.org/licenses/gpl-3.0.html. + +# limits in percentages +LOW=10 # flip LED every 2s +CRIT=5 # flip led every 0.5s + +BAT_FULL_DEV=/sys/class/power_supply/BAT0/energy_full_design +BAT_STATUS_DEV=/sys/class/power_supply/BAT0/status +BAT_NOW_DEV=/sys/class/power_supply/BAT0/energy_now +CAPSLOCK_LED_DEV=/sys/class/leds/input4\:\:capslock/brightness + +# If not set by the systemd service file +LED_DEV=${BATTERY_STATUS_LED_DEV:-$CAPSLOCK_LED_DEV} + +BAT_FULL=$(cat $BAT_FULL_DEV) + +LED=0 +while : +do + # If charging, sleep 1m, then restart the cycle + STATUS=$(cat $BAT_STATUS_DEV) + if [ $STATUS == "Charging" ] ; then + echo 0 > $LED_DEV + sleep 1m + continue + fi + + BAT_NOW=$(cat $BAT_NOW_DEV) + BAT_PCT=$(($BAT_NOW * 100 / $BAT_FULL)) + + # If battery has more than >10% left, sleep 1m then restart the cycle + if (($BAT_PCT >= $LOW )) ; then + sleep 1m + continue + fi + + # If battery is on low, but not crytical, flip LED every 2s + if (( $BAT_PCT < $LOW )) && (( $BAT_PCT >= $CRIT)) ; then + LED=$((1 ^ $LED)) + echo $LED > $LED_DEV + sleep 2s + continue + fi + + # If battery is on crytical flip capslock LED every 0.5s + if (( $BAT_PCT < $CRIT )) ; then + LED=$((1 ^ $LED)) + echo $LED > $LED_DEV + sleep 0.5s + continue + fi +done + diff --git a/redhat/build/battery-status-led.1 b/redhat/build/battery-status-led.1 new file mode 100644 index 0000000..f56110f --- /dev/null +++ b/redhat/build/battery-status-led.1 @@ -0,0 +1,38 @@ +.TH BATTERY-STATUS-LED 1 LOCAL + +.SH NAME +.B battery-status-led +\- Blink a LED on low battery + +.SH SYNOPSIS +battery-status-led + +.SH DESCRIPTION +Battery (low/critical) status indication by making a (the capslock) LED blink + +Takes no argument. To pick another LED device, edit +.I /lib/systemd/system/battery-status-led.service +and modify +.I BATTERY_STATUS_LED_DEV +to something else. The default value is +.I /sys/class/leds/input4\:\:capslock + +.SH AUTHOR +.MT denes.matetelki@gmail.com +Denes Matetelki +.ME + +.SH SEE ALSO + +Homepage: +.UR https://github.com/dmatetelki/battery-status-led/ +.UE + +.br +Copyright © 2018 Denes Matetelki. +.br +License GPLv3+: GNU GPL version 3 or later . +.br +This is free software: you are free to change and redistribute it. +.br +There is NO WARRANTY, to the extent permitted by law. diff --git a/redhat/build/battery-status-led.service b/redhat/build/battery-status-led.service new file mode 100644 index 0000000..5096372 --- /dev/null +++ b/redhat/build/battery-status-led.service @@ -0,0 +1,10 @@ +[Unit] +Description=Battery monitoring on CapsLock LED + +[Service] +Environment="BATTERY_STATUS_LED_DEV=/sys/class/leds/input4\:\:capslock" +ExecStart="/usr/bin/battery-status-led.sh" +Type=idle + +[Install] +WantedBy=multi-user.target diff --git a/redhat/build/battery-status-led.spec b/redhat/build/battery-status-led.spec new file mode 100644 index 0000000..86b74ae --- /dev/null +++ b/redhat/build/battery-status-led.spec @@ -0,0 +1,46 @@ +Name: battery-status-led +Version: 0.1 +Release: 1%{?dist} +URL: https://github.com/dmatetelki/battery-status-led +Packager: Denes Matetelki + +Summary: Battery status indication on an LED + +Group: Utilities +License: GPLv3 +BuildArch: noarch + +Source0: battery-status-led.service +Source1: battery-status-led +Source2: README.md +Source3: battery-status-led.1 + +%description +Battery (low/critical) status indication by making a (the caps-lock) LED blink + +# %prep + +%install +mkdir -p %{buildroot}%{_unitdir} +install -p -m 0644 %{SOURCE0} %{buildroot}%{_unitdir} +mkdir -p %{buildroot}/%{_bindir} +install -p -m 755 %{SOURCE1} %{buildroot}/%{_bindir} +mkdir -p %{buildroot}/%{_docdir}/battery-status-led +install -p -m 0644 %{SOURCE2} %{buildroot}%{_docdir}/battery-status-led/ +mkdir -p %{buildroot}/%{_mandir}/man1 +install -p -m 0644 %{SOURCE3} %{buildroot}%{_mandir}/man1/ + +%clean +rm -rf %{buildroot} + +%files +%defattr(-,root,root,-) +%{_unitdir}/battery-status-led.service +%{_bindir}/battery-status-led +%{_docdir}/battery-status-led/README.md +%{_mandir}/man1/battery-status-led.1.* + +%changelog +* Fri Aug 31 2018 Denes Matetelki - 0.1-1 +- Initial release + diff --git a/redhat/package-rpm b/redhat/package-rpm index f4369d3..478c658 100755 --- a/redhat/package-rpm +++ b/redhat/package-rpm @@ -28,8 +28,8 @@ cat > build/${NAME}.spec < +URL: https://gitea.matetelki.eu/denes/battery-status-led +Packager: Denes Matetelki Summary: Battery status indication on an LED @@ -68,7 +68,7 @@ rm -rf %{buildroot} %{_mandir}/man1/${NAME}.1.* %changelog -* Fri Aug 31 2018 Denes Matetelki - 0.1-1 +* Fri Aug 31 2018 Denes Matetelki - 0.1-1 - Initial release EOL