about summary refs log tree commit diff
path: root/pkgs/profpatsch/display-infos
diff options
context:
space:
mode:
authorProfpatsch <mail@profpatsch.de>2019-04-20 19:30:14 +0200
committerProfpatsch <mail@profpatsch.de>2019-04-20 19:36:04 +0200
commit6480ee5b9e05a763eef929250bf14acaa8631202 (patch)
treefeccb44b13394b83e9dc08b8317836d047880acf /pkgs/profpatsch/display-infos
parentd81c4dcc1ec84033ecdceb348a681759f329ca6c (diff)
pkgs/profpatsch/display-infos: add sfttime and AC charger
Diffstat (limited to 'pkgs/profpatsch/display-infos')
-rw-r--r--pkgs/profpatsch/display-infos/default.nix15
1 files changed, 9 insertions, 6 deletions
diff --git a/pkgs/profpatsch/display-infos/default.nix b/pkgs/profpatsch/display-infos/default.nix
index d213241c..9dc510cd 100644
--- a/pkgs/profpatsch/display-infos/default.nix
+++ b/pkgs/profpatsch/display-infos/default.nix
@@ -1,8 +1,8 @@
-{ lib, runCommand, python3, libnotify }:
+{ lib, runCommand, writeText, python3, libnotify, sfttime }:
 
 let
   name = "display-infos-0.1.0";
-  script = builtins.toFile (name + "-script") ''
+  script = writeText (name + "-script") ''
     #!@python3@
 
     import sys
@@ -11,19 +11,22 @@ let
     import os.path as path
     import statistics as st
 
+    def readint(fn):
+        with open(fn, 'r') as f:
+            return int(f.read())
+
     full = 0
     now  = 0
     for bat in glob.iglob("/sys/class/power_supply/BAT*"):
-        def readint(fn):
-            with open(fn, 'r') as f:
-                return int(f.read())
 
         full += readint(path.join(bat, "energy_full"))
         now  += readint(path.join(bat, "energy_now" ))
 
     bat = round( now/full, 2 )
+    ac = "🗲" if readint("/sys/class/power_supply/AC/online") else ""
     date = sub.run(["date", "+%d.%m. %a %T"], stdout=sub.PIPE).stdout.strip().decode()
-    notify = "BAT: {}% | {}".format(int(bat*100), date)
+    sfttime = sub.run(["${sfttime}/bin/sfttime"], stdout=sub.PIPE).stdout.strip().decode()
+    notify = "BAT: {}% {} | {} | {}".format(int(bat*100), ac, date, sfttime)
     sub.run(["@notify-send@", notify])
   '';