mirror of
https://github.com/AZumD/frametop.git
synced 2026-10-08 13:00:05 +02:00
Spare KWin outputs, ft-floatd, the float script, decoration, and session wiring give floating windows their own panels without layout rearranging spares.
34 lines
1.5 KiB
Python
34 lines
1.5 KiB
Python
#!/usr/bin/env python3
|
|
"""ft-float: talk to ft-floatd (floating windows in the Frametop desktop).
|
|
|
|
ft-float float [ID|active] float a window (default: the active one; for it, a toggle)
|
|
ft-float float pointer the float key: float the window under the pointer (else the
|
|
active one), or put it back if it floats
|
|
ft-float dock [ID|active] put a floating window back on the desktop
|
|
ft-float dock all put every floating window back
|
|
ft-float launch APP start an app (its desktop file name, e.g. org.kde.dolphin) and
|
|
float its first window where that app last floated
|
|
ft-float run COMMAND [ARG...] the same for a command
|
|
ft-float close ID close a window
|
|
ft-float list the spare outputs and what floats on them
|
|
FT_FLOAT_SOCKET names ft-floatd's socket (default frametop_float).
|
|
"""
|
|
import json
|
|
import os
|
|
import socket
|
|
import sys
|
|
|
|
if len(sys.argv) < 2 or sys.argv[1] in ("-h", "--help"):
|
|
sys.exit(__doc__)
|
|
s = socket.socket(socket.AF_UNIX, socket.SOCK_DGRAM)
|
|
s.bind("")
|
|
s.settimeout(5)
|
|
try:
|
|
text = "run " + json.dumps(sys.argv[2:]) if sys.argv[1] == "run" else " ".join(sys.argv[1:])
|
|
s.sendto(text.encode(), "\0" + os.environ.get("FT_FLOAT_SOCKET", "frametop_float"))
|
|
reply = s.recv(8192).decode()
|
|
except OSError as e:
|
|
sys.exit(f"ft-floatd didn't answer ({e}); is the Frametop desktop running?")
|
|
print(reply)
|
|
sys.exit(0 if reply.startswith("ok") else 1)
|