First Commit
This commit is contained in:
commit
cae9d57360
22 changed files with 1957 additions and 0 deletions
39
bin/screenshot.nix
Executable file
39
bin/screenshot.nix
Executable file
|
|
@ -0,0 +1,39 @@
|
|||
{ pkgs, ... }:
|
||||
pkgs.writers.writePython3 "screenshot" { flakeIgnore = [ "E501" ];} ''
|
||||
import subprocess
|
||||
import re
|
||||
|
||||
options = """\
|
||||
a selected area (copy)
|
||||
current window (copy)
|
||||
full screen (copy)
|
||||
a selected area
|
||||
current window
|
||||
full screen
|
||||
"""
|
||||
|
||||
cmd = '${pkgs.rofi-wayland}/bin/rofi -dmenu -location 2 -l 6 -i -p "Screenshot which area?"'
|
||||
result = subprocess.run(cmd,
|
||||
input=options,
|
||||
stdout=subprocess.PIPE,
|
||||
stderr=subprocess.PIPE,
|
||||
shell=True,
|
||||
text=True)
|
||||
|
||||
if result.returncode != 0:
|
||||
exit(1)
|
||||
|
||||
choice = result.stdout.strip()
|
||||
cmd = "${pkgs.pkgs.sway-contrib.grimshot}/bin/grimshot "
|
||||
cmd += "copy " if re.match(".*(copy)", choice) else "save "
|
||||
|
||||
for k, v in {"a selected area.*": "area ",
|
||||
"current window.*": "active ",
|
||||
"current screen.*": "output ",
|
||||
"all screens.*": "screen "}.items():
|
||||
if re.match(k, choice):
|
||||
cmd += v
|
||||
|
||||
subprocess.call(cmd,
|
||||
shell=True)
|
||||
''
|
||||
Loading…
Add table
Add a link
Reference in a new issue