I’ve setup the following keybindings to take a screenshot, and then play a camera sound:
{ config, lib, pkgs, ... }:
let
cfg = config.poperigby.desktops.sway;
sway = config.wayland.windowManager.sway;
in
{
config = lib.mkIf cfg.enable {
wayland.windowManager.sway.config.keybindings = let
mod = sway.config.modifier;
grim = "${pkgs.grim}/bin/grim";
slurp = "${pkgs.slurp}/bin/slurp";
screenshotLocation = "${config.xdg.userDirs.pictures}/Screenshots/$(date +'%s.png')";
screenshotSound = "${pkgs.alsa-utils}/bin/aplay ${./camera.wav}";
in lib.mkOptionDefault {
# Full screen
"Print" = "exec ${grim} ${screenshotLocation} && ${screenshotSound}";
# A region of the screen
"Control+Print" = "exec ${grim} -g $(${slurp}) ${screenshotLocation} && ${screenshotSound}";
};
};
}
The problem is, the only really seems to work sometimes. For the first keybinding, hitting it the first time only seems to play the ending of the clip, like the first part is cut off, the second time it seems to work fairly consistently. The second keybinding doesn’t play the sound at all.
I’m using Bluetooth headphones, if that matters.