script optimization
All checks were successful
Activate Homelab Configuration / rebuild (push) Successful in 16s
All checks were successful
Activate Homelab Configuration / rebuild (push) Successful in 16s
This commit is contained in:
parent
c3d19551ee
commit
eabea04a14
1 changed files with 4 additions and 3 deletions
|
|
@ -13,9 +13,10 @@
|
||||||
cron = {
|
cron = {
|
||||||
enable = true;
|
enable = true;
|
||||||
systemCronJobs = [
|
systemCronJobs = [
|
||||||
"* * * * * ${username} bash -x ${pkgs.writeShellScript "low-battery-notifier" ''
|
"*/2 * * * * ${username} bash ${pkgs.writeShellScript "low-battery-notifier" ''
|
||||||
BAT_PCT=`${pkgs.acpi}/bin/acpi -b | ${pkgs.gnugrep}/bin/grep -P -o '[0-9]+(?=%)'`
|
ACPI_OUT=$(${pkgs.acpi}/bin/acpi -b)
|
||||||
BAT_STA=`${pkgs.acpi}/bin/acpi -b | ${pkgs.gnugrep}/bin/grep -P -o '\w+(?=,)'`
|
BAT_PCT=`echo "$ACPI_OUT" | ${pkgs.gnugrep}/bin/grep -P -o '[0-9]+(?=%)'`
|
||||||
|
BAT_STA=`echo "$ACPI_OUT" | ${pkgs.gnugrep}/bin/grep -P -o '\w+(?=,)'`
|
||||||
echo "`date` battery status:$BAT_STA percentage:$BAT_PCT"
|
echo "`date` battery status:$BAT_STA percentage:$BAT_PCT"
|
||||||
export DISPLAY=:0
|
export DISPLAY=:0
|
||||||
export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/$(id -u)/bus
|
export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/$(id -u)/bus
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue