summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew <saintruler@gmail.com>2020-07-17 15:14:30 +0400
committerAndrew <saintruler@gmail.com>2020-07-17 15:14:30 +0400
commitc15360bdd76eadf62cc1ac7ccb03e17ec250b024 (patch)
tree8fdaf75fae7fdcb997fe98e46d8add81fa671dd3
parent9d22b4fc9c67711165e52150038cc6a72d8f4f8d (diff)
Added screenshoter scripts
-rwxr-xr-x.local/bin/scripts/dis1
-rwxr-xr-x.local/bin/scripts/getrange32
-rwxr-xr-x.local/bin/scripts/screenshot3
-rwxr-xr-x.local/bin/scripts/screenshot.py52
4 files changed, 88 insertions, 0 deletions
diff --git a/.local/bin/scripts/dis b/.local/bin/scripts/dis
new file mode 100755
index 0000000..fc21f42
--- /dev/null
+++ b/.local/bin/scripts/dis
@@ -0,0 +1 @@
+env PULSE_LATENCY_MSEC=90 /opt/discord/Discord
diff --git a/.local/bin/scripts/getrange b/.local/bin/scripts/getrange
new file mode 100755
index 0000000..561dfdc
--- /dev/null
+++ b/.local/bin/scripts/getrange
@@ -0,0 +1,32 @@
+#!/sbin/python3
+import sys
+def nempty(l):
+ return [i for i in l if i]
+
+
+if len(sys.argv) > 2:
+ s = sys.argv[2]
+else:
+ s = input()
+
+l = nempty(s.strip().split())
+r = sys.argv[1].split(":")
+
+if len(r) == 3:
+ start, end, step = map(int, r)
+elif len(r) == 2:
+ if r[0] == '':
+ start = 0
+ end = int(r[1])
+ step = 1
+ elif r[1] == '':
+ start = int(r[0])
+ end = len(l)
+ step = 1
+ else:
+ start, end = r
+ step = 1
+
+print(' '.join(l[start:end:step]))
+
+
diff --git a/.local/bin/scripts/screenshot b/.local/bin/scripts/screenshot
new file mode 100755
index 0000000..a7d3cda
--- /dev/null
+++ b/.local/bin/scripts/screenshot
@@ -0,0 +1,3 @@
+#!/bin/sh
+
+/bin/sh -c "$(screenshot.py $@)"
diff --git a/.local/bin/scripts/screenshot.py b/.local/bin/scripts/screenshot.py
new file mode 100755
index 0000000..752924b
--- /dev/null
+++ b/.local/bin/scripts/screenshot.py
@@ -0,0 +1,52 @@
+#!/bin/python3
+import sys
+import re
+import subprocess
+
+def shoot(arg, dst):
+ print(f"{tool_name} {arg} | {dst}")
+
+
+tool_name = "maim"
+default_tool = "area"
+default_dest = "clip"
+
+file_path = "~/Pictures"
+file_name = "Screenshot_$(date +%Y-%m-%d_%H-%M-%S).png"
+
+tool = {
+ "area": "-u -s -m 1",
+ "window": "-B -u -i $(xdotool getactivewindow)",
+ "screen": "-u",
+}
+
+dest = {
+ "file": f"tee {file_path}/{file_name}",
+ "clip": "xclip -selection clipboard -t image/png",
+}
+
+args = sys.argv[1:]
+if len(args) == 0:
+ shoot(tool[default_tool], dest[default_dest])
+
+elif len(args) == 1:
+ if args[0] in tool:
+ shoot(tool[args[0]], dest[default_dest])
+ else:
+ print("Wrong arguments")
+ quit(1)
+
+elif len(args) == 2:
+ if args[0] == "to" and args[1] in dest:
+ shoot(tool[default_tool], dest[args[1]])
+ else:
+ print("Wrong arguments")
+ quit(1)
+
+elif len(args) == 3:
+ if args[1] == "to" and args[0] in tool and args[2] in dest:
+ shoot(tool[args[0]], dest[args[2]])
+ else:
+ print("Wrong arguments")
+ quit(1)
+