Added new configs and hyprvirtmon.py

This commit is contained in:
2025-08-17 14:22:04 -04:00
parent 1752303a00
commit 292be7ac05
18 changed files with 1661 additions and 446 deletions

View File

@@ -0,0 +1,63 @@
#!/usr/bin/env python
import sys
import subprocess
import json
if __name__ == "__main__":
try:
result = subprocess.run(
['hyprctl', '-j', 'monitors'],
capture_output=True, text=True, check=True
)
monitors = json.loads(result.stdout)
monitor_names = []
for monitor in monitors:
if 'name' in monitor:
monitor_names.append(monitor['name'])
if "Virtual-1" in monitor_names:
result = subprocess.run(
["hyprctl", "keyword", "monitor", "Virtual-1,disable"],
capture_output=True, text=True, check=True
)
if result.returncode != 0:
print("Failed to disable monitor Virtual-1", file=sys.stderr)
sys.exit(1)
else:
result = subprocess.run(["pkill", "-x", "wayvnc"],
capture_output=True, text=True)
if result.returncode != 0:
print("Failed to stop wayvnc", file=sys.stderr)
sys.exit(1)
else:
sys.exit(0)
else:
result = subprocess.run(
["hyprctl", "keyword", "monitor",
"Virtual-1, 2800x1752@120,1920x0,2"],
capture_output=True, text=True, check=True
)
if result.returncode != 0:
print("Failed to set monitor Virtual-1", file=sys.stderr)
sys.exit(1)
else:
result = subprocess.run(
["hyprctl", "output", "create", "headless", "Virtual-1"],
capture_output=True, text=True, check=True
)
if result.returncode != 0:
print("Failed to create headless monitor Virtual-1",
file=sys.stderr)
sys.exit(1)
else:
result = subprocess.Popen(
["wayvnc", "--output=Virtual-1", "0.0.0.0", "5900", "&"],
stdout=subprocess.DEVNULL,
stderr=subprocess.DEVNULL)
except subprocess.CalledProcessError as e:
print(f"Error executing hyprctl: {e}", file=sys.stderr)
sys.exit(1)
except Exception as e:
print(f"An unexpected error occurred: {e}", file=sys.stderr)
sys.exit(1)