diff options
Diffstat (limited to 'linux/qtile')
-rw-r--r-- | linux/qtile/config/__pycache__/config.cpython-312.pyc | bin | 0 -> 16859 bytes | |||
-rw-r--r-- | linux/qtile/config/__pycache__/config_screens.cpython-312.pyc | bin | 0 -> 140 bytes | |||
-rwxr-xr-x | linux/qtile/config/autostart.sh | 10 | ||||
-rw-r--r-- | linux/qtile/config/config.py.m4 | 117 | ||||
-rw-r--r-- | linux/qtile/config/group.m4.py | 67 | ||||
-rw-r--r-- | linux/qtile/config/keys.m4.py | 68 | ||||
-rw-r--r-- | linux/qtile/config/layout.m4.py | 29 | ||||
-rw-r--r-- | linux/qtile/config/screen.m4.py | 115 | ||||
-rw-r--r-- | linux/qtile/qtile-wayland.desktop | 6 | ||||
-rw-r--r-- | linux/qtile/qtile.desktop | 6 |
10 files changed, 418 insertions, 0 deletions
diff --git a/linux/qtile/config/__pycache__/config.cpython-312.pyc b/linux/qtile/config/__pycache__/config.cpython-312.pyc Binary files differnew file mode 100644 index 0000000..50e9a1f --- /dev/null +++ b/linux/qtile/config/__pycache__/config.cpython-312.pyc diff --git a/linux/qtile/config/__pycache__/config_screens.cpython-312.pyc b/linux/qtile/config/__pycache__/config_screens.cpython-312.pyc Binary files differnew file mode 100644 index 0000000..e588404 --- /dev/null +++ b/linux/qtile/config/__pycache__/config_screens.cpython-312.pyc diff --git a/linux/qtile/config/autostart.sh b/linux/qtile/config/autostart.sh new file mode 100755 index 0000000..cf95bd1 --- /dev/null +++ b/linux/qtile/config/autostart.sh @@ -0,0 +1,10 @@ +#!/bin/sh +nm-applet & +echo "Starting blueman-applet" +blueman-applet & +echo "Starting udiskie" +udiskie & +echo "Starting fcitx5" +fcitx5 -d & +echo "Starting nextcloud" +nextcloud --background & diff --git a/linux/qtile/config/config.py.m4 b/linux/qtile/config/config.py.m4 new file mode 100644 index 0000000..d32becd --- /dev/null +++ b/linux/qtile/config/config.py.m4 @@ -0,0 +1,117 @@ +# Copyright (c) 2010 Aldo Cortesi +# Copyright (c) 2010, 2014 dequis +# Copyright (c) 2012 Randall Ma +# Copyright (c) 2012-2014 Tycho Andersen +# Copyright (c) 2012 Craig Barnes +# Copyright (c) 2013 horsik +# Copyright (c) 2013 Tao Sauvage +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. + +import subprocess, os +from libqtile import bar, layout, qtile, hook, extension, widget +from libqtile.config import Click, Drag, Group, Key, Match, Screen +from libqtile.lazy import lazy +from libqtile.utils import guess_terminal, send_notification + +from qtile_extras.widget import UPowerWidget +from qtile_extras.resources import wallpapers +from libqtile.log_utils import logger + +os.environ["PATH"] += os.pathsep + os.path.expanduser('/var/lib/flatpak/exports/share') +os.environ["PATH"] += os.pathsep + os.path.expanduser('/var/lib/flatpak/exports/share/applications') + +mod = "mod4" +mod1 = "mod1" +terminal = guess_terminal() + +m4_include(`linux/qtile/config/keys.m4.py')m4_dnl + +# Add key bindings to switch VTs in Wayland. +# We can't check qtile.core.name in default config as it is loaded before qtile is started +# We therefore defer the check until the key binding is run by using .when(func=...) +for vt in range(1, 8): + keys.append( + Key( + ["control", "mod1"], + f"f{vt}", + lazy.core.change_vt(vt).when(func=lambda: qtile.core.name == "wayland"), + desc=f"Switch to VT{vt}", + ) + ) + +# Drag floating layouts. +mouse = [ + Drag([mod], "Button1", lazy.window.set_position_floating(), start=lazy.window.get_position()), + Drag([mod], "Button3", lazy.window.set_size_floating(), start=lazy.window.get_size()), + Click([mod], "Button2", lazy.window.bring_to_front()), +] + +dgroups_key_binder = None +dgroups_app_rules = [] # type: list +follow_mouse_focus = True +bring_front_click = False +floats_kept_above = True +cursor_warp = False +auto_fullscreen = True +focus_on_window_activation = "smart" +reconfigure_screens = True + +m4_include(`linux/qtile/config/screen.m4.py')m4_dnl +m4_include(`linux/qtile/config/group.m4.py')m4_dnl +m4_include(`linux/qtile/config/layout.m4.py')m4_dnl + +# Drag floating layouts. +mouse = [ + Drag([mod], "Button1", lazy.window.set_position_floating(), start=lazy.window.get_position()), + Drag([mod], "Button3", lazy.window.set_size_floating(), start=lazy.window.get_size()), + Click([mod], "Button2", lazy.window.bring_to_front()), +] + +dgroups_key_binder = None +dgroups_app_rules = [] # type: list +follow_mouse_focus = True +bring_front_click = True +floats_kept_above = True +cursor_warp = True +auto_fullscreen = True +focus_on_window_activation = "smart" +reconfigure_screens = True + +# If things like steam games want to auto-minimize themselves when losing +# focus, should we respect this or not? +auto_minimize = True + +# When using the Wayland backend, this can be used to configure input devices. +wl_input_rules = None + +# XXX: Gasp! We're lying here. In fact, nobody really uses or cares about this +# string besides java UI toolkits; you can see several discussions on the +# mailing lists, GitHub issues, and other WM documentation that suggest setting +# this string if your java app doesn't work correctly. We may as well just lie +# and say that we're a working one by default. +# +# We choose LG3D to maximize irony: it is a 3D non-reparenting WM written in +# java that happens to be on java's whitelist. +wmname = "LG3D" + +@hook.subscribe.startup_once +def autostart(): + home = os.path.expanduser('~/.config/qtile/autostart.sh') + subprocess.Popen([home]) diff --git a/linux/qtile/config/group.m4.py b/linux/qtile/config/group.m4.py new file mode 100644 index 0000000..abb64a6 --- /dev/null +++ b/linux/qtile/config/group.m4.py @@ -0,0 +1,67 @@ +groups = [ + Group(name="1"), + Group(name="2"), + Group(name="3"), + Group(name="4"), + Group(name="5"), + Group(name="6"), + Group(name="7"), + Group(name="8"), + Group(name="9"), +] + +group_screen_map = dict() + +def to_group(name: str): + def _inner(qtile): + g = qtile.groups_map[name] + if (sc := group_screen_map[name]) is not None: + if sc < num_monitors: + qtile.to_screen(sc) + g.toscreen() + return _inner + + +for g in groups: + group_screen_map[g.name] = None + keys.extend( + [ + Key( + [mod], + g.name, + lazy.function(to_group(g.name)), + desc="Switch to group {}".format(g.name), + ), + Key( + [mod, "shift"], + g.name, + lazy.window.togroup(g.name), + desc="move focused window to group {}".format(g.name) + ), + ] + ) + +@hook.subscribe.group_window_add +def group_window_add(group, window): + groups = qtile.get_groups() + global group_screen_map + group_screen_map[group.name] = groups[group.name]["screen"] + logger.warning(group_screen_map) + + +@hook.subscribe.delgroup +def group_deleted(group_name): + send_notification("qtile", f"Group deleted: {group_name}") + +@hook.subscribe.setgroup +def setgroup(): + send_notification("qtile", "Group set") + + +@hook.subscribe.changegroup +def change_group(): + send_notification("qtile", "Change group event") + +@hook.subscribe.addgroup +def group_added(group_name): + send_notification("qtile", f"New group added: {group_name}") diff --git a/linux/qtile/config/keys.m4.py b/linux/qtile/config/keys.m4.py new file mode 100644 index 0000000..3e57667 --- /dev/null +++ b/linux/qtile/config/keys.m4.py @@ -0,0 +1,68 @@ +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 + # Switch between windows + Key([mod], "h", lazy.layout.left(), desc="Move focus to left"), + Key([mod], "l", lazy.layout.right(), desc="Move focus to right"), + Key([mod], "j", lazy.layout.down(), desc="Move focus down"), + Key([mod], "k", lazy.layout.up(), desc="Move focus up"), + # Move windows between left/right columns or move up/down in current stack. + # Moving out of range in Columns layout will create new column. + Key([mod, "shift"], "h", lazy.layout.shuffle_left(), desc="Move window to the left"), + Key([mod, "shift"], "l", lazy.layout.shuffle_right(), desc="Move window to the right"), + Key([mod, "shift"], "j", lazy.layout.shuffle_down(), desc="Move window down"), + Key([mod, "shift"], "k", lazy.layout.shuffle_up(), desc="Move window up"), + # Grow windows. If current window is on the edge of screen and direction + # will be to screen edge - window would shrink. + Key([mod, "control"], "h", lazy.layout.grow_left(), desc="Grow window to the left"), + Key([mod, "control"], "l", lazy.layout.grow_right(), desc="Grow window to the right"), + Key([mod, "control"], "j", lazy.layout.grow_down(), desc="Grow window down"), + Key([mod, "control"], "k", lazy.layout.grow_up(), desc="Grow window up"), + Key([mod], "n", lazy.layout.normalize(), desc="Reset all window sizes"), + # Toggle between split and unsplit sides of stack. + # Split = all windows displayed + # Unsplit = 1 window displayed, like Max layout, but still with + # multiple stack panes + # Key( + # [mod, "shift"], + # "Return", + # lazy.layout.toggle_split(), + # desc="Toggle between split and unsplit sides of stack", + # ), + Key([mod], "Return", lazy.spawn(terminal), desc="Launch terminal"), + # Toggle between different layouts as defined below + Key([mod], "Tab", lazy.next_layout(), desc="Toggle between layouts"), + Key([mod1], "f4", lazy.window.kill(), desc="Kill focused window"), + Key( + [mod], + "f", + lazy.window.toggle_fullscreen(), + desc="Toggle fullscreen on the focused window", + ), + Key([mod], "space", lazy.window.toggle_floating(), desc="Toggle floating on the focused window"), + Key([mod, "control"], "c", lazy.reload_config(), desc="Reload the config"), + Key([mod, "control", "shift"], "c", lazy.restart(), desc="Restart QTile"), + Key([mod, "control"], "q", lazy.shutdown(), desc="Shutdown Qtile"), + Key([mod], "r", lazy.spawncmd(), desc="Spawn a command using a prompt widget"), + Key([mod], "l", lazy.spawn("xsecurelock"), desc="Toggle floating on the focused window"), + #Key([mod], 'd', lazy.run_extension(extension.DmenuRun( + # dmenu_ignorecase=True, + # dmenu_font="Andika-8", + # dmenu_lines=10, + # dmenu_bottom=True, + #))), + Key([mod], 'd', lazy.spawn("rofi -show drun")), + + # audio + Key([], 'XF86AudioRaiseVolume', lazy.spawn('amixer sset Master 5%+')), + Key([], 'XF86AudioLowerVolume', lazy.spawn('amixer sset Master 5%-')), + Key([], 'XF86AudioMute', lazy.spawn('amixer sset Master toggle')), + Key([], 'XF86AudioMicMute', lazy.spawn('amixer set Capture toggle')), + + # backlight + Key([], 'XF86MonBrightnessDown', lazy.spawn('brightnessctl set 5%-')), + Key([], 'XF86MonBrightnessUp', lazy.spawn('brightnessctl set +5%')), + + # tt gui + Key([mod, "shift"], "Return", lazy.spawn("/home/jakob/.local/bin/tt-g")), +] diff --git a/linux/qtile/config/layout.m4.py b/linux/qtile/config/layout.m4.py new file mode 100644 index 0000000..cdddb18 --- /dev/null +++ b/linux/qtile/config/layout.m4.py @@ -0,0 +1,29 @@ +layouts = [ + layout.Columns(border_focus_stack=["#d75f5f", "#8f3d3d"], border_width=4), + layout.Max(), + # Try more layouts by unleashing below layouts. + # layout.Stack(num_stacks=2), + # layout.Bsp(), + layout.Matrix(), + # layout.MonadTall(), + # layout.MonadWide(), + # layout.RatioTile(), + # layout.Tile(), + layout.TreeTab(), + # layout.VerticalTile(), + layout.Zoomy(), + # layout.Floating(), +] + +floating_layout = layout.Floating( + float_rules=[ + # Run the utility of `xprop` to see the wm class and name of an X client. + *layout.Floating.default_float_rules, + Match(wm_class="confirmreset"), # gitk + Match(wm_class="makebranch"), # gitk + Match(wm_class="maketag"), # gitk + Match(wm_class="ssh-askpass"), # ssh-askpass + Match(title="branchdialog"), # gitk + Match(title="pinentry"), # GPG key password entry + ] +) diff --git a/linux/qtile/config/screen.m4.py b/linux/qtile/config/screen.m4.py new file mode 100644 index 0000000..7511125 --- /dev/null +++ b/linux/qtile/config/screen.m4.py @@ -0,0 +1,115 @@ +from Xlib import display as xdisplay + +def get_monitors(): + display = xdisplay.Display() + screen = display.screen() + resources = screen.root.xrandr_get_screen_resources() + return [display.xrandr_get_output_info(output, resources.config_timestamp) + for output in resources.outputs] + + +# See https://github.com/qtile/qtile/wiki/screens +def get_num_monitors(): + num_monitors = 0 + try: + for monitor in get_monitors(): + preferred = False + if hasattr(monitor, 'preferred'): + preferred = monitor.preferred + elif hasattr(monitor, 'num_preferred'): + preferred = monitor.num_preferred + if preferred: + num_monitors += 1 + except Exception as e: + logger.error(e) + # always setup at least one monitor + return 1 + else: + return num_monitors + + +widget_defaults = dict( + font="sans", + fontsize=12, + padding=3, +) +extension_defaults = widget_defaults.copy() +widget_systray = widget.Systray() +widget_pomodoro = widget.Pomodoro() + +def get_widgets(systray: bool = False): + w = list() + w.append(widget.CurrentLayout()) + w.append(widget.GroupBox( + highlight_method="line", + hide_unused=True, + )) + w.append(widget.Prompt()) + w.append(widget.Chord( + chords_colors={ + "launch": ("#ff0000", "#ffffff"), + }, + name_transform=lambda name: name.upper(), + )) + + w.append(widget.Spacer()) + w.append(widget.Clock(format="%H:%M (%d-%m-%Y)")) + w.append(widget.Spacer()) + + w.append(widget.Notify()) + w.append(widget.Sep()) + w.append(widget_pomodoro) + w.append(widget.Sep()) + w.append(widget.Volume()) + w.append(widget.Sep()) + w.append(UPowerWidget()) + w.append(widget.Sep()) + + # NB Systray is incompatible with Wayland, consider using StatusNotifier instead + #w.append(widget.StatusNotifier()) + if systray: + global widget_systray + w.append(widget_systray) + #w.append(widget.QuickExit()) + return w + +def make_bar(systray: bool = False): + return bar.Bar( + get_widgets(systray), + 24, + background="#2b303b", + # border_width=[2, 0, 2, 0], # Draw top and bottom borders + # border_color=["ff00ff", "000000", "ff00ff", "000000"] # Borders are magenta + ) + +def make_screen(systray: bool = False): + return Screen( + top=make_bar(systray), + # you can uncomment this variable if you see that on x11 floating resize/moving is laggy + # by default we handle these events delayed to already improve performance, however your system might still be struggling + # this variable is set to none (no cap) by default, but you can set it to 60 to indicate that you limit it to 60 events per second + # x11_drag_polling_rate = 60, + wallpaper=wallpapers.WALLPAPER_TILES, + wallpaper_mode="fill", + ) + +def run_screen_reconfiguration(): + logger.warn("reconfiguring screens") + + global screens + screens = [make_screen(True)] + + global num_monitors + num_monitors = get_num_monitors() + if num_monitors > 1: + for i in range(num_monitors - 1): + logger.warn(f"Adding additional screen {i+1} of {num_monitors-1}") + screens.append(make_screen(False)) + +run_screen_reconfiguration() + +# Reload on screen change +@hook.subscribe.screens_reconfigured +def screen_reconf(_): + run_screen_reconfiguration() + qtile.cmd_reload_config() diff --git a/linux/qtile/qtile-wayland.desktop b/linux/qtile/qtile-wayland.desktop new file mode 100644 index 0000000..3445e1d --- /dev/null +++ b/linux/qtile/qtile-wayland.desktop @@ -0,0 +1,6 @@ +[Desktop Entry] +Name=Qtile (Wayland) +Comment=Qtile Session +Exec=qtile start -b wayland +Type=Application +Keywords=wm;tiling diff --git a/linux/qtile/qtile.desktop b/linux/qtile/qtile.desktop new file mode 100644 index 0000000..59c4c9b --- /dev/null +++ b/linux/qtile/qtile.desktop @@ -0,0 +1,6 @@ +[Desktop Entry] +Name=Qtile (X11) +Comment=Qtile Session +Exec=qtile start +Type=Application +Keywords=wm;tiling |