aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--crontab/laptop.crontab3
-rwxr-xr-xinstall11
-rwxr-xr-xlocal/bin/battery-low-check5
-rwxr-xr-xlocal/bin/battery-low-notify14
4 files changed, 26 insertions, 7 deletions
diff --git a/crontab/laptop.crontab b/crontab/laptop.crontab
new file mode 100644
index 0000000..18f36f1
--- /dev/null
+++ b/crontab/laptop.crontab
@@ -0,0 +1,3 @@
+*/10 * * * * . $HOME/.zprofile ; DBUS_SESSION_BUS_ADDRESS="unix:path=/run/user/$(id -u $USER)/bus" DISPLAY=:0 battery-low-notify
+
+# vim:ft=crontab
diff --git a/install b/install
index 2c6ee73..892e845 100755
--- a/install
+++ b/install
@@ -6,7 +6,7 @@
if [ "$USER" = 'root' ]
then
- crontab 'crontab/root.crontab'
+ crontab crontab/root.crontab
exit
fi
@@ -96,7 +96,14 @@ parallel_wait
###############################################################################
echo '---------------------------- INSTALL CRONTAB -----------------------------'
-crontab 'crontab/user.crontab'
+
+if [ "$(hostname)" = 'charleslaptopcarbon' ]
+then
+ cat crontab/user.crontab crontab/laptop.crontab | crontab -
+else
+ crontab crontab/user.crontab
+fi
+
echo 'INFO: Run this script as root if you want to install the root contab'
###############################################################################
diff --git a/local/bin/battery-low-check b/local/bin/battery-low-check
deleted file mode 100755
index dbbdc6b..0000000
--- a/local/bin/battery-low-check
+++ /dev/null
@@ -1,5 +0,0 @@
-#!/bin/sh
-
-capacity=$(cat /sys/class/power_supply/BAT0/capacity)
-
-[ "$capacity" -lt 10 ] && notify-send -u critical "Battery low $capacity%"
diff --git a/local/bin/battery-low-notify b/local/bin/battery-low-notify
new file mode 100755
index 0000000..605ea91
--- /dev/null
+++ b/local/bin/battery-low-notify
@@ -0,0 +1,14 @@
+#!/bin/sh
+
+battery_dir='/sys/class/power_supply/BAT0'
+
+[ ! -d "$battery_dir" ] && exit 1
+
+if [ "$(cat "$battery_dir/status")" != 'Charging' ]
+then
+ capacity="$(cat "$battery_dir/capacity")"
+ [ "$capacity" -lt 15 ] &&
+ notify-send -u critical "Battery low: $capacity%"
+fi
+
+exit 0