Skip to content

Commit

Permalink
pkgs/profpatsch/display-infos: display free memory
Browse files Browse the repository at this point in the history
  • Loading branch information
Profpatsch committed Nov 29, 2024
1 parent 621089b commit f18e2d8
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions pkgs/profpatsch/display-infos/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ let
import subprocess as sub
import os.path as path
import statistics as st
import jc
def readint(fn):
with open(fn, 'r') as f:
Expand Down Expand Up @@ -56,24 +57,28 @@ let
dottime = sub.run(["date", "--utc", "+%H·%M"], stdout=sub.PIPE).stdout.strip().decode()
sftdate = sub.run(["@sfttime@"], stdout=sub.PIPE).stdout.strip().decode()
load = get_5_min_load()
notify = "BAT: {percent}% {ac}{charge}{{{load}}} | {date} | {sftdate} | {dottime}".format(
free_mem_gibi = jc.parse('free', sub.check_output(['free', '--gibi'], text=True))[0]['available']
notify = "BAT: {percent}% {ac}{charge}{{{load}, {free_mem_gibi}G}} | {date} | {sftdate} | {dottime}".format(
percent = int(bat*100),
ac = ac,
charge = "{} ".format(sft_remaining) if seconds_remaining else "",
load = load,
free_mem_gibi = free_mem_gibi,
date = date,
sftdate = sftdate,
dottime = dottime
)
print(notify)
'';

python = python3.withPackages (pp: [ pp.jc ]);

in
with lib; runCommandLocal "display-infos" {
meta.description = "Script to display time & battery";
} ''
substitute ${script} script \
--replace "@python3@" "${getBin python3}/bin/python3" \
--replace "@python3@" "${getBin python}/bin/python3" \
--replace "@bc@" "${getBin bc}/bin/bc" \
--replace "@sfttime@" "${getBin sfttime}/bin/sfttime"
install -D script $out/bin/display-infos
Expand Down

0 comments on commit f18e2d8

Please sign in to comment.