diff --git a/users/guanranwang/home-manager/applications/hyprland/hypr/keybinds.conf b/users/guanranwang/home-manager/applications/hyprland/hypr/keybinds.conf index e38ea63..5f98883 100644 --- a/users/guanranwang/home-manager/applications/hyprland/hypr/keybinds.conf +++ b/users/guanranwang/home-manager/applications/hyprland/hypr/keybinds.conf @@ -9,7 +9,7 @@ $wp = ~/.local/bin/wrapped-swww $dwp = ~/.local/bin/wrapped-mpvpaper $changevolume = ~/.local/bin/wrapped-pamixer # use swayosd instead $changebrightness = ~/.local/bin/wrapped-brightnessctl -$screenshot = ~/.local/bin/wrapped-grim +$screenshot = ~/.local/bin/screenshot $inputfix = ~/.local/bin/minecraft-inputfix $video_path = ~/.var/app/com.valvesoftware.Steam/data/Steam/steamapps/workshop/content/431960 @@ -41,7 +41,7 @@ bind = SUPER SHIFT, L, exec, rofi -modi "power-men # screenshot bind = ,Print, exec, $screenshot fullscreen bind = SUPER SHIFT, S, exec, $screenshot region -bind = ALT SHIFT, S, exec, $screenshot region edit +bind = ALT SHIFT, S, exec, $screenshot swappy # wallpaper switching bind = SHIFT ALT, 1, exec, $wp /usr/share/backgrounds/odin.jpg # pkg: elementary-wallpapers diff --git a/users/guanranwang/home-manager/applications/sway/default.nix b/users/guanranwang/home-manager/applications/sway/default.nix index 6659722..a141a70 100644 --- a/users/guanranwang/home-manager/applications/sway/default.nix +++ b/users/guanranwang/home-manager/applications/sway/default.nix @@ -97,7 +97,7 @@ inherit (config.wayland.windowManager.sway.config) modifier; setBrightness = "/home/guanranwang/.local/bin/wrapped-brightnessctl"; setVolume = "/home/guanranwang/.local/bin/wrapped-pamixer"; - screenshot = "/home/guanranwang/.local/bin/wrapped-grim"; + screenshot = "/home/guanranwang/.local/bin/screenshot"; in { ### Sway itself # Window @@ -148,9 +148,8 @@ # Screenshot "${modifier}+Shift+s" = "exec ${screenshot} region"; - "${modifier}+Control+Shift+s" = "exec ${screenshot} region edit"; "Print" = "exec ${screenshot} fullscreen"; - "Print+Control" = "exec ${screenshot} fullscreen edit"; + "Print+Control" = "exec ${screenshot} swappy"; # Fn keys "XF86MonBrightnessUp" = "exec ${setBrightness} up"; diff --git a/users/guanranwang/home-manager/profiles/device-type/graphical/nixos/scripts/bin/wrapped-grim b/users/guanranwang/home-manager/profiles/device-type/graphical/nixos/scripts/bin/wrapped-grim deleted file mode 100755 index cf00d8b..0000000 --- a/users/guanranwang/home-manager/profiles/device-type/graphical/nixos/scripts/bin/wrapped-grim +++ /dev/null @@ -1,56 +0,0 @@ -#!/bin/sh - -# Original script based on some early version of https://github.com/moverest/sway-interactive-screenshot -# modified for use with key bindings. For now supports sway & Hyprland. - -SWAY=$(echo "$SWAYSOCK") -HYPR=$(echo "$HYPRLAND_INSTANCE_SIGNATURE") -if [[ -n "$SWAY" && -n "$HYPR" ]]; then - echo "This script only works on sway or Hyprland, terminating."; - exit 1 -fi - -list_geometry() -{ - swaymsg -t get_tree | jq -r '.. | try select(.'"$1"' and .pid) | "\(.rect.x),\(.rect.y) \(.rect.width)x\(.rect.height)''"' -} - -list_geometry_hypr() -{ - hyprctl -j activewindow | jq -r '"\(.at[0]),\(.at[1]) \(.size[0])x\(.size[1])''"' -} - -CHOICE=$1 -EDIT=$2 -DIR=${SCREENSHOT_DIR:=~/Pictures/Screenshots} - -mkdir -p "$DIR" - -if [[ -n "$SWAY" ]]; then - FOCUSED=$(list_geometry focused) - FILENAME="${DIR/#\~/$HOME}/$(date +'%Y-%m-%d-%H%M%S_sway_screenshot.png')" - case $CHOICE in - fullscreen) grim "$FILENAME" ;; - region) grim -g "$(slurp)" "$FILENAME" ;; - focused) grim -g "$FOCUSED" "$FILENAME" ;; - display) grim -o "$(swaymsg -t get_outputs | jq -r '.[] | select(.focused) | .name')" "$FILENAME" ;; - esac -fi - -if [[ -n "$HYPR" ]]; then - FOCUSED=$(list_geometry_hypr) - FILENAME="${DIR/#\~/$HOME}/$(date +'%Y-%m-%d-%H%M%S_hypr_screenshot.png')" - case $CHOICE in - fullscreen) grim "$FILENAME" ;; - region) grim -g "$(slurp)" "$FILENAME" ;; - focused) grim -g "$FOCUSED" "$FILENAME" ;; - display) grim -o "$(hyprctl -j monitors | jq -r '.[] | select(.focused) | .name')" "$FILENAME" ;; - esac -fi - -wl-copy < "$FILENAME" -notify-send "Screenshot" "File saved as '$FILENAME' and copied to the clipboard." -i "$FILENAME" - -if [[ "$EDIT" = "edit" ]]; then - swappy -f "$FILENAME" -fi diff --git a/users/guanranwang/home-manager/profiles/device-type/graphical/nixos/scripts/bin/wrapped-wayshot b/users/guanranwang/home-manager/profiles/device-type/graphical/nixos/scripts/bin/wrapped-wayshot deleted file mode 100755 index b356c25..0000000 --- a/users/guanranwang/home-manager/profiles/device-type/graphical/nixos/scripts/bin/wrapped-wayshot +++ /dev/null @@ -1,56 +0,0 @@ -#!/bin/sh - -# Original script based on some early version of https://github.com/moverest/sway-interactive-screenshot -# modified for use with key bindings. For now supports sway & Hyprland. - -SWAY=$(echo "$SWAYSOCK") -HYPR=$(echo "$HYPRLAND_INSTANCE_SIGNATURE") -if [[ -n "$SWAY" && -n "$HYPR" ]]; then - echo "This script only works on sway or Hyprland, terminating."; - exit 1 -fi - -list_geometry() -{ - swaymsg -t get_tree | jq -r '.. | try select(.'"$1"' and .pid) | "\(.rect.x),\(.rect.y) \(.rect.width)x\(.rect.height)''"' -} - -list_geometry_hypr() -{ - hyprctl -j activewindow | jq -r '"\(.at[0]),\(.at[1]) \(.size[0])x\(.size[1])''"' -} - -CHOICE=$1 -EDIT=$2 -DIR=${SCREENSHOT_DIR:=~/Pictures/Screenshots} - -mkdir -p "$DIR" - -if [[ -n "$SWAY" ]]; then - FOCUSED=$(list_geometry focused) - FILENAME="${DIR/#\~/$HOME}/$(date +'%Y-%m-%d-%H%M%S_sway_screenshot.png')" - case $CHOICE in - fullscreen) wayshot -f "$FILENAME" ;; - region) wayshot -s "$(slurp)" -f "$FILENAME" ;; - focused) wayshot -s "$FOCUSED" -f "$FILENAME" ;; - display) wayshot -o "$(swaymsg -t get_outputs | jq -r '.[] | select(.focused) | .name')" -f "$FILENAME" ;; - esac -fi - -if [[ -n "$HYPR" ]]; then - FOCUSED=$(list_geometry_hypr) - FILENAME="${DIR/#\~/$HOME}/$(date +'%Y-%m-%d-%H%M%S_hypr_screenshot.png')" - case $CHOICE in - fullscreen) wayshot -f "$FILENAME" ;; - region) wayshot -s "$(slurp)" -f "$FILENAME" ;; - focused) wayshot -s "$FOCUSED" -f "$FILENAME" ;; - display) wayshot -o "$(hyprctl -j monitors | jq -r '.[] | select(.focused) | .name')" "$FILENAME" ;; - esac -fi - -wl-copy < "$FILENAME" -notify-send "Screenshot" "File saved as '$FILENAME' and copied to the clipboard." -i "$FILENAME" - -if [[ "$EDIT" = "edit" ]]; then - swappy -f "$FILENAME" -fi diff --git a/users/guanranwang/home-manager/profiles/device-type/graphical/nixos/scripts/default.nix b/users/guanranwang/home-manager/profiles/device-type/graphical/nixos/scripts/default.nix index 6e65251..825cd1d 100644 --- a/users/guanranwang/home-manager/profiles/device-type/graphical/nixos/scripts/default.nix +++ b/users/guanranwang/home-manager/profiles/device-type/graphical/nixos/scripts/default.nix @@ -1,17 +1,26 @@ -{pkgs, ...}: { - home.sessionPath = ["$HOME/.local/bin"]; +{pkgs, ...}: let + binPATH = ".local/bin"; +in { + home.sessionPath = ["$HOME/${binPATH}"]; home.file = { - ".local/bin" = { + ${binPATH} = { source = ./bin; recursive = true; executable = true; }; - ".local/bin/lofi" = { + "${binPATH}/lofi" = { source = pkgs.fetchurl { url = "https://raw.githubusercontent.com/lime-desu/bin/main/lofi"; hash = "sha256-hT+S/rqOHUYnnFcSDFfQht4l1DGasz1L3wDHKUWLraA="; }; executable = true; }; + "${binPATH}/screenshot" = { + source = pkgs.fetchurl { + url = "https://raw.githubusercontent.com/nwg-piotr/nwg-shell/c29e8eb4658a2613fb221ead0b101c75f457bcaf/scripts/screenshot"; + hash = "sha256-Z/fWloz8pLHsvPTPOeBxnbMsGDRTY3G3l/uePQ3ZxjU="; + }; + executable = true; + }; }; }