forked from Shinonome/caelestia-cli
screenshot: kill wayfreeze even if no selection
Also fix slurp being hidden by wayfreeze
This commit is contained in:
@@ -1,4 +1,5 @@
|
|||||||
import subprocess
|
import subprocess
|
||||||
|
import time
|
||||||
from argparse import Namespace
|
from argparse import Namespace
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
|
|
||||||
@@ -19,19 +20,28 @@ class Command:
|
|||||||
self.fullscreen()
|
self.fullscreen()
|
||||||
|
|
||||||
def region(self) -> None:
|
def region(self) -> None:
|
||||||
freeze_proc = None
|
|
||||||
|
|
||||||
if self.args.freeze:
|
|
||||||
freeze_proc = subprocess.Popen(["wayfreeze", "--hide-cursor"])
|
|
||||||
|
|
||||||
if self.args.region == "slurp":
|
if self.args.region == "slurp":
|
||||||
ws = hypr.message("activeworkspace")["id"]
|
freeze_proc = None
|
||||||
geoms = [
|
|
||||||
f"{','.join(map(str, c['at']))} {'x'.join(map(str, c['size']))}"
|
if self.args.freeze:
|
||||||
for c in hypr.message("clients")
|
freeze_proc = subprocess.Popen(["wayfreeze", "--hide-cursor"])
|
||||||
if c["workspace"]["id"] == ws
|
|
||||||
]
|
try:
|
||||||
region = subprocess.check_output(["slurp"], input="\n".join(geoms), text=True)
|
ws = hypr.message("activeworkspace")["id"]
|
||||||
|
geoms = [
|
||||||
|
f"{','.join(map(str, c['at']))} {'x'.join(map(str, c['size']))}"
|
||||||
|
for c in hypr.message("clients")
|
||||||
|
if c["workspace"]["id"] == ws
|
||||||
|
]
|
||||||
|
|
||||||
|
# Delay to ensure wayfreeze starts first
|
||||||
|
if freeze_proc:
|
||||||
|
time.sleep(0.01)
|
||||||
|
|
||||||
|
region = subprocess.check_output(["slurp"], input="\n".join(geoms), text=True)
|
||||||
|
finally:
|
||||||
|
if freeze_proc:
|
||||||
|
freeze_proc.kill()
|
||||||
else:
|
else:
|
||||||
region = self.args.region
|
region = self.args.region
|
||||||
|
|
||||||
@@ -40,9 +50,6 @@ class Command:
|
|||||||
swappy.stdin.write(sc_data)
|
swappy.stdin.write(sc_data)
|
||||||
swappy.stdin.close()
|
swappy.stdin.close()
|
||||||
|
|
||||||
if freeze_proc:
|
|
||||||
freeze_proc.kill()
|
|
||||||
|
|
||||||
def fullscreen(self) -> None:
|
def fullscreen(self) -> None:
|
||||||
sc_data = subprocess.check_output(["grim", "-"])
|
sc_data = subprocess.check_output(["grim", "-"])
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user