refactor(hypr): use screen-cap as a nix package

This commit is contained in:
Price Hiller 2024-06-22 05:50:05 -05:00
parent 3c121195e4
commit f980f035c0
Signed by: Price
GPG Key ID: C3FADDE7A8534BEB
5 changed files with 23 additions and 14 deletions

View File

@ -4,6 +4,7 @@
rustPlatform = pkgs.rustPlatform;
fetchFromGitHub = pkgs.fetchFromGitHub;
};
screen-cap = pkgs.callPackage ./screen-cap/default.nix { };
Fmt = pkgs.writeShellApplication {
name = "Fmt";
runtimeInputs = with pkgs; [

View File

@ -0,0 +1,17 @@
{ pkgs }:
pkgs.writeShellApplication {
name = "screen-cap";
runtimeInputs = with pkgs; [
wl-screenrec
gifski
inotify-tools
libnotify
mktemp
slurp
file
];
text = ''
#!${pkgs.bash}/bin/bash
${builtins.readFile ./screen-cap.bash}
'';
}

View File

@ -1,14 +1,4 @@
#!/usr/bin/env -S nix shell github:nix-community/nixgl#nixGLIntel nixpkgs#bash nixpkgs#wl-screenrec nixpkgs#gifski nixpkgs#inotify-tools nixpkgs#libnotify nixpkgs#mktemp nixpkgs#slurp nixpkgs#slurp --command bash
# Dependencies:
# - wl-screenrec: https://github.com/russelltg/wl-screenrec
# - notification daemon: https://archlinux.org/packages/?name=notification-daemon
# - wl-clipboard: https://github.com/bugaevc/wl-clipboard
# - gifski: https://github.com/sindresorhus/Gifski
#
# Gifski is necessary because `wl-screenrec` doesn't support gifs
# set -euoE pipefail
set -euoE pipefail
mk-screen-cap() {
local program_name="Screen Capture"
@ -40,7 +30,7 @@ mk-screen-cap() {
local geometry
geometry="$(slurp)"
nixGLIntel wl-screenrec --filename "$tmp_file" --geometry "$geometry" &
wl-screenrec --filename "$tmp_file" --geometry "$geometry" &
local pid="${!}"
printf "%s" "$pid" >"$pid_file"
printf "Putting pid: '%d' into pid file: '%s'\n" "$pid" "$pid_file"

View File

@ -74,8 +74,8 @@ bind = SUPERSHIFT,M,exit
# May be videos or screenshots
bind = SUPER,S,exec,grim -g "$(slurp)" - | swappy -f - -o - | wl-copy
bind = CTRLSUPER,S,exec,grim -g "$(slurp)" - | wl-copy --type image/png
bind = SUPERSHIFT,S,exec,~/.config/hypr/scripts/screen-cap.bash
bind = SUPERSHIFT,A,exec,~/.config/hypr/scripts/screen-cap.bash gif
bind = SUPERSHIFT,S,exec,screen-cap
bind = SUPERSHIFT,A,exec,screen-cap gif
# Mediakey bindings as taken from `wev`
bindl = ,XF86AudioPrev,exec,playerctl previous

View File

@ -47,6 +47,7 @@ in
slurp
unzip
Fmt
screen-cap
starship
nodePackages.prettier
cargo