Guest User

Untitled

a guest
Sep 18th, 2021
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 15.75 KB | None | 0 0
  1. from posixpath import expanduser
  2. from typing import List  # noqa: F401
  3. from libqtile import bar, layout, widget, hook, qtile
  4. from libqtile.config import (
  5.     Click,
  6.     Drag,
  7.     Group,
  8.     Key,
  9.     KeyChord,
  10.     Screen,
  11.     ScratchPad,
  12.     DropDown,
  13.     Match,
  14. )
  15. from libqtile.lazy import lazy
  16. from libqtile.utils import guess_terminal
  17. from libqtile.widget import CurrentLayoutIcon
  18. import os, subprocess
  19.  
  20. # startup apps
  21.  
  22. @hook.subscribe.startup_once
  23. def autostart():
  24.     autostart_path = os.path.expanduser("~/.config/qtile/autostart.sh")
  25.     subprocess.call([autostart_path])
  26.  
  27.  
  28. mod = "mod4"
  29. terminal = "alacritty"
  30. browser = "firefox-developer-edition"
  31. editor = "emacsclient -n -c -a emacs"
  32. home = os.path.expanduser("~")
  33.  
  34. # key names for keys other than letters are weird they are all described here:
  35. # https://github.com/qtile/qtile/blob/master/libqtile/xkeysyms.py
  36. keys = [
  37.     # this toggles the floating / tiling window mode
  38.     Key([mod], "t", lazy.window.toggle_floating()),
  39.     # Switch between windows in current stack pane
  40.     Key([mod], "h", lazy.layout.left(), desc="move focus in stack pane to the left"),
  41.     Key([mod], "l", lazy.layout.right(), desc="move focus in stack pane to the right"),
  42.     Key([mod], "j", lazy.layout.down(), desc="move focus down in stack pane"),
  43.     Key([mod], "k", lazy.layout.up(), desc="move focus up in the stack pane"),
  44.     #  Move windows in current stack
  45.     Key(
  46.         [mod, "shift"],
  47.         "h",
  48.         lazy.layout.swap_left(),
  49.         desc="move window left in current stack",
  50.     ),
  51.     Key(
  52.         [mod, "shift"],
  53.         "l",
  54.         lazy.layout.swap_right(),
  55.         desc="move window right in current stack",
  56.     ),
  57.     Key(
  58.         [mod, "shift"],
  59.         "j",
  60.         lazy.layout.shuffle_down(),
  61.         desc="move window down in current stack",
  62.     ),
  63.     Key(
  64.         [mod, "shift"],
  65.         "k",
  66.         lazy.layout.shuffle_up(),
  67.         desc="move window up in current stack",
  68.     ),
  69.     # customize window sizes
  70.     Key([mod], "equal", lazy.layout.grow(), desc="increase size of window in focus"),
  71.     Key([mod], "minus", lazy.layout.shrink(), desc="decrease size of window in focus"),
  72.     Key([mod], "n", lazy.layout.reset(), desc="reset window sized back to default"),
  73.     Key(
  74.         [mod],
  75.         "o",
  76.         lazy.layout.maximize(),
  77.         desc="maximize the size of the focused window",
  78.     ),
  79.     Key(
  80.         [mod, "shift"], "space", lazy.layout.flip(), desc="flip master/stack positions"
  81.     ),
  82.     # Switch window focus to other pane(s) of stack
  83.     Key(
  84.         [mod],
  85.         "Tab",
  86.         lazy.layout.next(),
  87.         desc="Switch window focus to other pane(s) of stack",
  88.     ),
  89.     # Swap panes of split stack
  90.     # Key([mod, "shift"], "space", lazy.layout.rotate(),
  91.     #    desc="Swap panes of split stack"),
  92.     # Toggle between split and unsplit sides of stack.
  93.     # Split = all windows displayed
  94.     # Unsplit = 1 window displayed, like Max layout, but still with
  95.     # multiple stack panes
  96.     Key(
  97.         [mod, "shift"],
  98.         "Return",
  99.         lazy.layout.toggle_split(),
  100.         desc="Toggle between split and unsplit sides of stack",
  101.     ),
  102.     Key([mod], "Return", lazy.spawn(terminal), desc="Launch terminal"),
  103.     Key(
  104.         ["mod1"],
  105.         "space",
  106.         lazy.spawn(
  107.             "rofi -show drun -show-icons -theme-str 'element-icon {size: 2.5ch;}'"
  108.         ),
  109.         desc="Launch rofi",
  110.     ),
  111.     Key([mod], "e", lazy.spawn(editor), desc="Launch emacs"),
  112.     Key([mod], "w", lazy.spawn(browser), desc="Launch Firefox"),
  113.     # Key([mod], "f", lazy.spawn("alacritty -e ranger"), desc="Launch Ranger"),
  114.     # fix for issues with ranger opening and resizing
  115.     # described here: https://groups.google.com/g/qtile-dev/c/mjMKB533GNA/m/f0UGhBxpDgAJ
  116.     Key(
  117.         [mod],
  118.         "f",
  119.         # lazy.spawn("alacritty -e /home/david/.config/qtile/ranger-startup-fix.sh"),
  120.         # finally relative paths are working!
  121.         # for spawning an app with its own window  in a script or a script that
  122.         #  won't need to run in a window, simply use home + "whatever path to script"
  123.         lazy.spawn(
  124.             "" + terminal + " -e " + home + "/.config/qtile/ranger-startup-fix.sh"
  125.         ),
  126.         desc="Launch Ranger",
  127.     ),
  128.     Key(
  129.         [mod, "control"],
  130.         "l",
  131.         lazy.spawn("betterlockscreen -s blur"),
  132.         desc="lock using betterclockscreen with blur effect and suspend",
  133.     ),
  134.     Key([], "Print", lazy.spawn("flameshot gui"), desc="take a screenshot"),
  135.     # Toggle between different layouts as defined below
  136.     Key([mod], "space", lazy.next_layout(), desc="Toggle between layouts"),
  137.     Key([mod], "q", lazy.window.kill(), desc="Kill focused window"),
  138.     Key([mod, "control"], "r", lazy.restart(), desc="Restart qtile"),
  139.     Key([mod, "control"], "q", lazy.shutdown(), desc="Shutdown qtile"),
  140.     # toggle the status bar
  141.     Key([mod], "b", lazy.hide_show_bar(), desc="toggle the status bar"),
  142.     Key(
  143.         [mod, "shift"],
  144.         "f",
  145.         lazy.window.toggle_fullscreen(),
  146.         desc="turn off the bar and go full screen mode",
  147.     ),
  148.     # dropdown apps
  149.     KeyChord(
  150.         [mod],
  151.         "d",
  152.         [
  153.             Key([], "m", lazy.group["scratchpad"].dropdown_toggle("mixer")),
  154.             Key([], "t", lazy.group["scratchpad"].dropdown_toggle("term")),
  155.         ],
  156.     ),
  157.     # volume and media keys
  158.     Key(
  159.         [],
  160.         "XF86AudioMute",
  161.         lazy.spawn(home + "/.config/qtile/volume-control.sh toggle"),
  162.         # lazy.spawn("amixer -D pulse sset Master toggle"),
  163.         desc="Mute audio",
  164.     ),
  165.     Key(
  166.         [],
  167.         "XF86AudioLowerVolume",
  168.         lazy.spawn(home + "/.config/qtile/volume-control.sh down"),
  169.         # lazy.spawn("pactl set-sink-volume @DEFAULT_SINK@ -2%"),
  170.         desc="Volume down",
  171.     ),
  172.     Key(
  173.         [],
  174.         "XF86AudioRaiseVolume",
  175.         lazy.spawn(home + "/.config/qtile/volume-control.sh up"),
  176.         # lazy.spawn("pactl set-sink-volume @DEFAULT_SINK@ +2%"),
  177.         desc="Volume up",
  178.     ),
  179.     # Brightness - not working yet
  180.     # Key([], "XF86MonBrightnessDown",
  181.     #     lazy.spawn(home + "/.local/bin/statusbar/brightnesscontrol down"),
  182.     #     desc='Brightness down'
  183.     #     ),
  184.     # Key([], "XF86MonBrightnessUp",
  185.     #     lazy.spawn(home + "/.local/bin/statusbar/brightnesscontrol up"),
  186.     #     desc='Brightness up'
  187.     #     ),
  188.     # Media keys - not wokring yet (need to get them to work on bare metal)
  189.     Key(
  190.         [],
  191.         "XF86AudioPlay",
  192.         lazy.spawn("playerctl play-pause"),
  193.         desc="Audio play-pause toggle",
  194.     ),
  195.     Key([], "XF86AudioNext", lazy.spawn("playerctl next"), desc="Audio next"),
  196.     Key([], "XF86AudioPrev", lazy.spawn("playerctl next"), desc="Audio previous"),
  197. ]
  198.  
  199. groups = [
  200.     ScratchPad(
  201.         "scratchpad",
  202.         [
  203.             DropDown(
  204.                 "term",
  205.                 "alacritty",
  206.                 on_focus_lost_hide=True,
  207.                 height=0.65,
  208.                 opacity=0.95,
  209.                 warp_pointer=True,
  210.             ),
  211.             DropDown(
  212.                 "mixer",
  213.                 "pavucontrol",
  214.                 height=0.6,
  215.                 width=0.4,
  216.                 on_focus_lost_hide=True,
  217.                 opacity=1,
  218.                 warp_pointer=True,
  219.                 x=0.3,
  220.                 y=0.2,
  221.             ),
  222.         ],
  223.     ),
  224. ]
  225.  
  226. workspaces = [
  227.     # exmaple of matching workspace with an app
  228.     # {"name": "1", "key": "1", "matches": [Match(wm_class="firefox")]},
  229.     {"name": "1", "key": "1", "matches": []},
  230.     {"name": "2", "key": "2", "matches": []},
  231.     {"name": "3", "key": "3", "matches": []},
  232.     {"name": "4", "key": "4", "matches": []},
  233.     {"name": "5", "key": "5", "matches": []},
  234.     {"name": "6", "key": "6", "matches": []},
  235.     {"name": "7", "key": "7", "matches": []},
  236.     {"name": "8", "key": "8", "matches": []},
  237.     {"name": "9", "key": "9", "matches": []},
  238.     {"name": "10", "key": "0", "matches": []},
  239. ]
  240.  
  241. for workspace in workspaces:
  242.     matches = workspace["matches"] if "matches" in workspace else None
  243.     groups.append(Group(workspace["name"], matches=matches, layout="monadtall"))
  244.     keys.append(Key([mod], workspace["key"], lazy.group[workspace["name"]].toscreen()))
  245.     keys.append(
  246.         Key(
  247.             [mod, "shift"],
  248.             workspace["key"],
  249.             lazy.window.togroup(workspace["name"], switch_group=True),
  250.         )
  251.     )
  252.  
  253.  
  254. layout_theme = {
  255.     "margin": 20,
  256.     "border_width": 5,
  257.     "border_focus": "#cc241d",
  258.     "border_normal": "#282828",
  259. }
  260.  
  261. colors = {
  262.     "background": ["#1d1f21"],
  263.     "foreground": ["#c4c8c5"],
  264.     "highlight": ["#313335"],
  265.     "inactive": ["#545B68"],
  266.     "active": ["#ecf0ed"],
  267.     "red": ["#cc6666"],
  268.     "blue": ["#80a1bd"],
  269.     "green": ["#b5bd68"],
  270. }
  271.  
  272. layouts = [
  273.     layout.MonadTall(
  274.         **layout_theme,
  275.         new_client_position="bottom",
  276.         # single_border_width=0,
  277.         # single_margin=0
  278.     ),
  279.     layout.Max(),
  280.     # layout.Stack(
  281.         # **layout_theme,
  282.         # num_stacks=2
  283.         # ),
  284.     # Try more layouts by unleashing below layouts.
  285.     # layout.Bsp(),
  286.     layout.Columns(
  287.         # **layout_theme,
  288.         num_columns=3,
  289.         ),
  290.     # layout.Matrix(),
  291.     layout.MonadWide(
  292.         **layout_theme
  293.         ),
  294.     # layout.RatioTile(),
  295.     # layout.Tile(),
  296.     layout.TreeTab(
  297.          fontsize=21,
  298.          sections=[""],
  299.          section_fontsize=0,
  300.          section_top=0,
  301.          section_bottom=0,
  302.          border_width=5,
  303.          bg_color=colors["background"],
  304.          active_bg=colors["highlight"],
  305.          active_fg=colors["active"],
  306.          inactive_bg=colors["background"],
  307.          inactive_fg=colors["inactive"],
  308.          padding_left=0,
  309.          padding_x=0,
  310.          padding_y=5,
  311.          level_shift=8,
  312.          vspace=3,
  313.         panel_width=400,
  314.      ),
  315.     # layout.VerticalTile(),
  316.     # layout.Zoomy(),
  317.     # layout.Slice(),
  318.     layout.Floating(),
  319. ]
  320.  
  321. widget_defaults = dict(
  322.     # font="Source Code Pro Bold",
  323.     font="SFMono Nerd Font Mono Bold",
  324.     fontsize=21,
  325.     padding=3,
  326.     background=colors["background"],
  327.     foreground=colors["foreground"],
  328. )
  329. extension_defaults = widget_defaults.copy()
  330.  
  331. screens = [
  332.     Screen(
  333.         top=bar.Bar(
  334.             [
  335.                 widget.Spacer(length=5),
  336.                 widget.CurrentScreen(
  337.                     fontsize=40,
  338.                     active_text="",
  339.                     inactive_text="",
  340.                     active_color=colors["active"],
  341.                     inactive_color=colors["foreground"],
  342.                     padding=7,
  343.                 ),
  344.                 widget.Spacer(length=5),
  345.                 widget.GroupBox(
  346.                     active=colors["foreground"],
  347.                     inactive=colors["inactive"],
  348.                     urgent_border=colors["red"],
  349.                     urgent_text=colors["foreground"],
  350.                     highlight_color=colors["background"],
  351.                     this_current_screen_border=colors["foreground"],
  352.                     this_screen_border=colors["foreground"],
  353.                     other_current_screen_border=colors["blue"],
  354.                     other_screen_border=colors["blue"],
  355.                     highlight_method="line",
  356.                     rounded=False,
  357.                     use_mouse_wheel=False,
  358.                     fontsize=20,
  359.                     borderwidth=4,
  360.                     disable_drag=True,
  361.                 ),
  362.                 CurrentLayoutIcon(scale=0.6),
  363.                 widget.WindowName(),
  364.                 widget.Spacer(length=10),
  365.                 widget.Systray(icon_size=28),
  366.                 widget.Spacer(length=10),
  367.                 widget.WidgetBox(
  368.                     text_closed="...",
  369.                     close_button_location="right",
  370.                     text_open="...",
  371.                     widgets=[
  372.                         widget.Spacer(length=10),
  373.                         # note that when adding widgets emojis push the text more to
  374.                         # the center so clock appears to be a bit lower than widgets.
  375.                         widget.Wttr(
  376.                             location={"Manchester": "Manchester"},
  377.                             json=False,
  378.                             # if format removed it will include default
  379.                             # format="MAN: %t",
  380.                         ),
  381.                         widget.Spacer(length=10),
  382.                         widget.Volume(
  383.                             # fmt="\U0001f50a {}",  # speaker emoji and percentage
  384.                             fmt="VOL: {}",
  385.                             mute_command="amixer -D pulse sset Master toggle",
  386.                             volume_app="pavucontrol",
  387.                             get_volume_command="amixer -D pulse get Master".split(),
  388.                             volume_up_command="pactl set-sink-volume @DEFAULT_SINK@ +2%",
  389.                             volume_down_command="pactl set-sink-volume @DEFAULT_SINK@ -2%",
  390.                             padding=0,
  391.                         ),
  392.                         widget.Spacer(length=10),
  393.                     ],
  394.                 ),
  395.                 # widget.Sep(linewidth=3, padding=20, size_percent=40),
  396.                 widget.Spacer(length=10),
  397.                 widget.Clock(
  398.                     format="%b %d %A %H:%M:%S",
  399.                     mouse_callbacks={
  400.                         "Button1": lambda: qtile.cmd_spawn(
  401.                             "alacritty -e emacs -nw --eval '(progn (calendar))'"
  402.                         )
  403.                     }
  404.                     # mouse_callbacks={
  405.                     # "Button1": lambda: qtile.cmd_spawn("alacritty --hold -e cal -3")
  406.                     # },
  407.                 ),
  408.                 widget.Spacer(length=10),
  409.             ],
  410.             size=40,
  411.             opacity=1,
  412.         ),
  413.     ),
  414. ]
  415.  
  416. # Drag floating layouts.
  417. mouse = [
  418.     Drag(
  419.         [mod],
  420.         "Button1",
  421.         lazy.window.set_position_floating(),
  422.         start=lazy.window.get_position(),
  423.     ),
  424.     Drag(
  425.         [mod], "Button3", lazy.window.set_size_floating(), start=lazy.window.get_size()
  426.     ),
  427.     Click([mod], "Button2", lazy.window.bring_to_front()),
  428. ]
  429.  
  430. dgroups_key_binder = None
  431. dgroups_app_rules = []  # type: List
  432. follow_mouse_focus = True
  433. bring_front_click = False
  434. cursor_warp = True
  435.  
  436. floating_layout = layout.Floating(
  437.     **layout_theme,
  438.     float_rules=[
  439.         # Run the utility of `xprop` to see the wm class and name of an X client.
  440.         *layout.Floating.default_float_rules,
  441.         Match(wm_class="confirmreset"),  # gitk
  442.         Match(wm_class="makebranch"),  # gitk
  443.         Match(wm_class="maketag"),  # gitk
  444.         Match(wm_class="ssh-askpass"),  # ssh-askpass
  445.         Match(title="branchdialog"),  # gitk
  446.         Match(title="pinentry"),  # GPG key password entry
  447.         Match(wm_class="flameshot"),
  448.         Match(title="Picture-in-Picture"),
  449.         Match(title="Secure CRAN mirrors"),
  450.         Match(wm_class="r_x11"),
  451.     ]
  452. )
  453.  
  454. auto_fullscreen = True
  455. focus_on_window_activation = "smart"
  456. reconfigure_screens = True
  457.  
  458. # If things like steam games want to auto-minimize themselves when losing
  459. # focus, should we respect this or not?
  460. auto_minimize = True
  461.  
  462. # XXX: Gasp! We're lying here. In fact, nobody really uses or cares about this
  463. # string besides java UI toolkits; you can see several discussions on the
  464. # mailing lists, GitHub issues, and other WM documentation that suggest setting
  465. # this string if your java app doesn't work correctly. We may as well just lie
  466. # and say that we're a working one by default.
  467. #
  468. # We choose LG3D to maximize irony: it is a 3D non-reparenting WM written in
  469. # java that happens to be on java's whitelist.
  470.  
  471. wmname = "LG3D"
Advertisement
Add Comment
Please, Sign In to add comment