different-name / nix-files

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

Disable Mako while sharing screen #46

Open different-name opened 1 month ago

different-name commented 1 month ago

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

different-name commented 1 month 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