swaync/feedbackd: activate ringer on incoming dino call

This commit is contained in:
Colin 2023-09-16 05:06:41 +00:00
parent 254da7e17b
commit 81c16ec479
2 changed files with 72 additions and 3 deletions

View File

@ -23,6 +23,32 @@ in
# N.B.: feedbackd will load ~/.config/feedbackd/themes/default.json by default
# - but using that would forbid `parent-theme = "default"`
# the default theme ships support for these events:
# - alarm-clock-elapsed
# - alarm-clock-elapsed
# - battery-caution
# - bell-terminal
# - button-pressed
# - button-released
# - camera-focus
# - camera-shutter
# - message-missed-email
# - message-missed-instant
# - message-missed-notification
# - message-missed-sms
# - message-new-email
# - message-new-instant
# - message-new-sms
# - message-sent-instant
# - phone-failure
# - phone-hangup
# - phone-incoming-call
# - phone-missed-call
# - phone-outgoing-busy
# - screen-capture
# - theme-demo
# - timeout-completed
# - window-close
fs.".config/feedbackd/themes/proxied.json".symlink.text = builtins.toJSON {
name = "proxied";
parent-theme = "default";
@ -40,6 +66,12 @@ in
type = "Sound";
effect = "message-new-instant";
}
{
# i guess we aren't actually inheriting from the default theme?
event-name = "phone-incoming-call";
type = "Sound";
effect = "phone-incoming-call";
}
];
}
];

View File

@ -21,24 +21,49 @@ let
name = "swaync-fbcli";
runtimeInputs = [
config.sane.programs.feedbackd.package
pkgs.procps # for pkill
cfg.package
];
text = ''
# if in Do Not Disturb, don't do any feedback
# TODO: better solution is to actually make use of feedbackd profiles.
# i.e. set profile to `quiet` when in DnD mode
if [ "$(swaync-client --get-dnd)" = "true" ]; then
if [ "$SWAYNC_URGENCY" != "Critical" ] && [ "$(swaync-client --get-dnd)" = "true" ]; then
exit
fi
# kill children if killed, to allow that killing this parent process will end the real fbcli call
cleanup() {
echo "aborting fbcli notification (PID $child)"
pkill -P "$child"
exit 0 # exit cleanly to avoid swaync alerting a script failure
}
trap cleanup SIGINT SIGQUIT SIGTERM
# feedbackd stops playback when the caller exits
# and fbcli will exit immediately if it has no stdin.
# so spoof a stdin:
true | fbcli "$@"
/bin/sh -c "true | fbcli $*" &
child=$!
wait
'';
};
fbcli = "${fbcli-wrapper}/bin/swaync-fbcli";
# we do this because swaync's exec naively splits the command on space to produce its argv, rather than parsing the shell.
# [ "pkill" "-f" "fbcli" "--event" ... ] -> breaks pkill
# [ "pkill" "-f" "fbcli --event ..." ] -> is what we want
fbcli-stop-wrapper = pkgs.writeShellApplication {
name = "fbcli-stop";
runtimeInputs = [
pkgs.procps # for pkill
];
text = ''
pkill -e -f "${fbcli} $*"
'';
};
fbcli-stop = "${fbcli-stop-wrapper}/bin/fbcli-stop";
systemctl-toggle = pkgs.writeShellApplication {
name = "systemctl-toggle";
runtimeInputs = [
@ -152,9 +177,21 @@ in
# - SWAYNC_SUMMARY
sound-im = {
# trigger notification sound on behalf of these IM clients.
# TODO: dispatch calls separately!
exec = "${fbcli} --event proxied-message-new-instant";
app-name = "(Chats|Dino|discord|Element)";
body = "^(?!Incoming call).*$"; #< don't match Dino Incoming calls
};
sound-call = {
exec = "${fbcli} --event phone-incoming-call -t 20";
app-name = "Dino";
body = "^Incoming call$";
};
sound-call-end = {
# pkill will kill all processes matching -- not just the first
exec = "${fbcli-stop} --event phone-incoming-call -t 20";
app-name = "Dino";
body = "^Incoming call$";
run-on = "action";
};
};
notification-visibility = {