feat: add hyprshot for screenshot

This commit is contained in:
Ryan Yin
2024-01-30 21:07:12 +08:00
parent c70f9de97c
commit 544ec79aff
3 changed files with 10 additions and 62 deletions

View File

@@ -94,7 +94,6 @@ $term = kitty
$app_launcher = ~/.config/hypr/scripts/menu
$volume = ~/.config/hypr/scripts/volume
$backlight = ~/.config/hypr/scripts/brightness
$screenshot = ~/.config/hypr/scripts/screenshot
$lockscreen = ~/.config/hypr/scripts/lockscreen
$wlogout = ~/.config/hypr/scripts/wlogout
$colorpicker = ~/.config/hypr/scripts/colorpicker
@@ -137,9 +136,9 @@ bind=,XF86AudioPlay,exec,mpc toggle
bind=,XF86AudioStop,exec,mpc stop
# -- Screenshots --
bind=,Print,exec,$screenshot --now
bind=SUPER,Print,exec,$screenshot --win
bind=CTRL,Print,exec,$screenshot --area
bind=,Print,exec,hyprshot -m output -o ~/Pictures/Screenshots -- imv
bind=SUPER,Print,exec,hyprshot -m window -o ~/Pictures/Screenshots -- imv
bind=CTRL,Print,exec,hyprshot -m region -o ~/Pictures/Screenshots -- imv
# Focus
bind=SUPER,left,movefocus,l

View File

@@ -1,55 +0,0 @@
#!/usr/bin/env bash
## Script to take screenshots with grim, slurp (in Wayland)
iDIR="$HOME/.config/hypr/mako/icons"
time=$(date +%Y-%m-%d-%H-%M-%S)
dir="$(xdg-user-dir PICTURES)/Screenshots" # need
file="Screenshot_${time}_${RANDOM}.png"
# notify and view screenshot
notify_cmd_shot="notify-send -h string:x-canonical-private-synchronous:shot-notify -u low -i ${iDIR}/picture.png"
notify_view () {
${notify_cmd_shot} "Copied to clipboard."
imv ${dir}/"$file"
if [[ -e "$dir/$file" ]]; then
${notify_cmd_shot} "Screenshot Saved."
else
${notify_cmd_shot} "Screenshot Deleted."
fi
}
# take shots
shotnow () {
cd ${dir} && grim - | tee "$file" | wl-copy
notify_view
}
shotwin () {
w_pos=$(hyprctl activewindow | grep 'at:' | cut -d':' -f2 | tr -d ' ' | tail -n1)
w_size=$(hyprctl activewindow | grep 'size:' | cut -d':' -f2 | tr -d ' ' | tail -n1 | sed s/,/x/g)
cd ${dir} && grim -g "$w_pos $w_size" - | tee "$file" | wl-copy
notify_view
}
shotarea () {
cd ${dir} && grim -g "$(slurp -b 1B1F28CC -c E06B74ff -s C778DD0D -w 2)" - | tee "$file" | wl-copy
notify_view
}
if [[ ! -d "$dir" ]]; then
mkdir -p "$dir"
fi
if [[ "$1" == "--now" ]]; then
shotnow
elif [[ "$1" == "--area" ]]; then
shotarea
elif [[ "$1" == "--win" ]]; then
shotwin
else
echo -e "Available Options : --now --win --area"
fi
exit 0

View File

@@ -1,4 +1,8 @@
{pkgs, ...}: {
{
pkgs,
pkgs-unstable,
...
}: {
home.packages = with pkgs; [
waybar # the status bar
swaybg # the wallpaper
@@ -8,10 +12,10 @@
wl-clipboard # copying and pasting
hyprpicker # color picker
wf-recorder # creen recording
pkgs-unstable.hyprshot # screen shot
grim # taking screenshots
slurp # selecting a region to screenshot
# TODO replace by `flameshot gui --raw | wl-copy`
wf-recorder # creen recording
mako # the notification daemon, the same as dunst