summarylogtreecommitdiffstats
diff options
context:
space:
mode:
authorparchd2015-06-13 08:55:06 +0200
committerparchd2015-06-13 08:55:06 +0200
commit3c1a1fe504a2b34b537ed79c15be0320dd78e519 (patch)
treefbc00d75c468d1c0fb3000a2fe247d1c24447c1d
downloadaur-3c1a1fe504a2b34b537ed79c15be0320dd78e519.tar.gz
Remove comma and submit to AUR4
-rw-r--r--.SRCINFO20
-rw-r--r--PKGBUILD26
-rwxr-xr-xbatterylife30
-rw-r--r--batterylife.service6
-rw-r--r--batterylife.timer10
5 files changed, 92 insertions, 0 deletions
diff --git a/.SRCINFO b/.SRCINFO
new file mode 100644
index 000000000000..a7aa21fb15f1
--- /dev/null
+++ b/.SRCINFO
@@ -0,0 +1,20 @@
+pkgbase = batterylife
+ pkgdesc = Help user keep battery between 40 and 80%
+ pkgver = 1
+ pkgrel = 1
+ url = https://bbs.archlinux.org/viewtopic.php?pid=1431917
+ arch = i686
+ arch = x86_64
+ license = GPL
+ depends = pulseaudio
+ depends = acpi
+ depends = libnotify
+ source = batterylife
+ source = batterylife.timer
+ source = batterylife.service
+ md5sums = SKIP
+ md5sums = SKIP
+ md5sums = SKIP
+
+pkgname = batterylife
+
diff --git a/PKGBUILD b/PKGBUILD
new file mode 100644
index 000000000000..3e8546e9aef1
--- /dev/null
+++ b/PKGBUILD
@@ -0,0 +1,26 @@
+# This is an example PKGBUILD file. Use this as a start to creating your own,
+# and remove these comments. For more information, see 'man PKGBUILD'.
+# NOTE: Please fill out the license field for your package! If it is unknown,
+# then please put 'unknown'.
+
+# Maintainer: parchd
+pkgname=batterylife
+pkgver=1
+pkgrel=1
+pkgdesc="Help user keep battery between 40 and 80%"
+url="https://bbs.archlinux.org/viewtopic.php?pid=1431917"
+license=('GPL')
+groups=()
+depends=('pulseaudio' 'acpi' 'libnotify')
+arch=('i686' 'x86_64')
+source=('batterylife'
+ 'batterylife.timer'
+ 'batterylife.service')
+
+md5sums=('SKIP' 'SKIP' 'SKIP')
+
+package() {
+ install -Dm644 "$srcdir/$pkgname.service" "$pkgdir/etc/systemd/system/$pkgname.service"
+ install -Dm644 "$srcdir/$pkgname.timer" "$pkgdir/etc/systemd/system/$pkgname.timer"
+ install -Dm755 "$srcdir/$pkgname" "$pkgdir/usr/bin/$pkgname"
+}
diff --git a/batterylife b/batterylife
new file mode 100755
index 000000000000..578f981486e2
--- /dev/null
+++ b/batterylife
@@ -0,0 +1,30 @@
+#! /bin/bash
+BELOWFILE=/tmp/batblo
+ABOVEFILE=/tmp/batabo
+MIN=40
+MAX=80
+
+notify-send-all(){
+ for p in $(pgrep gconf-helper); do
+ dbus=$(grep -z DBUS_SESSION_BUS_ADDRESS /proc/$p/environ | sed 's/DBUS_SESSION_BUS_ADDRESS=//')
+ user=$(grep -m 1 -z USER /proc/$p/environ | sed 's/USER=//')
+ dply=$(grep -z DISPLAY /proc/$p/environ | sed 's/DISPLAY=//')
+ sudo -u $user sh -c "DBUS_SESSION_BUS_ADDRESS=\"$dbus\" DISPLAY=\"$dply\" notify-send $@"
+ done
+}
+
+if [ `acpi|grep -Po "[0-9]+(?=%)"` -le $MIN ]; then
+ if [ ! -f $BELOWFILE ]; then
+ notify-send-all "-i battery \"Battery at $MIN%\" \"Do you want to plug it in?\""
+ touch $BELOWFILE
+ rm $ABOVEFILE 2>/dev/null
+ fi
+elif [ `acpi|grep -Po "[0-9]+(?=%)"` -ge $MAX ]; then
+ if [ ! -f $ABOVEFILE ]; then
+ notify-send-all "-i battery \"Battery at $MAX%\" \"Do you want to unplug it?\""
+ rm $BELOWFILE 2>/dev/null
+ touch $ABOVEFILE
+ fi
+else
+ rm $BELOWFILE $ABOVEFILE 2>/dev/null
+fi
diff --git a/batterylife.service b/batterylife.service
new file mode 100644
index 000000000000..e09f1d3bbaff
--- /dev/null
+++ b/batterylife.service
@@ -0,0 +1,6 @@
+[Unit]
+Description=Help user keep battery between 40 and 80%
+
+[Service]
+Type=simple
+ExecStart=/usr/bin/batterylife
diff --git a/batterylife.timer b/batterylife.timer
new file mode 100644
index 000000000000..7acba62b3426
--- /dev/null
+++ b/batterylife.timer
@@ -0,0 +1,10 @@
+[Unit]
+Description=Help user keep battery between 40 and 80%
+
+[Timer]
+OnBootSec=10m
+OnUnitInactiveSec=60
+Unit=batterylife.service
+
+[Install]
+WantedBy=multi-user.target