From 5687e919f98c69673a4ccc8e0c1cbabfd336d783 Mon Sep 17 00:00:00 2001 From: Aly Raffauf Date: Sun, 21 Jul 2024 23:31:46 -0400 Subject: [PATCH] home/desktop: simplify screenshoot bindings --- homeManagerModules/desktop/hyprland/README.md | 3 +- .../desktop/hyprland/settings.nix | 6 +-- .../desktop/wayland/helpers.nix | 41 ++++++++----------- 3 files changed, 21 insertions(+), 29 deletions(-) diff --git a/homeManagerModules/desktop/hyprland/README.md b/homeManagerModules/desktop/hyprland/README.md index e928cb99..35121160 100644 --- a/homeManagerModules/desktop/hyprland/README.md +++ b/homeManagerModules/desktop/hyprland/README.md @@ -34,8 +34,7 @@ ### Screenshots -- PRINT // CTRL + F12: Take screenshot of monitor. -- SUPER + PRINT // SUPER CTRL + F12: Take screenshot of selected area. +- PRINT // CTRL + F12: Take screenshot of monitor or selected area. ### Session Control diff --git a/homeManagerModules/desktop/hyprland/settings.nix b/homeManagerModules/desktop/hyprland/settings.nix index ad7c98b6..895f19c0 100644 --- a/homeManagerModules/desktop/hyprland/settings.nix +++ b/homeManagerModules/desktop/hyprland/settings.nix @@ -27,7 +27,6 @@ in { bind = [ - "$mod CONTROL,F12,exec,${helpers.screenshot.region}" "$mod CONTROL,L,exec,${lib.getExe pkgs.swaylock}" "$mod SHIFT,S,movetoworkspace,special:magic" "$mod SHIFT,V,togglefloating" @@ -41,7 +40,6 @@ in { "$mod,F,exec,${lib.getExe cfg.defaultApps.fileManager}" "$mod,F11,exec,pkill -SIGUSR1 waybar" "$mod,M,exec,${lib.getExe pkgs.wlogout}" - "$mod,PRINT,exec,${helpers.screenshot.region}" "$mod,R,exec,${lib.getExe pkgs.fuzzel}" "$mod,S,togglespecialworkspace,magic" "$mod,T,exec,${lib.getExe cfg.defaultApps.terminal}" @@ -49,8 +47,8 @@ in { "$mod,mouse_down,workspace,+1" "$mod,mouse_up,workspace,-1" "$mod,period,exec,${lib.getExe pkgs.hyprnome}" - ",PRINT,exec,${helpers.screenshot.screen}" - "CONTROL,F12,exec,${helpers.screenshot.screen}" + ",PRINT,exec,${helpers.screenshot}" + "CONTROL,F12,exec,${helpers.screenshot}" "CTRL ALT,M,submap,move" "CTRL ALT,R,submap,resize" ] diff --git a/homeManagerModules/desktop/wayland/helpers.nix b/homeManagerModules/desktop/wayland/helpers.nix index 81d205dd..bdc514a6 100644 --- a/homeManagerModules/desktop/wayland/helpers.nix +++ b/homeManagerModules/desktop/wayland/helpers.nix @@ -18,33 +18,28 @@ prev = "${bin} previous"; }; - screenshot = rec { - bin = pkgs.writeShellScript "screenshooter" '' - FILENAME=${config.xdg.userDirs.pictures}/screenshots/$(date +'%Y-%m-%d-%H:%M:%S_grim.png') - MAKO_MODE=$(${lib.getExe' pkgs.mako "makoctl"} mode) + screenshot = pkgs.writeShellScript "screenshooter" '' + FILENAME=${config.xdg.userDirs.pictures}/screenshots/$(date +'%Y-%m-%d-%H:%M:%S_grim.png') + MAKO_MODE=$(${lib.getExe' pkgs.mako "makoctl"} mode) - if echo "$MAKO_MODE" | grep -q "do-not-disturb"; then - DND=true - else - DND=false - ${lib.getExe' pkgs.mako "makoctl"} mode -t do-not-disturb - fi + if echo "$MAKO_MODE" | grep -q "do-not-disturb"; then + DND=true + else + DND=false + ${lib.getExe' pkgs.mako "makoctl"} mode -t do-not-disturb + fi - ${lib.getExe pkgs.grim} -g "$(${lib.getExe pkgs.slurp} -o)" "$FILENAME" + ${lib.getExe pkgs.grim} -g "$(${lib.getExe pkgs.slurp} -o)" "$FILENAME" - if [ "$DND" = false ]; then - ${lib.getExe' pkgs.mako "makoctl"} mode -t do-not-disturb - fi + if [ "$DND" = false ]; then + ${lib.getExe' pkgs.mako "makoctl"} mode -t do-not-disturb + fi - if [ -e "$FILENAME" ]; then - ${lib.getExe' pkgs.wl-clipboard-rs "wl-copy"} $FILENAME - ${lib.getExe' pkgs.libnotify "notify-send"} "Screenshot saved" "$FILENAME" -i "$FILENAME" - fi - ''; - - region = "${bin}"; - screen = "${bin}"; - }; + if [ -e "$FILENAME" ]; then + ${lib.getExe' pkgs.wl-clipboard-rs "wl-copy"} $FILENAME + ${lib.getExe' pkgs.libnotify "notify-send"} "Screenshot saved" "$FILENAME" -i "$FILENAME" + fi + ''; volume = rec { bin = lib.getExe' pkgs.swayosd "swayosd-client";