65 lines
1.8 KiB
Nix
65 lines
1.8 KiB
Nix
|
{
|
||
|
pkgs,
|
||
|
config,
|
||
|
...
|
||
|
}: let
|
||
|
passwords = import ../../variables/passwords.crypt.nix;
|
||
|
in {
|
||
|
services.espanso = {
|
||
|
enable = true;
|
||
|
settings = {
|
||
|
matches = let
|
||
|
playerctl = ''
|
||
|
${pkgs.coreutils}/bin/env DBUS_SESSION_BUS_ADDRESS="unix:path=/run/user/$(${pkgs.coreutils}/bin/id -u)/bus" ${pkgs.playerctl}/bin/playerctl'';
|
||
|
in [
|
||
|
{
|
||
|
trigger = ":vpos";
|
||
|
replace = "{{output}}";
|
||
|
vars = [
|
||
|
{
|
||
|
name = "output";
|
||
|
type = "script";
|
||
|
params = {
|
||
|
args = [
|
||
|
(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))
|
||
|
'')
|
||
|
];
|
||
|
};
|
||
|
}
|
||
|
];
|
||
|
}
|
||
|
{
|
||
|
trigger = ":vtit";
|
||
|
replace = "{{output}}";
|
||
|
vars = [
|
||
|
{
|
||
|
name = "output";
|
||
|
type = "script";
|
||
|
params = {
|
||
|
args = [
|
||
|
(pkgs.writeShellScript "espanso"
|
||
|
"${playerctl} metadata title")
|
||
|
];
|
||
|
};
|
||
|
}
|
||
|
];
|
||
|
}
|
||
|
{
|
||
|
trigger = ":dunno";
|
||
|
replace = "¯\\_(ツ)_/¯";
|
||
|
}
|
||
|
];
|
||
|
};
|
||
|
};
|
||
|
}
|