feat(qtile-desktop/espanso): :vpos display human readable time and timestamp

This commit is contained in:
steveej 2022-08-13 17:24:50 +02:00
parent 15f21b27dc
commit 9729abca54

View file

@ -320,9 +320,18 @@ in {
type = "script";
params = {
args = [
(pkgs.writeShellScript "espanso" ''
${playerctl} position''
)
(pkgs.writeScript "espanso" ''
#! ${pkgs.python3}/bin/python
import subprocess, os, math, datetime
id=str(os.getuid())
result=subprocess.run(args=["${pkgs.playerctl}/bin/playerctl", "position"], env={"DBUS_SESSION_BUS_ADDRESS": "unix:path=/run/user/"+id+"/bus"},capture_output=True)
result.check_returncode()
position_secs = math.trunc(float(result.stdout))
position_human = datetime.timedelta(seconds=position_secs)
print("%s - %s" % (position_human, position_secs))
'')
];
};
}