From f980f035c075ccc095baba69c4b24b597ec1f293 Mon Sep 17 00:00:00 2001 From: Price Hiller Date: Sat, 22 Jun 2024 05:50:05 -0500 Subject: [PATCH] refactor(hypr): use `screen-cap` as a nix package --- pkgs/default.nix | 1 + pkgs/screen-cap/default.nix | 17 +++++++++++++++++ .../scripts => pkgs/screen-cap}/screen-cap.bash | 14 ++------------ .../dots/.config/hypr/conf/core/bindings.conf | 4 ++-- users/price/home.nix | 1 + 5 files changed, 23 insertions(+), 14 deletions(-) create mode 100644 pkgs/screen-cap/default.nix rename {users/price/dots/.config/hypr/scripts => pkgs/screen-cap}/screen-cap.bash (75%) mode change 100755 => 100644 diff --git a/pkgs/default.nix b/pkgs/default.nix index 1ff2fe50..9f7793a4 100644 --- a/pkgs/default.nix +++ b/pkgs/default.nix @@ -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; [ diff --git a/pkgs/screen-cap/default.nix b/pkgs/screen-cap/default.nix new file mode 100644 index 00000000..a1277733 --- /dev/null +++ b/pkgs/screen-cap/default.nix @@ -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} + ''; +} diff --git a/users/price/dots/.config/hypr/scripts/screen-cap.bash b/pkgs/screen-cap/screen-cap.bash old mode 100755 new mode 100644 similarity index 75% rename from users/price/dots/.config/hypr/scripts/screen-cap.bash rename to pkgs/screen-cap/screen-cap.bash index d5030773..16258717 --- a/users/price/dots/.config/hypr/scripts/screen-cap.bash +++ b/pkgs/screen-cap/screen-cap.bash @@ -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" diff --git a/users/price/dots/.config/hypr/conf/core/bindings.conf b/users/price/dots/.config/hypr/conf/core/bindings.conf index b91d8378..de7f19d4 100644 --- a/users/price/dots/.config/hypr/conf/core/bindings.conf +++ b/users/price/dots/.config/hypr/conf/core/bindings.conf @@ -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 diff --git a/users/price/home.nix b/users/price/home.nix index 191d2cda..ec20fbe0 100644 --- a/users/price/home.nix +++ b/users/price/home.nix @@ -47,6 +47,7 @@ in slurp unzip Fmt + screen-cap starship nodePackages.prettier cargo