mirror of
https://github.imc.re/void-land/hyprland-void-dots
synced 2025-04-26 15:03:43 +02:00
feat: screenshot tool
This commit is contained in:
parent
b93f9148bd
commit
9af67d741c
5 changed files with 30 additions and 39 deletions
|
@ -53,10 +53,13 @@ The following packages are required for the proper functioning of Hyprland on Vo
|
||||||
<summary><strong>User Interface Components</strong></summary>
|
<summary><strong>User Interface Components</strong></summary>
|
||||||
|
|
||||||
- waybar
|
- waybar
|
||||||
- grim
|
|
||||||
- swaybg
|
- swaybg
|
||||||
- swaylock or [swaylock-effects](https://github.com/mortie/swaylock-effects) : lock screen with effects
|
- swaylock or [swaylock-effects](https://github.com/mortie/swaylock-effects)
|
||||||
|
- grim
|
||||||
- slurp
|
- slurp
|
||||||
|
- jq
|
||||||
|
- wl-clipboard
|
||||||
|
- libnotify
|
||||||
- dunst
|
- dunst
|
||||||
- swayidle
|
- swayidle
|
||||||
- swappy
|
- swappy
|
||||||
|
|
|
@ -21,6 +21,10 @@ bind = $mainMod ALT, right, movewindow, r
|
||||||
bind = $mainMod ALT, up, movewindow, u
|
bind = $mainMod ALT, up, movewindow, u
|
||||||
bind = $mainMod ALT, down, movewindow, d
|
bind = $mainMod ALT, down, movewindow, d
|
||||||
|
|
||||||
|
# Screenshot
|
||||||
|
bind = $mainMod, PRINT, exec, $screenshot -m window
|
||||||
|
bind = , PRINT, exec, $screenshot -m output
|
||||||
|
|
||||||
# Audio control
|
# Audio control
|
||||||
bind=,XF86AudioRaiseVolume,exec, $volume_control u
|
bind=,XF86AudioRaiseVolume,exec, $volume_control u
|
||||||
bind=,XF86AudioLowerVolume,exec, $volume_control d
|
bind=,XF86AudioLowerVolume,exec, $volume_control d
|
||||||
|
|
|
@ -16,6 +16,7 @@ $scr_path = ~/.config/hypr/scripts
|
||||||
$mainMod = SUPER
|
$mainMod = SUPER
|
||||||
$terminal = alacritty
|
$terminal = alacritty
|
||||||
$fileManager = dolphin
|
$fileManager = dolphin
|
||||||
|
$screenshot = $scr_path/hyprshot.sh
|
||||||
$waybar_toggle = $scr_path/waybar-toggle.sh
|
$waybar_toggle = $scr_path/waybar-toggle.sh
|
||||||
$volume_control = $scr_path/volume-control.sh
|
$volume_control = $scr_path/volume-control.sh
|
||||||
$rofi_menu = $scr_path/rofi-launch.sh d
|
$rofi_menu = $scr_path/rofi-launch.sh d
|
||||||
|
|
|
@ -53,9 +53,8 @@ function send_notification() {
|
||||||
fi
|
fi
|
||||||
|
|
||||||
local message=$([ $CLIPBOARD -eq 1 ] &&
|
local message=$([ $CLIPBOARD -eq 1 ] &&
|
||||||
echo "Image copied to the clipboard" ||
|
echo "Image copied to the clipboard")
|
||||||
echo "Image saved in <i>${1}</i> and copied to the clipboard.")
|
dunstify "Screenshot Saved." \
|
||||||
notify-send "Screenshot saved" \
|
|
||||||
"${message}" \
|
"${message}" \
|
||||||
-t "$NOTIF_TIMEOUT" -i "${1}" -a Hyprshot
|
-t "$NOTIF_TIMEOUT" -i "${1}" -a Hyprshot
|
||||||
}
|
}
|
||||||
|
@ -119,6 +118,7 @@ function save_geometry() {
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
wl-copy < <(grim -g "${cropped_geometry}" -)
|
wl-copy < <(grim -g "${cropped_geometry}" -)
|
||||||
|
echo ""
|
||||||
fi
|
fi
|
||||||
|
|
||||||
send_notification $output
|
send_notification $output
|
||||||
|
@ -271,8 +271,15 @@ DEBUG=0
|
||||||
SILENT=0
|
SILENT=0
|
||||||
RAW=0
|
RAW=0
|
||||||
NOTIF_TIMEOUT=5000
|
NOTIF_TIMEOUT=5000
|
||||||
CURRENT=0
|
CURRENT=1
|
||||||
[ -z "$XDG_PICTURES_DIR" ] && type xdg-user-dir &>/dev/null && XDG_PICTURES_DIR=$(xdg-user-dir PICTURES)
|
HYPRSHOT_DIR="$HOME/Screenshots"
|
||||||
|
|
||||||
|
if [[ ! -d "$HYPRSHOT_DIR" ]]; then
|
||||||
|
mkdir -p "$HYPRSHOT_DIR"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# [ -z "$XDG_PICTURES_DIR" ] && type xdg-user-dir &>/dev/null && XDG_PICTURES_DIR=$(xdg-user-dir PICTURES)
|
||||||
|
|
||||||
FILENAME="$(date +'%Y-%m-%d-%H%M%S_hyprshot.png')"
|
FILENAME="$(date +'%Y-%m-%d-%H%M%S_hyprshot.png')"
|
||||||
[ -z "$HYPRSHOT_DIR" ] && SAVEDIR=${XDG_PICTURES_DIR:=~} || SAVEDIR=${HYPRSHOT_DIR}
|
[ -z "$HYPRSHOT_DIR" ] && SAVEDIR=${XDG_PICTURES_DIR:=~} || SAVEDIR=${HYPRSHOT_DIR}
|
||||||
|
|
||||||
|
|
|
@ -8,6 +8,7 @@
|
||||||
# Import Current Theme
|
# Import Current Theme
|
||||||
source "$HOME"/.config/rofi/applets/shared/theme.bash
|
source "$HOME"/.config/rofi/applets/shared/theme.bash
|
||||||
theme="$type/$style"
|
theme="$type/$style"
|
||||||
|
hyprshot="$HOME/.config/hypr/scripts/hyprshot.sh"
|
||||||
|
|
||||||
# Theme Elements
|
# Theme Elements
|
||||||
prompt='Screenshot'
|
prompt='Screenshot'
|
||||||
|
@ -64,28 +65,6 @@ run_rofi() {
|
||||||
echo -e "$option_1\n$option_2\n$option_3\n$option_4\n$option_5" | rofi_cmd
|
echo -e "$option_1\n$option_2\n$option_3\n$option_4\n$option_5" | rofi_cmd
|
||||||
}
|
}
|
||||||
|
|
||||||
# Screenshot
|
|
||||||
time=$(date +%Y-%m-%d-%H-%M-%S)
|
|
||||||
geometry=$(xrandr | grep 'current' | head -n1 | cut -d',' -f2 | tr -d '[:blank:],current')
|
|
||||||
dir="$HOME/Screenshots"
|
|
||||||
file="Screenshot_${time}_${geometry}.png"
|
|
||||||
|
|
||||||
if [[ ! -d "$dir" ]]; then
|
|
||||||
mkdir -p "$dir"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# notify and view screenshot
|
|
||||||
notify_view() {
|
|
||||||
notify_cmd_shot='dunstify -u low --replace=699'
|
|
||||||
${notify_cmd_shot} "Copied to clipboard."
|
|
||||||
viewnior ${dir}/"$file"
|
|
||||||
if [[ -e "$dir/$file" ]]; then
|
|
||||||
${notify_cmd_shot} "Screenshot Saved."
|
|
||||||
else
|
|
||||||
${notify_cmd_shot} "Screenshot Deleted."
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
# Copy screenshot to clipboard
|
# Copy screenshot to clipboard
|
||||||
copy_shot() {
|
copy_shot() {
|
||||||
tee "$file" | xclip -selection clipboard -t image/png
|
tee "$file" | xclip -selection clipboard -t image/png
|
||||||
|
@ -101,30 +80,27 @@ countdown() {
|
||||||
|
|
||||||
# take shots
|
# take shots
|
||||||
shotnow() {
|
shotnow() {
|
||||||
cd ${dir} && sleep 0.5 && maim -u -f png | copy_shot
|
sleep 1
|
||||||
notify_view
|
$hyprshot -im output
|
||||||
}
|
}
|
||||||
|
|
||||||
shot5() {
|
shot5() {
|
||||||
countdown '5'
|
countdown '5'
|
||||||
sleep 1 && cd ${dir} && maim -u -f png | copy_shot
|
$hyprshot -m output
|
||||||
notify_view
|
|
||||||
}
|
}
|
||||||
|
|
||||||
shot10() {
|
shot10() {
|
||||||
countdown '10'
|
countdown '10'
|
||||||
sleep 1 && cd ${dir} && maim -u -f png | copy_shot
|
$hyprshot -m output
|
||||||
notify_view
|
|
||||||
}
|
}
|
||||||
|
|
||||||
shotwin() {
|
shotwin() {
|
||||||
cd ${dir} && maim -u -f png -i $(xdotool getactivewindow) | copy_shot
|
sleep 1
|
||||||
notify_view
|
$hyprshot -m window
|
||||||
}
|
}
|
||||||
|
|
||||||
shotarea() {
|
shotarea() {
|
||||||
cd ${dir} && maim -u -f png -s -b 2 -c 0.35,0.55,0.85,0.25 -l | copy_shot
|
$hyprshot -m region
|
||||||
notify_view
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# Execute Command
|
# Execute Command
|
||||||
|
|
Loading…
Add table
Reference in a new issue