From 5bf02164604b255261cdf91b7514955b02330c8a Mon Sep 17 00:00:00 2001 From: Corwin Perren Date: Mon, 3 Nov 2025 20:58:20 -0800 Subject: [PATCH] Switched flameshot for custom grim/wl-copy/swappy pipeline, new printscr shortcuts, minor refactoring of some modules, spotify_player swap for streamdeck, new area for hyprland scripts --- .../application-groups/system-utilities.nix | 1 + modules/system/hyprland.nix | 30 ++--- users/caperren/caperren.nix | 8 +- .../.config/hypr/scripts/screenshot.sh | 116 ++++++++++++++++++ .../dotfiles/hyprland/hyprland-common.conf | 19 ++- .../dotfiles/streamdeck/.streamdeck_ui.json | 2 +- 6 files changed, 152 insertions(+), 24 deletions(-) create mode 100755 users/caperren/dotfiles/.config/hypr/scripts/screenshot.sh diff --git a/modules/application-groups/system-utilities.nix b/modules/application-groups/system-utilities.nix index af611a1..a360d1e 100644 --- a/modules/application-groups/system-utilities.nix +++ b/modules/application-groups/system-utilities.nix @@ -33,6 +33,7 @@ kdePackages.qt6ct killall kitty + swappy lf minicom ncdu diff --git a/modules/system/hyprland.nix b/modules/system/hyprland.nix index a781890..9c0bd18 100644 --- a/modules/system/hyprland.nix +++ b/modules/system/hyprland.nix @@ -1,35 +1,31 @@ { config, pkgs, ... }: { - programs.hyprland = { - enable = true; - xwayland.enable = true; - }; - - services.displayManager.gdm = { - enable = true; - wayland = true; - }; - - services.xserver = { - enable = true; - }; hardware.graphics = { enable = true; enable32Bit = true; }; - xdg.portal.enable = true; - xdg.portal.extraPortals = [ pkgs.xdg-desktop-portal-gtk ]; - + programs.hyprland = { + enable = true; + xwayland.enable = true; + }; programs.hyprlock.enable = true; programs.waybar.enable = true; + + services.displayManager.gdm = { + enable = true; + wayland = true; + }; services.hypridle.enable = true; + services.xserver.enable = true; + + xdg.portal.enable = true; + xdg.portal.extraPortals = [ pkgs.xdg-desktop-portal-gtk ]; environment.systemPackages = with pkgs; [ arandr dunst - flameshot grim hyprpaper hyprpicker diff --git a/users/caperren/caperren.nix b/users/caperren/caperren.nix index eb15421..e85791a 100644 --- a/users/caperren/caperren.nix +++ b/users/caperren/caperren.nix @@ -46,8 +46,9 @@ in font.name = "JetBrains Mono"; }; - # Assets + # Assets/scripts home.file.".config/streamdeck-ui/icons".source = ./dotfiles/streamdeck/icons; + home.file.".config/hypr/scripts".source = ./dotfiles/.config/hypr/scripts; # Application config files home.file.".config/glances/glances.conf".source = ./dotfiles/.config/glances/glances.conf; @@ -81,8 +82,9 @@ in # Custom bash aliases home.shellAliases = { - # Streamdeck isn't easy to manually edit, so make a save command to copy any updates to the repo - savestreamdeck = "cp ~/.streamdeck_ui.json ~/.nixos-configs/users/caperren/dotfiles/streamdeck/.streamdeck_ui.json"; + # Streamdeck isn't easy to manually edit, so make a save command to copy any updates to the repo + savestreamdeck = "cp ~/.streamdeck_ui.json ~/.nixos-configs/users/caperren/dotfiles/streamdeck/.streamdeck_ui.json"; + screenshot = "~/.config/hypr/scripts/screenshot.sh"; }; # Theming diff --git a/users/caperren/dotfiles/.config/hypr/scripts/screenshot.sh b/users/caperren/dotfiles/.config/hypr/scripts/screenshot.sh new file mode 100755 index 0000000..e345ebc --- /dev/null +++ b/users/caperren/dotfiles/.config/hypr/scripts/screenshot.sh @@ -0,0 +1,116 @@ +#!/usr/bin/env bash + +# Unashamedly taken from: https://www.reddit.com/r/hyprland/comments/13ivh0c/comment/jkgk65k +# Small edits made for my particular needs + +# Flags: + +# r: region +# s: screen +# +# c: clipboard +# f: file +# i: interactive + +# p: pixel + +# Example hyprland bindings +#bind = CTRL, SUPER, ALT, PRINT, exec, ~/.config/hypr/scripts/screenshot.sh +#bind = , PRINT, exec, ~/.config/hypr/scripts/screenshot.sh rc +#bind = SUPER, PRINT, exec, ~/.config/hypr/scripts/screenshot.sh rf +#bind = CTRL, PRINT, exec, ~/.config/hypr/scripts/screenshot.sh ri +#bind = SHIFT, PRINT, exec, ~/.config/hypr/scripts/screenshot.sh sc +#bind = SUPER SHIFT, PRINT, exec, ~/.config/hypr/scripts/screenshot.sh sf +#bind = CTRL SHIFT, PRINT, exec, ~/.config/hypr/scripts/screenshot.sh si +#bind = ALT, PRINT, exec, ~/.config/hypr/scripts/screenshot.sh p + +screenshotPath=~/Pictures/screenshots + +hyprpicker_launch(){ + # Start hyprpicker with screen render (freeze), no fancy, no zoom + # We're just using this to lock the screen in place for grim ingest + hyprpicker -r -n -z -d >/dev/null 2>&1 & + sleep 0.5 +} + +hyprpicker_kill(){ + killall hyprpicker >/dev/null 2>&1 +} + +trap hyprpicker_kill EXIT + +generate_filename(){ + # Make sure screenshots path exists first + if [ ! -d "$screenshotPath" ]; then + mkdir -p "$screenshotPath" + fi + + echo "$screenshotPath/$(date +%Y-%m-%d_%H-%M-%S).png" +} + +active_screen_grim_region(){ + hyprctl -j monitors | jq -r '.[] | select(.focused) | "\(.x),\(.y) \(.width)x\(.height)"' - +} + +grim_from_region() { + local filename="${1:-}" + local region="${2:-}" + + hyprpicker_launch + + # Get region of screen to capture, if not passed in + if [ -z "$region" ]; then + region=$(slurp -b '#000000b0' -c '#00000000') || exit 1 + fi + + # Start grim while screen is still frozen, kill hyprpicker, and pass through data + if [ -z "$filename" ]; then + grim -g "$region" - | { + hyprpicker_kill || true + cat + } + else + grim -g "$region" "$filename" | { + hyprpicker_kill || true + cat + } + fi +} + +if [[ $1 == rc ]]; then + grim_from_region | wl-copy + notify-send 'Copied to Clipboard' Screenshot + +elif [[ $1 == rf ]]; then + grim_from_region "$(generate_filename)" + notify-send 'Screenshot Taken' "$filename" + +elif [[ $1 == ri ]]; then + grim_from_region | swappy -f - -o "$(generate_filename)" + +elif [[ $1 == sc ]]; then + grim_from_region "" "$(active_screen_grim_region)" | wl-copy + notify-send 'Copied to Clipboard' Screenshot + +elif [[ $1 == sf ]]; then + grim_from_region "$(generate_filename)" "$(active_screen_grim_region)" + notify-send 'Screenshot Taken' "$filename" + +elif [[ $1 == si ]]; then + grim_from_region "" "$(active_screen_grim_region)" | swappy -f - -o "$(generate_filename)" + +elif [[ $1 == p ]]; then + color=$(hyprpicker -a -r) + wl-copy "$color" + notify-send 'Copied to Clipboard' "$color" + +else + notify-send 'Screenshot Shortcuts' "Print:\t\t\tRegion to clip +Super+Print:\t\tRegion to file +Ctrl+Print:\t\tRegion to editor +Shift+Print:\t\t\Screen to clip +Shift+Super+Print:\tScreen to file +Ctrl+Shift+Print:\tScreen to editor +Alt+Print:\t\tColor picker to clip" -t 20000 + +fi \ No newline at end of file diff --git a/users/caperren/dotfiles/hyprland/hyprland-common.conf b/users/caperren/dotfiles/hyprland/hyprland-common.conf index d164ede..fa1030e 100644 --- a/users/caperren/dotfiles/hyprland/hyprland-common.conf +++ b/users/caperren/dotfiles/hyprland/hyprland-common.conf @@ -83,14 +83,13 @@ windowrulev2 = suppressevent maximize, class:.* # You'll probably like this. $mainMod = SUPER -bind = $mainMod, T, exec, $terminal -bind = $mainMod, C, killactive, - # Launch terminal +bind = $mainMod, T, exec, $terminal bind = SHIFT_SUPER, Return, exec, $terminal # Close active window bind = $mainMod, Shift+q, killactive, +bind = $mainMod, C, killactive, bind = $mainMod, M, exit, bind = $mainMod, E, exec, $fileManager @@ -157,6 +156,20 @@ bindl=, XF86AudioNext, exec, playerctl next bind = ,XF86MonBrightnessDown, exec, brightnessctl s 1%- bind = ,XF86MonBrightnessUp, exec, brightnessctl s +1% +# Screenshots +bind = , PRINT, exec, ~/.config/hypr/scripts/screenshot.sh rc +bind = SUPER, PRINT, exec, ~/.config/hypr/scripts/screenshot.sh rf +bind = CTRL, PRINT, exec, ~/.config/hypr/scripts/screenshot.sh ri +bind = SHIFT, PRINT, exec, ~/.config/hypr/scripts/screenshot.sh sc +bind = SUPER_SHIFT, PRINT, exec, ~/.config/hypr/scripts/screenshot.sh sf +bind = CTRL_SHIFT, PRINT, exec, ~/.config/hypr/scripts/screenshot.sh si +bind = ALT, PRINT, exec, ~/.config/hypr/scripts/screenshot.sh p + + +# Jetbrains window rules +# Prevent initial focus for JetBrains popups +windowrulev2 = noinitialfocus, class:^jetbrains-.*$, floating:1, title:^$|^\s$|^win\d+$ + # Application launch exec-once = kanshi # Automatically handles display configurations exec-once = ydotoold # Autoclicker/autokeyboard for automation diff --git a/users/caperren/dotfiles/streamdeck/.streamdeck_ui.json b/users/caperren/dotfiles/streamdeck/.streamdeck_ui.json index a208064..ddd0b80 100644 --- a/users/caperren/dotfiles/streamdeck/.streamdeck_ui.json +++ b/users/caperren/dotfiles/streamdeck/.streamdeck_ui.json @@ -263,7 +263,7 @@ "icon": "/home/caperren/.config/streamdeck-ui/icons/spotify-logo.png", "keys": "", "write": "", - "command": "spotify", + "command": "kitty -e spotify_player", "brightness_change": 0, "switch_page": 0, "switch_state": 0,