From 508bdeb553bdb43ad15adc2453fce244b0b1db6e Mon Sep 17 00:00:00 2001 From: Joseph Ferano Date: Sat, 9 May 2026 18:02:01 +0700 Subject: [PATCH] qtile: Move to corners --- .config/qtile/config.py | 40 +++++++++++++++++++++++++++++++++++++--- 1 file changed, 37 insertions(+), 3 deletions(-) diff --git a/.config/qtile/config.py b/.config/qtile/config.py index abd4b49..0ea6de2 100644 --- a/.config/qtile/config.py +++ b/.config/qtile/config.py @@ -84,6 +84,34 @@ def new_client(client): y = client.group.screen.height - client.height - padding - 22 client.set_position_floating(x,y) +def move_to_corner(corner: str) -> Callable: + def _inner(qtile) -> None: + win = qtile.current_window + if win is None: + return + + if not win.floating: + win.toggle_floating() + + screen = qtile.current_screen + padding = 0 + bar_height = 24 + + w = win.width + h = win.height + sw = screen.width + sh = screen.height + + positions = { + "top-left": (padding, bar_height + padding), + "top-right": (sw - w - padding, bar_height + padding), + "bottom-left": (padding, sh - h - padding), + "bottom-right": (sw - w - padding, sh - h - padding), + } + x, y = positions[corner] + win.set_position_floating(x, y) + return _inner + keys = [ # A list of available commands that can be bound to keys can be found # at https://docs.qtile.org/en/latest/manual/config/lazy.html @@ -91,8 +119,8 @@ keys = [ # .when(wm_class != 'kitty') # Key([mod], "h", lazy.function(move_focus, direction='left'), desc="Move focus to left"), Key([mod], "h", lazy.layout.left().when(focused=Match(wm_class=re.compile('(?![Ee]macs)'))), desc="Move focus to left"), - Key([mod], "j", lazy.layout.down().when(focused=Match(wm_class=re.compile('(?![Ee]macs)'))), desc="Move focus to left"), - Key([mod], "k", lazy.layout.up().when(focused=Match(wm_class=re.compile('(?![Ee]macs)'))), desc="Move focus to left"), + # Key([mod], "j", lazy.layout.down().when(focused=Match(wm_class=re.compile('(?![Ee]macs)'))), desc="Move focus to left"), + # Key([mod], "k", lazy.layout.up().when(focused=Match(wm_class=re.compile('(?![Ee]macs)'))), desc="Move focus to left"), Key([mod], "l", lazy.layout.right().when(focused=Match(wm_class=re.compile('(?![Ee]macs)'))), desc="Move focus to left"), # Key([alt], "tab", lazy.layout.next(), desc="Move window focus to other window"), @@ -161,19 +189,25 @@ keys = [ ), Key([mod], "t", lazy.window.toggle_floating(), desc="Toggle floating on the focused window"), Key([mod, "control"], "r", lazy.reload_config(), desc="Reload the config"), + Key([mod, "shift"], "r", lazy.spawn("reload_wm.sh"), desc="Kill Unity"), Key([mod, "control"], "q", lazy.shutdown(), desc="Shutdown Qtile"), Key([mod, alt], "space", lazy.function(toggle_language), desc="Toggle Language Layout"), Key([mod], "r", lazy.spawncmd(), desc="Spawn a command using a prompt widget"), Key([], "XF86AudioLowerVolume", lazy.spawn("amixer sset Master 5%-")), Key([], "XF86AudioRaiseVolume", lazy.spawn("amixer sset Master 5%+")), Key([], "XF86Launch1", lazy.spawn("playerctl play-pause")), + Key([], "XF86AudioMicMute", lazy.spawn("playerctl play-pause")), Key([], "XF86AudioPlay", lazy.spawn("playerctl play-pause")), Key([], "XF86MonBrightnessDown", lazy.spawn("brightnessctl set 5%-")), Key([], "XF86MonBrightnessUp", lazy.spawn("brightnessctl set +5%")), # This uses discrete values Key([], "XF86KbdBrightnessDown", lazy.function(kbd_brightness_down)), Key([], "XF86KbdBrightnessUp", lazy.function(kbd_brightness_up)), - Key([mod, "control", "shift", alt], "1", lazy.window.set_position_floating(5, 28), desc="Put the window in the corner"), + + Key([mod, alt, "control", "shift"], "q", lazy.function(move_to_corner("top-left")), desc="Move float to top-left"), + Key([mod, alt, "control", "shift"], "w", lazy.function(move_to_corner("top-right")), desc="Move float to top-right"), + Key([mod, alt, "control", "shift"], "a", lazy.function(move_to_corner("bottom-left")), desc="Move float to bottom-left"), + Key([mod, alt, "control", "shift"], "s", lazy.function(move_to_corner("bottom-right")), desc="Move float to bottom-right"), ] pape_dir = '/home/joe/Pictures/Wallpapers/'