diff options
author | Justine Smithies <justine@smithies.me.uk> | 2023-08-22 19:35:23 +0100 |
---|---|---|
committer | Justine Smithies <justine@smithies.me.uk> | 2023-08-22 19:35:23 +0100 |
commit | 3058d6df77817de298a207d36b8b0871893c417a (patch) | |
tree | 2f3cbb973751e0f829ad3e00dd52bc5a081936d5 /.local/bin/screenshot.sh | |
parent | 1125d4a4ee25de42f3223d612a50a1256bd222d3 (diff) |
Initial commit
Diffstat (limited to '.local/bin/screenshot.sh')
-rwxr-xr-x | .local/bin/screenshot.sh | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/.local/bin/screenshot.sh b/.local/bin/screenshot.sh new file mode 100755 index 0000000..bb4bdb6 --- /dev/null +++ b/.local/bin/screenshot.sh @@ -0,0 +1,28 @@ +#!/bin/bash + +case $1 in + selected-region) + # Take a screenshot of the selected region + grim -t jpeg -g "$(slurp)" ~/Pictures/Screenshots/$(date +%Y-%m-%d_%H-%m-%s).jpg + ;; + save-to-clipboard) + # Take a screenshot and save it to the clipboard + grim -g "$(slurp -d)" - | wl-copy + ;; + selected-window) + pos=$(qtile cmd-obj -o window -f get_position | awk '{ print $1" "$2}' | tr -dc '0-9 ') + xpos=$(echo $pos | awk '{ print $1 }') + ypos=$(echo $pos | awk '{ print $2 }') + size=$(qtile cmd-obj -o window -f get_size | awk '{ print $1" "$2}' | 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 + ysize=$((ysize+4)) # Value added is 2 times the border width + grim -g "$xpos"",""$ypos $xsize""x""$ysize" -t jpeg ~/Pictures/Screenshots/$(date +%Y-%m-%d_%H-%m-%s).jpg + ;; + *) + # 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}')" + grim -o $output -t jpeg ~/Pictures/Screenshots/$(date +%Y-%m-%d_%H-%m-%s).jpg + ;; +esac |