Facebook
From y, 1 Month ago, written in Python.
Embed
Download Paste or View Raw
Hits: 139
  1. # Copyright (c) 2010 Aldo Cortesi
  2. # Copyright (c) 2010, 2014 dequis
  3. # Copyright (c) 2012 Randall Ma
  4. # Copyright (c) 2012-2014 Tycho Andersen
  5. # Copyright (c) 2012 Craig Barnes
  6. # Copyright (c) 2013 horsik
  7. # Copyright (c) 2013 Tao Sauvage
  8. #
  9. # Permission is hereby granted, free of charge, to any person obtaining a copy
  10. # of this software and associated documentation files (the "Software"), to deal
  11. # in the Software without restriction, including without limitation the rights
  12. # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  13. # copies of the Software, and to permit persons to whom the Software is
  14. # furnished to do so, subject to the following conditions:
  15. #
  16. # The above copyright notice and this permission notice shall be included in
  17. # all copies or substantial portions of the Software.
  18. #
  19. # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  20. # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  21. # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  22. # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  23. # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  24. # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  25. # SOFTWARE.
  26.  
  27. from libqtile import bar, layout, qtile, widget
  28. from libqtile.config import Click, Drag, Group, Key, Match, Screen
  29. from libqtile.lazy import lazy
  30. from libqtile.utils import guess_terminal
  31.  
  32. mod = "mod4"
  33. terminal = guess_terminal()
  34.  
  35. keys = [
  36.     # A list of available commands that can be bound to keys can be found
  37.     # at https://docs.qtile.org/en/latest/manual/config/lazy.html
  38.     # Switch between windows
  39.     Key([mod], "h", lazy.layout.left(), desc="Move focus to left"),
  40.     Key([mod], "l", lazy.layout.right(), desc="Move focus to right"),
  41.     Key([mod], "j", lazy.layout.down(), desc="Move focus down"),
  42.     Key([mod], "k", lazy.layout.up(), desc="Move focus up"),
  43.     Key([mod], "space", lazy.layout.next(), desc="Move window focus to other window"),
  44.     # Move windows between left/right columns or move up/down in current stack.
  45.     # Moving out of range in Columns layout will create new column.
  46.     Key([mod, "shift"], "h", lazy.layout.shuffle_left(), desc="Move window to the left"),
  47.     Key([mod, "shift"], "l", lazy.layout.shuffle_right(), desc="Move window to the right"),
  48.     Key([mod, "shift"], "j", lazy.layout.shuffle_down(), desc="Move window down"),
  49.     Key([mod, "shift"], "k", lazy.layout.shuffle_up(), desc="Move window up"),
  50.     # Grow windows. If current window is on the edge of screen and direction
  51.     # will be to screen edge - window would shrink.
  52.     Key([mod, "control"], "h", lazy.layout.grow_left(), desc="Grow window to the left"),
  53.     Key([mod, "control"], "l", lazy.layout.grow_right(), desc="Grow window to the right"),
  54.     Key([mod, "control"], "j", lazy.layout.grow_down(), desc="Grow window down"),
  55.     Key([mod, "control"], "k", lazy.layout.grow_up(), desc="Grow window up"),
  56.     Key([mod], "n", lazy.layout.normalize(), desc="Reset all window sizes"),
  57.     # Toggle between split and unsplit sides of stack.
  58.     # Split = all windows displayed
  59.     # Unsplit = 1 window displayed, like Max layout, but still with
  60.     # multiple stack panes
  61.     Key(
  62.         [mod, "shift"],
  63.         "Return",
  64.         lazy.layout.toggle_split(),
  65.         desc="Toggle between split and unsplit sides of stack",
  66.     ),
  67.     Key([mod], "Return", lazy.spawn(terminal), desc="Launch terminal"),
  68.     # Toggle between different layouts as defined below
  69.     Key([mod], "Tab", lazy.next_layout(), desc="Toggle between layouts"),
  70.     Key([mod], "w", lazy.window.kill(), desc="Kill focused window"),
  71.     Key(
  72.         [mod],
  73.         "f",
  74.         lazy.window.toggle_fullscreen(),
  75.         desc="Toggle fullscreen on the focused window",
  76.     ),
  77.     Key([mod], "t", lazy.window.toggle_floating(), desc="Toggle floating on the focused window"),
  78.     Key([mod, "control"], "r", lazy.reload_config(), desc="Reload the config"),
  79.     Key([mod, "control"], "q", lazy.shutdown(), desc="Shutdown Qtile"),
  80.     Key([mod], "r", lazy.spawncmd(), desc="Spawn a command using a prompt widget"),
  81. ]
  82.  
  83. # Add key bindings to switch VTs in Wayland.
  84. # We can't check qtile.core.name in default config as it is loaded before qtile is started
  85. # We therefore defer the check until the key binding is run by using .when(func=...)
  86. for vt in range(1, 8):
  87.     keys.append(
  88.         Key(
  89.             ["control", "mod1"],
  90.             f"f{vt}",
  91.             lazy.core.change_vt(vt).when(func=lambda: qtile.core.name == "wayland"),
  92.             desc=f"Switch to VT{vt}",
  93.         )
  94.     )
  95.  
  96.  
  97. groups = [Group(i) for i in "123456789"]
  98.  
  99. for i in groups:
  100.     keys.extend(
  101.         [
  102.             # mod1 + group number = switch to group
  103.             Key(
  104.                 [mod],
  105.                 i.name,
  106.                 lazy.group[i.name].toscreen(),
  107.                 desc="Switch to group {}".format(i.name),
  108.             ),
  109.             # mod1 + shift + group number = switch to & move focused window to group
  110.             Key(
  111.                 [mod, "shift"],
  112.                 i.name,
  113.                 lazy.window.togroup(i.name, switch_group=True),
  114.                 desc="Switch to & move focused window to group {}".format(i.name),
  115.             ),
  116.             # Or, use below if you prefer not to switch to that group.
  117.             # # mod1 + shift + group number = move focused window to group
  118.             # Key([mod, "shift"], i.name, lazy.window.togroup(i.name),
  119.             #     desc="move focused window to group {}".format(i.name)),
  120.         ]
  121.     )
  122.  
  123. layouts = [
  124.     layout.Columns(border_focus_stack=["#d75f5f", "#8f3d3d"], border_width=4),
  125.     layout.Max(),
  126.     # Try more layouts by unleashing below layouts.
  127.     # layout.Stack(num_stacks=2),
  128.     # layout.Bsp(),
  129.     # layout.Matrix(),
  130.     # layout.MonadTall(),
  131.     # layout.MonadWide(),
  132.     # layout.RatioTile(),
  133.     # layout.Tile(),
  134.     # layout.TreeTab(),
  135.     # layout.VerticalTile(),
  136.     # layout.Zoomy(),
  137. ]
  138.  
  139. widget_defaults = dict(
  140.     font="sans",
  141.     fontsize=12,
  142.     padding=3,
  143. )
  144. extension_defaults = widget_defaults.copy()
  145.  
  146. screens = [
  147.     Screen(
  148.         bottom=bar.Bar(
  149.             [
  150.                 widget.CurrentLayout(),
  151.                 widget.GroupBox(),
  152.                 widget.Prompt(),
  153.                 widget.WindowName(),
  154.                 widget.Chord(
  155.                     chords_colors={
  156.                         "launch": ("#ff0000", "#ffffff"),
  157.                     },
  158.                     name_transform=lambda name: name.upper(),
  159.                 ),
  160.                 widget.TextBox("default config", name="default"),
  161.                 widget.TextBox("Press <M-r> to spawn", foreground="#d75f5f"),
  162.                 # NB Systray is incompatible with Wayland, consider using StatusNotifier instead
  163.                 # widget.StatusNotifier(),
  164.                 widget.Systray(),
  165.                 widget.Clock(format="%Y-%m-%d %a %I:%M %p"),
  166.                 widget.QuickExit(),
  167.             ],
  168.             24,
  169.             # border_width=[2, 0, 2, 0],  # Draw top and bottom borders
  170.             # border_color=["ff00ff", "000000", "ff00ff", "000000"]  # Borders are magenta
  171.         ),
  172.         # You can uncomment this variable if you see that on X11 floating resize/moving is laggy
  173.         # By default we handle these events delayed to already improve performance, however your system might still be struggling
  174.         # 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
  175.         # x11_drag_polling_rate = 60,
  176.     ),
  177. ]
  178.  
  179. # Drag floating layouts.
  180. mouse = [
  181.     Drag([mod], "Button1", lazy.window.set_position_floating(), start=lazy.window.get_position()),
  182.     Drag([mod], "Button3", lazy.window.set_size_floating(), start=lazy.window.get_size()),
  183.     Click([mod], "Button2", lazy.window.bring_to_front()),
  184. ]
  185.  
  186. dgroups_key_binder = None
  187. dgroups_app_rules = []  # type: list
  188. follow_mouse_focus = True
  189. bring_front_click = False
  190. floats_kept_above = True
  191. cursor_warp = False
  192. floating_layout = layout.Floating(
  193.     float_rules=[
  194.         # Run the utility of `xprop` to see the wm class and name of an X client.
  195.         *layout.Floating.default_float_rules,
  196.         Match(wm_class="confirmreset"),  # gitk
  197.         Match(wm_class="makebranch"),  # gitk
  198.         Match(wm_class="maketag"),  # gitk
  199.         Match(wm_class="ssh-askpass"),  # ssh-askpass
  200.         Match(title="branchdialog"),  # gitk
  201.         Match(title="pinentry"),  # GPG key password entry
  202.     ]
  203. )
  204. auto_fullscreen = True
  205. focus_on_window_activation = "smart"
  206. reconfigure_screens = True
  207.  
  208. # If things like steam games want to auto-minimize themselves when losing
  209. # focus, should we respect this or not?
  210. auto_minimize = True
  211.  
  212. # When using the Wayland backend, this can be used to configure input devices.
  213. wl_input_rules = None
  214.  
  215. # XXX: Gasp! We're lying here. In fact, nobody really uses or cares about this
  216. # string besides java UI toolkits; you can see several discussions on the
  217. # mailing lists, GitHub issues, and other WM documentation that suggest setting
  218. # this string if your java app doesn't work correctly. We may as well just lie
  219. # and say that we're a working one by default.
  220. #
  221. # We choose LG3D to maximize irony: it is a 3D non-reparenting WM written in
  222. # java that happens to be on java's whitelist.
  223. wmname = "LG3D"