add screenshot to an image viewer

This commit is contained in:
Antoine Vaure 2025-02-27 15:30:08 +01:00
parent 542eb04540
commit e341716e95
2 changed files with 11 additions and 2 deletions

View file

@ -10,9 +10,10 @@ full screen (copy)
a selected area
current window
full screen
viewer
"""
cmd = '${pkgs.rofi-wayland}/bin/rofi -dmenu -location 2 -l 6 -i -p "Screenshot which area?"'
cmd = '${pkgs.rofi-wayland}/bin/rofi -dmenu -location 2 -l 7 -i -p "Screenshot which area?"'
result = subprocess.run(cmd,
input=options,
stdout=subprocess.PIPE,
@ -25,7 +26,11 @@ if result.returncode != 0:
choice = result.stdout.strip()
cmd = "${pkgs.pkgs.sway-contrib.grimshot}/bin/grimshot "
cmd += "copy " if re.match(".*(copy)", choice) else "save "
if choice == "viewer":
filename = subprocess.getoutput("mktemp")
cmd += f"save area {filename}"
else:
cmd += "copy " if re.match(".*(copy)", choice) else "save "
for k, v in {"a selected area.*": "area ",
"current window.*": "active ",
@ -36,4 +41,7 @@ for k, v in {"a selected area.*": "area ",
subprocess.call(cmd,
shell=True)
if choice == "viewer":
subprocess.run(f"nsxiv -b {filename}", shell=True)
''