feat(hyprrecord): move recording script to seperate flake

This commit is contained in:
ooks-io 2024-03-17 20:12:15 +13:00
parent 1294cf04e9
commit 7655485e8f
5 changed files with 8 additions and 62 deletions

View file

@ -52,6 +52,11 @@
inputs.nixpkgs.follows = "nixpkgs";
};
hyprrecord = {
url = "github:ooks-io/hyprrecord";
inputs.nixpkgs.follows = "nixpkgs";
};
hyprpaper.url = "github:hyprwm/hyprpaper";
helix = {

View file

@ -1,7 +1,7 @@
{ lib, config, pkgs, inputs, ... }:
let
cfg = config.homeModules.desktop.wayland.windowManager.hyprland;
inherit (import ./pkgs {inherit pkgs;}) hyprrecord hyprbrightness hyprvolume hyprkillsession;
inherit (import ./pkgs {inherit pkgs;}) hyprbrightness hyprvolume hyprkillsession;
in
{
imports = [
@ -22,8 +22,8 @@ in
hyprvolume
hyprkillsession
hyprbrightness
hyprrecord
];
inputs.hyprrecord.packages.${pkgs.system}.hyprrecord
];
wayland.windowManager.hyprland = {
enable = true;

View file

@ -4,7 +4,6 @@ let
packages = {
hyprvolume = pkgs.callPackage ./hyprvolume.nix {};
hyprbrightness = pkgs.callPackage ./hyprbrightness.nix {};
hyprrecord = pkgs.callPackage ./hyprrecord {};
# Script to help Hyprland quit https://github.com/hyprwm/Hyprland/issues/3558#issuecomment-1848768654
hyprkillsession = pkgs.callPackage ./hyprkillsession.nix {};
};

View file

@ -1,10 +0,0 @@
{ pkgs, ... }:
pkgs.writeShellScriptBin "hyprrecord" ''
${builtins.readFile ./hyprrecord.sh}
''

View file

@ -1,48 +0,0 @@
#!/usr/bin/env bash
getTargetDirectory() {
test -f "${XDG_CONFIG_HOME:-$HOME/.config}/user-dirs.dirs" &&
. "${XDG_CONFIG_HOME:-$HOME/.config}/user-dirs.dirs"
echo "${XDG_RECORDINGS_DIR:-${XDG_VIDEOS_DIR:-$HOME}}"
}
SINK="$(pactl get-default-sink).monitor"
AUDIO=""
FILE="--file=$(getTargetDirectory)/$(date -Ins).mp4"
SET_REGION=false
while [[ "$#" -gt 0 ]]; do
case $1 in
-a | --audio)
AUDIO="--audio=$SINK"
shift
;;
-r | --region)
SET_REGION=true
shift
;;
*)
echo "Unknown parameter passed: $1"
exit 1
;;
esac
done
notify() {
notify-send -t 5000 -a system-notify "$@"
}
takeRecording() {
if pgrep -x "wf-recorder" >/dev/null; then
pkill -x "wf-recorder"
notify "Recording Stopped"
else
# Only invoke slurp if starting a new recording and the region option was set
if [ "$SET_REGION" = true ]; then
REGION="--geometry=$(slurp)"
fi
wf-recorder "$AUDIO" "$REGION" "$FILE"
fi
}
echo $(takeRecording)