From 52bc2bed04f7c3fa4a86ba69f89c2b546829ec40 Mon Sep 17 00:00:00 2001 From: cuu Date: Fri, 14 Dec 2018 18:20:09 +0800 Subject: [PATCH] add lowpower.sh --- sys.py/gsnotify/Jobs/00_lowpower.alias | 1 + sys.py/gsnotify/Jobs/00_lowpower.sh | 17 +++++++++++++++++ 2 files changed, 18 insertions(+) create mode 100644 sys.py/gsnotify/Jobs/00_lowpower.alias create mode 100644 sys.py/gsnotify/Jobs/00_lowpower.sh diff --git a/sys.py/gsnotify/Jobs/00_lowpower.alias b/sys.py/gsnotify/Jobs/00_lowpower.alias new file mode 100644 index 0000000..71617b6 --- /dev/null +++ b/sys.py/gsnotify/Jobs/00_lowpower.alias @@ -0,0 +1 @@ +Low Battery Warning diff --git a/sys.py/gsnotify/Jobs/00_lowpower.sh b/sys.py/gsnotify/Jobs/00_lowpower.sh new file mode 100644 index 0000000..af920d7 --- /dev/null +++ b/sys.py/gsnotify/Jobs/00_lowpower.sh @@ -0,0 +1,17 @@ +#!/bin/bash + +BAT_PNT=`upower -i $(upower -e | grep 'battery') | grep -E "state|to\ full|percentage" | awk '/perc/{print $2}' | cut -d % -f1 ` + +if [ "$BAT_PNT" -lt "20" ]; then + + if [ "$BAT_PNT" -lt "10" ]; then + echo '{"type":"once","content":"Low Battery: 10% of battery remaining"}' + fi + + if [ "$BAT_PNT" -lt "5" ]; then + echo '{"type":"once","content":"Low Battery: 10% of battery remaining"}' + fi + +else + echo $BAT_PNT +fi