different-name / nix-files

My NixOS configuration files
GNU General Public License v3.0
9 stars 0 forks source link

Notification DND keybind #46

Open different-name opened 4 months ago

different-name commented 3 months ago

Mako modes enable disabling notifications via makoctl https://www.github.com/emersion/mako/issues/335

different-name commented 3 months ago

Created a script as a proof of concept using makoctl and a do-not-disturb mode

#! /usr/bin/env nix-shell
#! nix-shell -i sh -p socat mako pipewire

# handle screencast events
handle_screencast() {
    event_data="$1" # event data e.g. "screencast>>1,0"
    echo "Hyprland screencast event: \"$event_data\""

    data="${event_data#screencast>>}" # trim "screencast>>"

    # janky way to check if there's currently a screencast client
    echo "Checking for current screencast clients"
    if pw-cli info all | grep -q '.xdg-desktop-portal-hyprland-wrapped:capture'; then
        echo "Hiding notifications"
        makoctl mode -a do-not-disturb # hide notifications
    else
        echo "Displaying notifications"
        makoctl mode -r do-not-disturb # show notifications
    fi
}

# listening for hyprland events
# https://wiki.hyprland.org/IPC/#how-to-use-socket2-with-bash

SOCKET_PATH="$XDG_RUNTIME_DIR/hypr/$HYPRLAND_INSTANCE_SIGNATURE/.socket2.sock"

socat -U - UNIX-CONNECT:$SOCKET_PATH | while read -r line; do
    case "$line" in
        screencast*) handle_screencast "$line" ;;
        *);;
    esac
done
services.mako.extraConfig = ''
  [mode=do-not-disturb]
  invisible=1
'';

Would like to create a c application that interfaces with the pipewire api, this is what waybar does (though cpp)

I'd like to use c as that's what mako uses, and might be cool to adapt this into a pull request for a config option or something

https://github.com/Alexays/Waybar/blob/21906f07b312d56f51ce7cd2b26925cd12880ada/src/util/pipewire/pipewire_backend.cpp

different-name commented 2 weeks ago

I think a simple toggle bind would be far more effective and easier