73 lines
2.1 KiB
Nix
73 lines
2.1 KiB
Nix
{pkgs, ...}: {
|
|
services.espanso = {
|
|
# package = pkgs.espanso.overrideAttrs(_: {
|
|
# # src =
|
|
# })
|
|
enable = true;
|
|
configs = {
|
|
default = {
|
|
# backend = "Inject";
|
|
# backend = "Clipboard";
|
|
};
|
|
};
|
|
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 {
|
|
default = {
|
|
matches = [
|
|
{
|
|
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 = "¯\\_(ツ)_/¯";
|
|
}
|
|
{
|
|
trigger = ":shrug";
|
|
replace = "¯\\_(ツ)_/¯";
|
|
}
|
|
];
|
|
};
|
|
};
|
|
};
|
|
}
|