apoorv569

Qtile Config

May 20th, 2020
192
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 13.16 KB | None | 0 0
  1. ##### IMPORTS #####
  2.  
  3. import os
  4. import subprocess
  5. import socket
  6. import re
  7. from libqtile.config import Key, Screen, Group, Drag, Click
  8. from libqtile.lazy import lazy
  9. from libqtile import layout, bar, widget, hook
  10.  
  11. from typing import List  # noqa: F401
  12.  
  13. ##### CONFIG #####
  14.  
  15. mod = "mod4"                                     # Sets mod key to SUPER/WINDOWS
  16. myTerm = "alacritty"                             # My terminal of choice
  17. myConfig = "/home/apoorv/.config/qtile/config.py"    # The Qtile config file location
  18.  
  19. ##### KEYBINDINGS #####
  20.  
  21. keys = [
  22.     # Switch between windows in current stack pane
  23.     Key([mod], "k", lazy.layout.down()),
  24.     Key([mod], "j", lazy.layout.up()),
  25.  
  26.     # Move windows up or down in current stack
  27.     Key([mod, "control"], "k", lazy.layout.shuffle_down()),
  28.     Key([mod, "control"], "j", lazy.layout.shuffle_up()),
  29.  
  30.     # Switch window focus to other pane(s) of stack
  31.     Key([mod], "space", lazy.layout.next()),
  32.  
  33.     # Swap panes of split stack
  34.     Key([mod, "shift"], "space", lazy.layout.rotate()),
  35.  
  36.     # Toggle between split and unsplit sides of stack.
  37.     # Split = all windows displayed
  38.     # Unsplit = 1 window displayed, like Max layout, but still with
  39.     # multiple stack panes
  40.     Key([mod, "shift"], "Return", lazy.layout.toggle_split()),
  41.     Key([mod], "Return", lazy.spawn("alacritty")),
  42.  
  43.     # Toggle between different layouts as defined below
  44.     Key([mod], "Tab", lazy.next_layout()),
  45.     Key([mod], "w", lazy.window.kill()),
  46.  
  47.     Key([mod, "control"], "r", lazy.restart()),
  48.     Key([mod, "control"], "q", lazy.shutdown()),
  49.     Key([mod], "r", lazy.spawncmd()),
  50. ]
  51.  
  52. ##### WORKSPACES #####
  53.  
  54. group_names = [("WWW", {'layout': 'monadtall'}),
  55.                ("DEV", {'layout': 'monadtall'}),
  56.                ("SYS", {'layout': 'monadtall'}),
  57.                ("DOC", {'layout': 'monadtall'}),
  58.                ("VBOX", {'layout': 'monadtall'}),
  59.                ("CHAT", {'layout': 'monadtall'}),
  60.                ("MUS", {'layout': 'monadtall'}),
  61.                ("VID", {'layout': 'monadtall'}),
  62.                ("GFX", {'layout': 'floating'})]
  63.  
  64. groups = [Group(name, **kwargs) for name, kwargs in group_names]
  65.  
  66. for i, (name, kwargs) in enumerate(group_names, 1):
  67.     keys.append(Key([mod], str(i), lazy.group[name].toscreen()))        # Switch to another group
  68.     keys.append(Key([mod, "shift"], str(i), lazy.window.togroup(name))) # Send current window to another group
  69.  
  70. ##### LAYOUT SETTINGS #####
  71.  
  72. layout_theme = {"border_width": 2,
  73.                 "margin": 6,
  74.                 "border_focus": "e1acff",
  75.                 "border_normal": "1D2330"
  76.                 }
  77.  
  78. ##### LAYOUTS #####
  79.  
  80. layouts = [
  81.     layout.Max(**layout_theme),
  82.     layout.MonadTall(**layout_theme),
  83.     layout.MonadWide(**layout_theme),
  84.     layout.Floating(**layout_theme),
  85.     # layout.RatioTile(),
  86. ]
  87.  
  88. ##### WIDGET COLORS #####
  89.  
  90. colors = [["#d2e6f1", "#d2e6f1"], # panel background
  91.           ["#434758", "#434758"], # background for current screen tab
  92.           ["#ffffff", "#ffffff"], # font color for group names
  93.           ["#ff5555", "#ff5555"], # border line color for current tab
  94.           ["#8d62a9", "#8d62a9"], # border line color for other tab and odd widgets
  95.           ["#668bd7", "#668bd7"], # color for the even widgets
  96.           ["#e1acff", "#e1acff"]] # window name
  97.  
  98. ##### PROMPT #####
  99.  
  100. prompt = "{0}@{1}: ".format(os.environ["USER"], socket.gethostname())
  101.  
  102. ##### WIDGET SETTINGS #####
  103.  
  104. widget_defaults = dict(
  105.     font='sans',
  106.     fontsize=12,
  107.     padding=2,
  108.     background=colors[2]
  109. )
  110. extension_defaults = widget_defaults.copy()
  111.  
  112. ##### WIDGETS #####
  113.  
  114. def init_widgets_list():
  115.     widgets_list = [
  116.              [  widget.Sep(
  117.                         linewidth = 0,
  118.                         padding = 6,
  119.                         foreground = colors[2],
  120.                         background = colors[0]
  121.                         ),
  122.                widget.GroupBox(font="Ubuntu Bold",
  123.                         fontsize = 9,
  124.                         margin_y = 3,
  125.                         margin_x = 0,
  126.                         padding_y = 5,
  127.                         padding_x = 5,
  128.                         borderwidth = 3,
  129.                         active = colors[2],
  130.                         inactive = colors[2],
  131.                         rounded = False,
  132.                         highlight_color = colors[1],
  133.                         highlight_method = "line",
  134.                         this_current_screen_border = colors[3],
  135.                         this_screen_border = colors [4],
  136.                         other_current_screen_border = colors[0],
  137.                         other_screen_border = colors[0],
  138.                         foreground = colors[2],
  139.                         background = colors[0]
  140.                         ),
  141.                widget.Prompt(
  142.                         prompt=prompt,
  143.                         font="Ubuntu Mono",
  144.                         padding=10,
  145.                         foreground = colors[3],
  146.                         background = colors[1]
  147.                         ),
  148.                widget.Sep(
  149.                         linewidth = 0,
  150.                         padding = 40,
  151.                         foreground = colors[2],
  152.                         background = colors[0]
  153.                         ),
  154.                widget.WindowName(
  155.                         foreground = colors[6],
  156.                         background = colors[0],
  157.                         padding = 0
  158.                         ),
  159.                widget.TextBox(
  160.                         text='',
  161.                         background = colors[0],
  162.                         foreground = colors[4],
  163.                         padding=0,
  164.                         fontsize=37
  165.                         ),
  166.                widget.TextBox(
  167.                         text=" ₿",
  168.                         padding = 0,
  169.                         foreground=colors[2],
  170.                         background=colors[4],
  171.                         fontsize=12
  172.                         ),
  173.                widget.BitcoinTicker(
  174.                         foreground=colors[2],
  175.                         background=colors[4],
  176.                         padding = 5
  177.                         ),
  178.                widget.TextBox(
  179.                         text='',
  180.                         background = colors[4],
  181.                         foreground = colors[5],
  182.                         padding=0,
  183.                         fontsize=37
  184.                         ),
  185.                widget.TextBox(
  186.                         text=" 🌡",
  187.                         padding = 2,
  188.                         foreground=colors[2],
  189.                         background=colors[5],
  190.                         fontsize=11
  191.                         ),
  192.                widget.ThermalSensor(
  193.                         foreground=colors[2],
  194.                         background=colors[5],
  195.                         padding = 5
  196.                         ),
  197.                widget.TextBox(
  198.                         text='',
  199.                         background = colors[5],
  200.                         foreground = colors[4],
  201.                         padding=0,
  202.                         fontsize=37
  203.                         ),
  204.                widget.TextBox(
  205.                         text=" ⟳",
  206.                         padding = 2,
  207.                         foreground=colors[2],
  208.                         background=colors[4],
  209.                         fontsize=14
  210.                         ),
  211.                widget.Pacman(
  212.                         execute = "alacritty",
  213.                         update_interval = 1800,
  214.                         foreground = colors[2],
  215.                         background = colors[4]
  216.                         ),
  217.                widget.TextBox(
  218.                         text="Updates",
  219.                         padding = 5,
  220.                         foreground=colors[2],
  221.                         background=colors[4]
  222.                         ),
  223.                widget.TextBox(
  224.                         text='',
  225.                         background = colors[4],
  226.                         foreground = colors[5],
  227.                         padding=0,
  228.                         fontsize=37
  229.                         ),
  230.                widget.TextBox(
  231.                         text=" 🖬",
  232.                         foreground=colors[2],
  233.                         background=colors[5],
  234.                         padding = 0,
  235.                         fontsize=14
  236.                         ),
  237.                widget.Memory(
  238.                         foreground = colors[2],
  239.                         background = colors[5],
  240.                         padding = 5
  241.                         ),
  242.                widget.TextBox(
  243.                         text='',
  244.                         background = colors[5],
  245.                         foreground = colors[4],
  246.                         padding=0,
  247.                         fontsize=37
  248.                         ),
  249.                widget.Net(
  250.                         interface = "wlp13s0",
  251.                         format = '{down} ↓↑ {up}',
  252.                         foreground = colors[2],
  253.                         background = colors[4],
  254.                         padding = 5
  255.                         ),
  256.                widget.TextBox(
  257.                         text='',
  258.                         background = colors[4],
  259.                         foreground = colors[5],
  260.                         padding=0,
  261.                         fontsize=37
  262.                         ),
  263.                widget.TextBox(
  264.                        text=" Vol:",
  265.                         foreground=colors[2],
  266.                         background=colors[5],
  267.                         padding = 0
  268.                         ),
  269.                widget.Volume(
  270.                         foreground = colors[2],
  271.                         background = colors[5],
  272.                         padding = 5
  273.                         ),
  274.                widget.TextBox(
  275.                         text='',
  276.                         background = colors[5],
  277.                         foreground = colors[4],
  278.                         padding=0,
  279.                         fontsize=37
  280.                         ),
  281.                widget.CurrentLayoutIcon(
  282.                         custom_icon_paths=[os.path.expanduser("~/.config/qtile/icons")],
  283.                         foreground = colors[0],
  284.                         background = colors[4],
  285.                         padding = 0,
  286.                         scale=0.7
  287.                         ),
  288.                widget.CurrentLayout(
  289.                         foreground = colors[2],
  290.                         background = colors[4],
  291.                         padding = 5
  292.                         ),
  293.                widget.TextBox(
  294.                         text='',
  295.                         background = colors[4],
  296.                         foreground = colors[5],
  297.                         padding=0,
  298.                         fontsize=37
  299.                         ),
  300.                widget.Clock(
  301.                         foreground = colors[2],
  302.                         background = colors[5],
  303.                         format="%A, %B %d  [ %H:%M ]"
  304.                         ),
  305.                widget.Sep(
  306.                         linewidth = 0,
  307.                         padding = 10,
  308.                         foreground = colors[0],
  309.                         background = colors[5]
  310.                         ),
  311.                widget.Systray(
  312.                         background=colors[0],
  313.                         padding = 5
  314.                         ),
  315.               ],
  316.               ]
  317.     return widgets_list
  318.  
  319. ##### BAR #####
  320.  
  321. def init_widgets_screen():
  322.     widgets_screen = init_widgets_list()
  323.     return widgets_screen
  324.  
  325. def init_screens() :
  326.     return [Screen(top=bar.Bar(widgets=init_widgets_screen(), opacity=0.95, size=20))]
  327.  
  328. if __name__ in ["config", "__main__"]:
  329.     screens = init_screens()
  330.     widgets_list = init_widgets_list()
  331.     widget_screen = init_widgets_screen()
  332.  
  333. # Drag floating layouts.
  334. mouse = [
  335.     Drag([mod], "Button1", lazy.window.set_position_floating(),
  336.          start=lazy.window.get_position()),
  337.     Drag([mod], "Button3", lazy.window.set_size_floating(),
  338.          start=lazy.window.get_size()),
  339.     Click([mod], "Button2", lazy.window.bring_to_front())
  340. ]
  341.  
  342. dgroups_key_binder = None
  343. dgroups_app_rules = []  # type: List
  344. main = None
  345. follow_mouse_focus = True
  346. bring_front_click = False
  347. cursor_warp = False
  348. floating_layout = layout.Floating(float_rules=[
  349.     # Run the utility of `xprop` to see the wm class and name of an X client.
  350.     {'wmclass': 'confirm'},
  351.     {'wmclass': 'dialog'},
  352.     {'wmclass': 'download'},
  353.     {'wmclass': 'error'},
  354.     {'wmclass': 'file_progress'},
  355.     {'wmclass': 'notification'},
  356.     {'wmclass': 'splash'},
  357.     {'wmclass': 'toolbar'},
  358.     {'wmclass': 'confirmreset'},  # gitk
  359.     {'wmclass': 'makebranch'},  # gitk
  360.     {'wmclass': 'maketag'},  # gitk
  361.     {'wname': 'branchdialog'},  # gitk
  362.     {'wname': 'pinentry'},  # GPG key password entry
  363.     {'wmclass': 'ssh-askpass'},  # ssh-askpass
  364. ])
  365. auto_fullscreen = True
  366. focus_on_window_activation = "smart"
  367.  
  368. ##### AUTOSTART #####
  369.  
  370. @hook.subscribe.startup_once
  371. def autostart():
  372.     home = os.path.expanduser('~/.config/qtile/autostart.sh')
  373.     subprocess.call([home])
Add Comment
Please, Sign In to add comment