Files
qtile/hooks.py

73 lines
2.1 KiB
Python
Raw Normal View History

2026-02-23 17:56:46 +01:00
# _ _ _ _ _
# __ _| |_(_) | ___ | |__ ___ ___ | | _____
# / _` | __| | |/ _ \ | '_ \ / _ \ / _ \| |/ / __|
# | (_| | |_| | | __/ | | | | (_) | (_) | <\__ \
# \__, |\__|_|_|\___| |_| |_|\___/ \___/|_|\_\___/
# |_|
# by cerberus
# --------------------------------------------------------------------
# --------------------------------------------------------------------
# Imports
# --------------------------------------------------------------------
from libqtile import hook, qtile
import subprocess
import os.path
from libqtile.config import Match
2026-02-24 21:42:25 +01:00
import asyncio
2026-02-23 17:56:46 +01:00
# --------------------------------------------------------------------
# HOOK startup
# --------------------------------------------------------------------
# Client management
FULLSCREEN_RULES = [Match(wm_class="flameshot")]
@hook.subscribe.startup_once
def autostart():
2026-02-24 21:42:25 +01:00
autostartscript = "~/.config/qtile/assets/scripts/autostart.sh"
2026-02-23 17:56:46 +01:00
home = os.path.expanduser(autostartscript)
subprocess.Popen([home])
@hook.subscribe.startup_complete
def go_to_group1():
qtile.focus_screen(0)
qtile.groups_map["1"].toscreen()
@hook.subscribe.client_managed
def force_fullscreen(client) -> None:
"""
Some clients won't start fullscreen (exclusive to wayland)
With this function we force clients defined in FULLSCREEN_RULES to enter fullscreen
"""
if any(client.match(rule) for rule in FULLSCREEN_RULES):
client.fullscreen = True
2026-02-24 21:42:25 +01:00
@hook.subscribe.client_new
def tile_mpv(client):
if client.name == "mpv" or "mpvk":
client.floating = False
# @hook.subscribe.client_new
# def tile_mpv(client):
# # wm_class gibt oft eine liste zurück, z.b. ['mpv', 'mpv']
# if "mpv" in client.get_wm_class():
# client.floating = false
# @hook.subscribe.client_new
# def tile_mpv(client):
# if client.name == "mpv":
# # Wartet 0.1 Sekunden, bevor das Floating deaktiviert wird
# asyncio.create_task(set_tile(client))
#
#
# async def set_tile(client):
# await asyncio.sleep(0.1)
# client.floating = False