aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJustine Smithies <justine@smithies.me.uk>2024-02-10 13:34:09 +0000
committerJustine Smithies <justine@smithies.me.uk>2024-02-10 13:34:09 +0000
commit4e530fb055a14fbea2e0107fcc542dd802a22771 (patch)
treeb20b34102a2003b54cf0da769d944bab326ca6cb
parent98bec2a60dab942c8c1dba9429849083069a25d9 (diff)
Updated screenshot binds and added screenshot focused window
-rw-r--r--.config/hypr/hyprland.conf9
-rwxr-xr-x.local/bin/screenshot.sh8
2 files changed, 11 insertions, 6 deletions
diff --git a/.config/hypr/hyprland.conf b/.config/hypr/hyprland.conf
index c4bbad3..da029e1 100644
--- a/.config/hypr/hyprland.conf
+++ b/.config/hypr/hyprland.conf
@@ -242,13 +242,16 @@ bind = , xf86monbrightnessdown, exec, ~/.local/bin/statusbar/brightnesscontrol d
bind = , xf86monbrightnessup, exec, ~/.local/bin/statusbar/brightnesscontrol up
# Take a screenshot of the focused output and save it into screenshots
-bind = , PRINT, exec, grim -o $(hyprctl monitors | grep -B 12 'focused: yes' | grep 'Monitor' | awk '{ print $2 }') -t jpeg ~/Pictures/Screenshots/$(date +%Y-%m-%d_%H-%m-%s).jpg
+bind = , PRINT, exec, ~/.local/bin/screenshot.sh
# Take a screenshot of the selected region
-bind = $mainMod, PRINT, exec, grim -t jpeg -g "$(slurp)" ~/Pictures/Screenshots/$(date +%Y-%m-%d_%H-%m-%s).jpg
+bind = $mainMod, PRINT, exec, ~/.local/bin/screenshot.sh selected-region
# Take a screenshot and save it to the clipboard
-bind = $mainMod SHIFT, PRINT, exec, grim -g "$(slurp -d)" - | wl-copy
+bind = $mainMod SHIFT, PRINT, exec, ~/.local/bin/screenshot.sh save-to-region
+
+# Take a screenshot of the selected windows
+bind = $mainMod CONTROL, PRINT, exec, ~/.local/bin/screenshot.sh focused-window
# Swaps the active workspaces between two monitors
bind = $mainMod, Z, swapactiveworkspaces, HDMI-A-1 eDP-1
diff --git a/.local/bin/screenshot.sh b/.local/bin/screenshot.sh
index 29c62c8..6945464 100755
--- a/.local/bin/screenshot.sh
+++ b/.local/bin/screenshot.sh
@@ -11,10 +11,12 @@ case $1 in
;;
focused-window)
# Take a screenshot of the focused window
- pos=$(qtile cmd-obj -o window -f get_position | awk '{ print $1" "$2}' | tr -dc '0-9 ')
+ pos=$(hyprctl -j activewindow | grep 'at' | tr -dc '0-9 ')
xpos=$(echo $pos | awk '{ print $1 }')
+ xpos=$((xpos-2))
ypos=$(echo $pos | awk '{ print $2 }')
- size=$(qtile cmd-obj -o window -f get_size | awk '{ print $1" "$2}' | tr -dc '0-9 ')
+ ypos=$((ypos-2))
+ size=$(hyprctl -j activewindow | grep 'size' | tr -dc '0-9 ')
xsize=$(echo $size | awk '{ print $1 }')
ysize=$(echo $size | awk '{ print $2 }')
xsize=$((xsize+4)) # Value added is 2 times the border width
@@ -23,7 +25,7 @@ case $1 in
;;
*)
# Take a screenshot of the currently focused output and save it into screenshots
- output="$(qtile cmd-obj -o core -f eval -a "self._current_output.wlr_output.name" | awk -F"['']" '/,/{print $2}')"
+ output="$(hyprctl monitors | grep -B 12 'focused: yes' | grep 'Monitor' | awk '{ print $2 }')"
grim -o $output -t jpeg ~/Pictures/Screenshots/$(date +%Y-%m-%d_%H-%m-%s).jpg
;;
esac