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 a selected area
current window current window
full screen 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, result = subprocess.run(cmd,
input=options, input=options,
stdout=subprocess.PIPE, stdout=subprocess.PIPE,
@ -25,7 +26,11 @@ if result.returncode != 0:
choice = result.stdout.strip() choice = result.stdout.strip()
cmd = "${pkgs.pkgs.sway-contrib.grimshot}/bin/grimshot " 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 ", for k, v in {"a selected area.*": "area ",
"current window.*": "active ", "current window.*": "active ",
@ -36,4 +41,7 @@ for k, v in {"a selected area.*": "area ",
subprocess.call(cmd, subprocess.call(cmd,
shell=True) shell=True)
if choice == "viewer":
subprocess.run(f"nsxiv -b {filename}", shell=True)
'' ''

View file

@ -110,6 +110,7 @@
pull = "git pull"; pull = "git pull";
m = "meson"; m = "meson";
n = "ninja"; n = "ninja";
gdb_asan = "gdb -tui -ex='break __asan::ReportGenericError'";
}; };
plugins = [ plugins = [