#!/usr/bin/env python3 import sys import subprocess import os def tag_window(tag:str): """ Tags the currently focused window with the specified tag. """ command = f"hyprctl dispatch tagwindow {tag}" subprocess.run(command, shell=True) def notify(message: str): """ Displays a notification with the specified message. """ command = f'hyprctl notify 1 1000 0 "{message}"'; subprocess.run(command, shell=True) if __name__ == "__main__": if len(sys.argv) < 2: print("Usage: python3 opacity.py ") sys.exit(1) opacity_value = sys.argv[1] # Validate the opacity value valid_opacities = ['0.1', '0.2', '0.3', '0.4', '0.5', '0.6', '0.7', '0.8', '0.9', '1'] if opacity_value not in valid_opacities and opacity_value != '-1': print(f"Invalid opacity value: {opacity_value}. Valid values are: {', '.join(valid_opacities)}") sys.exit(1) # If the opacity value is -1, reset to default if opacity_value == '-1': notify("Resetting opacity to default") for op in valid_opacities: tag_window(f'-- -opacity:{op}') else: notify(f"Setting opacity to {opacity_value}") for op in valid_opacities: if op == opacity_value: tag_window(f'opacity:{op}') else: tag_window(f'-- -opacity:{op}')