aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPatrick Spek <p.spek@tyil.nl>2021-07-05 15:06:20 +0200
committerPatrick Spek <p.spek@tyil.nl>2021-07-05 15:06:25 +0200
commit6fe22fbf24b9546b7cec7391a0d6d316e6ebdc7f (patch)
treecaf14c079a87609d0b35847731639516be59eeea
parent9f8b8030899b2f965cb5a85d65eb9934a55fc13a (diff)
downloaddotfiles-6fe22fbf24b9546b7cec7391a0d6d316e6ebdc7f.tar.gz
dotfiles-6fe22fbf24b9546b7cec7391a0d6d316e6ebdc7f.tar.bz2
Update scrot commands
-rwxr-xr-x.local/bin/get-focussed-monitor43
-rwxr-xr-x.local/bin/mscrot6
-rwxr-xr-x.local/bin/sscrot8
-rwxr-xr-x.local/bin/wscrot6
4 files changed, 63 insertions, 0 deletions
diff --git a/.local/bin/get-focussed-monitor b/.local/bin/get-focussed-monitor
new file mode 100755
index 0000000..4d7bbd4
--- /dev/null
+++ b/.local/bin/get-focussed-monitor
@@ -0,0 +1,43 @@
+#!/usr/bin/env raku
+
+use v6.d;
+
+sub MAIN (
+ #Bool:D :$shell = False,
+ Bool:D :$coords = False,
+) {
+ my @xrandr = shell('xrandr | grep -w connected', :out).out.slurp.lines;
+ my %monitors;
+
+ my $mouse = shell('xdotool getmouselocation', :out).out.slurp.trim ~~ m/
+ 'x:' $<x> = [ \d+ ]
+ \s*
+ 'y:' $<y> = [ \d+ ]
+ /;
+
+ for @xrandr -> $monitor {
+ my $match = $monitor ~~ m/
+ $<width> = [ \d+ ]
+ 'x'
+ $<height> = [ \d+ ]
+ '+'
+ $<x> = [ \d+ ]
+ '+'
+ $<y> = [ \d+ ]
+ /;
+
+ next unless $match<x> ≤ $mouse<x> ≤ ($match<x> + $match<width>);
+ next unless $match<y> ≤ $mouse<y> ≤ ($match<y> + $match<height>);
+
+ say qq[MONITOR="{$monitor.words.first}"];
+
+ if ($coords) {
+ say qq[W="{$match<width>}"];
+ say qq[H="{$match<height>}"];
+ say qq[X="{$match<x>}"];
+ say qq[Y="{$match<y>}"];
+ }
+
+ last;
+ }
+}
diff --git a/.local/bin/mscrot b/.local/bin/mscrot
new file mode 100755
index 0000000..3848aaa
--- /dev/null
+++ b/.local/bin/mscrot
@@ -0,0 +1,6 @@
+#!/usr/bin/env sh
+
+p="~/pictures/scrot"
+cmd="mv \$f ${p} && notify-send \"Screenshot\" \"Saved to ${p}/\$f\""
+
+scrot -mz multi-%Y%m%d%H%M%S.png -e "${cmd}"
diff --git a/.local/bin/sscrot b/.local/bin/sscrot
new file mode 100755
index 0000000..2d4c049
--- /dev/null
+++ b/.local/bin/sscrot
@@ -0,0 +1,8 @@
+#!/usr/bin/env sh
+
+p="~/pictures/scrot"
+cmd="mv \$f ${p} && notify-send \"Screenshot\" \"Saved to ${p}/\$f\""
+
+eval "$(get-focussed-monitor --coords)"
+
+scrot -a $X,$Y,$W,$H -z screen-%Y%m%d%H%M%S.png -e "${cmd}"
diff --git a/.local/bin/wscrot b/.local/bin/wscrot
new file mode 100755
index 0000000..2970713
--- /dev/null
+++ b/.local/bin/wscrot
@@ -0,0 +1,6 @@
+#!/usr/bin/env sh
+
+p="~/pictures/scrot"
+cmd="mv \$f ${p} && notify-send \"Screenshot\" \"Saved to ${p}/\$f\""
+
+scrot -bsz window-%Y%m%d%H%M%S.png -e "${cmd}"