33 lines
998 B
Python
Executable File
33 lines
998 B
Python
Executable File
#!/usr/bin/python
|
|
|
|
# Code explanation:
|
|
#
|
|
# 1. The script imports the subprocess and time modules.
|
|
# 2. It enters an infinite loop that continuously checks for the current
|
|
# layout.
|
|
# 3. The subprocess.run() function is used to call the hyprctl command
|
|
# and capture its output.
|
|
# 4. The output is decoded from bytes to a string and processed to extract the
|
|
# layout information.
|
|
# 5. Based on the layout, the script prints the corresponding symbol.
|
|
# 6. The script then sleeps for 1 second before checking the layout again,
|
|
# allowing it to update the output in real-time as the layout changes.
|
|
|
|
import subprocess
|
|
import time
|
|
|
|
while True:
|
|
result = subprocess.run(['hyprctl', 'getoption'
|
|
, 'general:layout'], stdout=subprocess.PIPE)
|
|
|
|
hl = result.stdout.decode('utf-8').splitlines()[0].split(':')[1].strip()
|
|
|
|
if hl == "monocle":
|
|
print("[M]")
|
|
elif hl == "scrolling":
|
|
print("[S]")
|
|
else:
|
|
print("[]=")
|
|
|
|
time.sleep(1)
|