hyprland: move back to grimblast for screenshots because hyprshot cannot use second screen for screenshots

This commit is contained in:
Tigor Hutasuhut 2024-11-03 11:18:52 +07:00
parent dc87ef4a89
commit d46b5f0e6d
2 changed files with 56 additions and 2 deletions

View file

@ -14,7 +14,7 @@ in
./hypridle.nix
./hyprland.nix
./hyprlock.nix
./hyprshot.nix
# ./hyprshot.nix
# hyprpaper seems to be broken with out of memory and failure to swap wallpapers correctly.
# Use swww for now until the application is stable.
# ./hyprpaper.nix
@ -22,6 +22,7 @@ in
./rofi.nix
./waybar.nix
./wlogout.nix
./grimblast.nix
# ./swappy.nix
./alacritty.nix
./swayosd.nix
@ -40,7 +41,7 @@ in
pasystray
graphicsmagick
pkgs.swayosd
swayosd
image-roll # image viewer
];

View file

@ -0,0 +1,53 @@
{
config,
lib,
pkgs,
inputs,
...
}:
let
inherit (lib) mkIf;
inherit (lib.meta) getExe;
cfg = config.profile.hyprland;
saveDir = "${config.home.homeDirectory}/Pictures/screenshots";
grimblast = inputs.hyprland-contrib.packages.${pkgs.system}.grimblast;
script =
mode:
pkgs.writeShellScriptBin "grimblast-${mode}.sh" ''
mkdir -p "${saveDir}/original" "${saveDir}/edit"
file=$(date +%Y-%m-%d_%H%M%S).png
filename=${saveDir}/original/$file
${grimblast}/bin/grimblast save ${mode} "$filename"
action=$(notify-send --icon="$filename" --app-name="grimblast" --action="copy=Copy" --action="edit=Edit" --action="delete=Delete" "Grimblast" "Screenshot saved to $filename")
case $action in
"copy")
wl-copy < "$filename"
notify-send --icon="$filename" --app-name="grimblast" "Grimblast" "Screenshot copied to clipboard"
;;
"edit")
satty --save-after-copy --filename "$filename" --fullscreen --output-filename "${saveDir}/edit/$(date +%Y-%m-%d_%H%M%S).png"
;;
"delete")
rm "$filename"
notify-send --app-name="grimblast" "Grimblast" "Screenshot $filename deleted"
;;
esac
'';
saveAreaScript = script "area";
saveOutputScript = script "output";
in
{
config = mkIf cfg.enable {
home.packages = [
grimblast
pkgs.satty
pkgs.libnotify
];
wayland.windowManager.hyprland.settings.bind = [
", PRINT, exec, ${getExe saveAreaScript}"
"$mod, PRINT, exec, ${getExe saveOutputScript}"
];
};
}