Advertisement
kunal12588

config.py

Mar 26th, 2022 (edited)
1,961
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 20.14 KB | Source Code | 0 0
  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. import os
  28. import subprocess
  29. from libqtile import bar, layout, hook, command
  30. from libqtile.config import Click, Drag, Group, Key, Match, Screen
  31. from libqtile.lazy import lazy
  32.  
  33. import fontawesome as fa
  34. from qtile_extras import widget
  35. from qtile_extras.widget.decorations import PowerLineDecoration
  36.  
  37. # my functions
  38. def window_title_parser(text):
  39.     # for parsing window title
  40.     app_list=("Brave", "Chromium", "Opera", "Kitty",
  41.               "nvim", "zsh", "fish", "bash", "Sublime Text",
  42.               "QuteBrowser", "MPV", "Zathura", "tilda")
  43.     for string in app_list:
  44.         if string.lower() in text.lower():
  45.             return string
  46.     if "kunal@Manjaro".lower() in text.lower():
  47.         return "Terminal"
  48.     return text
  49.  
  50. @hook.subscribe.startup_once
  51. def autostart():
  52.     home = os.path.expanduser('~/.config/qtile/autostart.sh')
  53.     subprocess.Popen([home])
  54.  
  55.  
  56.  
  57. @lazy.window.function
  58. def window_to_next_group(window):
  59.     index = window.qtile.groups.index(window.group)
  60.     if index < len(window.qtile.groups) - 1:
  61.         index = index + 1
  62.         # index = (index + 1) % len(window.qtile.groups)
  63.     window.cmd_togroup(window.qtile.groups[index].name, switch_group = True)
  64.  
  65. @lazy.window.function
  66. def window_to_prev_group(window):
  67.     index = window.qtile.groups.index(window.group)
  68.     if index > 0:
  69.         index = index - 1
  70.         # index = (index - 1) % len(window.qtile.groups)
  71.     window.cmd_togroup(window.qtile.groups[index].name, switch_group = True)
  72.  
  73.  
  74. # from libqtile.utils import guess_terminal # cbm
  75. mod = "mod4"
  76. alt = "mod1"
  77. # terminal = guess_terminal() #cbm
  78. terminal = "kitty"
  79. wallpaper_details = ("/home/kunal/Pictures/Wallpapers/wall44_1.jpg", 'fill')
  80.  
  81. keys = [
  82.     # j -> a, k -> s, h -> z, l -> x
  83.  
  84.     # A list of available commands that can be bound to keys can be found
  85.     # at https://docs.qtile.org/en/latest/manual/config/lazy.html
  86.     # Switch between windows
  87.  
  88.  
  89.  
  90.     Key([mod], "h", lazy.layout.left(), desc="Move focus to left"),
  91.     Key([mod], "l", lazy.layout.right(), desc="Move focus to right"),
  92.     Key([mod], "j", lazy.layout.down(), desc="Move focus down"),
  93.     Key([mod], "k", lazy.layout.up(), desc="Move focus up"),
  94.     Key([mod], "space", lazy.layout.next(), desc="Move window focus to other window"),
  95.  
  96.     # Move windows between left/right columns or move up/down in current stack.
  97.     # Moving out of range in Columns layout will create new column.
  98.     Key([mod, "shift"], "z", lazy.layout.shuffle_left(), desc="Move window to the left"),
  99.     Key([mod, "shift"], "x", lazy.layout.shuffle_right(), desc="Move window to the right"),
  100.     Key([mod, "shift"], "a", lazy.layout.shuffle_down(), desc="Move window down"),
  101.     Key([mod, "shift"], "s", lazy.layout.shuffle_up(), desc="Move window up"),
  102.  
  103.     # Grow windows. If current window is on the edge of screen and direction
  104.     # will be to screen edge - window would shrink.
  105.     Key([mod, "control"], "z", lazy.layout.grow_left(), desc="Grow window to the left"),
  106.     Key([mod, "control"], "x", lazy.layout.grow_right(), desc="Grow window to the right"),
  107.     Key([mod, "control"], "a", lazy.layout.grow_down(), desc="Grow window down"),
  108.     Key([mod, "control"], "s", lazy.layout.grow_up(), desc="Grow window up"),
  109.     Key([mod], "n", lazy.layout.normalize(), desc="Reset all window sizes"),
  110.  
  111.     # Toggle between split and unsplit sides of stack.
  112.     # Split = all windows displayed
  113.     # Unsplit = 1 window displayed, like Max layout, but still with
  114.     # multiple stack panes
  115.  
  116.     Key([mod, "control"], "j", lazy.screen.next_group(), desc = "Move to next Group"),
  117.     Key([mod, "control"], "k", lazy.screen.prev_group(), desc = "Move to previous Group"),    
  118.  
  119.     Key([mod, "shift"], "j", window_to_next_group(), desc = "Move window to next Group"),
  120.     Key([mod, "shift"], "k", window_to_prev_group(), desc = "Move window to previous Group"),
  121.     Key(
  122.         [mod, "shift"],
  123.         "Return",
  124.         lazy.layout.toggle_split(),
  125.         desc="Toggle between split and unsplit sides of stack",
  126.     ),
  127.     Key([mod], "t", lazy.spawn(terminal), desc="Launch terminal"), #cbm
  128.     # Toggle between different layouts as defined below
  129.     Key([mod], "Tab", lazy.next_layout(), desc="Toggle between layouts"),
  130.     Key([mod], "q", lazy.window.kill(), desc="Kill focused window"), # cbm
  131.     # Key([mod], "w", lazy.window.kill(), desc="Kill focused window"), # cbm
  132.     # Key([mod, "control"], "r", lazy.reload_config(), desc="Reload the config"), # cbm
  133.     Key([mod], "r", lazy.reload_config(), desc="Reload the config"), # cbm
  134.     Key([mod, "control"], "q", lazy.shutdown(), desc="Shutdown Qtile"), #cbm
  135.     # Key([mod, "control"], "q", lazy.spawn("/home/kunal/.config/rofi/scripts/powermenu_t3")), # cmb
  136.  
  137.     # Key([mod], "r", lazy.spawncmd(), desc="Spawn a command using a prompt widget"), #cmb
  138.     Key([mod], "slash", lazy.spawn("/home/kunal/.config/rofi/scripts/launcher_t2")), # cmb
  139.  
  140.     # my keybindings
  141.     Key([], "XF86AudioLowerVolume", lazy.spawn("pactl set-sink-volume @DEFAULT_SINK@ -5%"), desc='Volume Down'),
  142.     Key([], "XF86AudioRaiseVolume", lazy.spawn("pactl set-sink-volume @DEFAULT_SINK@ +5%"), desc='Volume Up'),
  143.     Key([], "XF86AudioMute", lazy.spawn("pactl set-sink-mute @DEFAULT_SINK@ toggle"), desc='Volume Mute'),
  144.  
  145.     Key([], "XF86MonBrightnessUp", lazy.spawn("light -A 5")),
  146.     Key([], "XF86MonBrightnessDown", lazy.spawn("light -U 5")),
  147.     # Key([], "3270_PrintScreen", lazy.spawn('gnome-screenshot -i')),
  148.     Key([], "Print", lazy.spawn('flameshot gui')),
  149.     Key([mod], "b", lazy.spawn('qutebrowser')),
  150.     Key([mod, "shift"], "b", lazy.spawn('brave')),
  151.     # Key([mod], "s", lazy.spawn('spotify')),
  152.     Key([mod], "f", lazy.spawn('nemo')),
  153.     Key([mod, "control"], "c", lazy.spawn("subl ~/.config/qtile/config.py")),
  154.     Key([mod], "c", lazy.spawn("subl")),
  155. ]
  156.  
  157. # groups = [Group(i) for i in "123456789"]
  158. # groups = [Group(i) for i in "asdfuiop"]
  159. groups = [Group(i) for i in "12345P"]
  160. # groups.append(Group("www"))
  161.  
  162.  
  163. for i in groups:
  164.     keys.extend(
  165.         [
  166.             # mod1 + letter of group = switch to group
  167.             Key(
  168.                 [mod],
  169.                 i.name,
  170.                 lazy.group[i.name].toscreen(),
  171.                 desc="Switch to group {}".format(i.name),
  172.             ),
  173.             # mod1 + shift + letter of group = switch to & move focused window to group
  174.             Key(
  175.                 [mod, "shift"],
  176.                 i.name,
  177.                 lazy.window.togroup(i.name, switch_group=True),
  178.                 desc="Switch to & move focused window to group {}".format(i.name),
  179.             ),
  180.             Key(
  181.                 [mod],
  182.                 i.name.lower()[0],
  183.                 lazy.group[i.name].toscreen(),
  184.                 desc="Switch to group {}".format(i.name),
  185.             ),
  186.             # Or, use below if you prefer not to switch to that group.
  187.             # # mod1 + shift + letter of group = move focused window to group
  188.             # Key([mod, "shift"], i.name, lazy.window.togroup(i.name),
  189.             #     desc="move focused window to group {}".format(i.name)),
  190.         ]
  191.     )
  192. keys.extend(
  193.     [
  194.         Key(
  195.             ["control"],
  196.             "space",
  197.             # lazy.screen.next_group(),
  198.             lazy.group["1"].toscreen()
  199.         ),
  200.     ]
  201. )
  202.  
  203. layouts = [
  204.     layout.Columns(border_focus_stack=["#d75f5f", "#8f3d3d"], border_width=4),
  205.     layout.Max(),
  206.     # Try more layouts by unleashing below layouts.
  207.     layout.Stack(num_stacks=2),
  208.     # layout.Bsp(),
  209.     # layout.Matrix(),
  210.     # layout.MonadTall(),
  211.     # layout.MonadWide(),
  212.     # layout.RatioTile(),
  213.     layout.Tile(),
  214.     # layout.TreeTab(),
  215.     # layout.VerticalTile(),
  216.     # layout.Zoomy(),
  217.     layout.Floating(),
  218.  
  219. ]
  220.  
  221. widget_defaults = dict(
  222.     font="Monofur Nerd Font Bold",
  223.     fontsize=15,
  224.     padding=1,
  225.     foreground = "#f4a9f5",
  226. )
  227. extension_defaults = widget_defaults.copy()
  228.  
  229. powerline_right_arrow = {
  230.     "decorations": [
  231.         PowerLineDecoration(path = "arrow_right")
  232.     ]
  233. }
  234. powerline_left_arrow = {
  235.     "decorations": [
  236.         PowerLineDecoration(path = "arrow_left")
  237.     ],
  238. }
  239.  
  240. powerline_back_slash = {
  241.     "decorations": [
  242.         PowerLineDecoration(path = "back_slash")
  243.     ]
  244. }
  245. powerline_forward_slash = {
  246.     "decorations": [
  247.         PowerLineDecoration(path = "forward_slash")
  248.     ]
  249. }
  250.  
  251. screens = [
  252.     Screen(
  253.         top=bar.Bar(
  254.             [
  255.                 # widget.CurrentLayout(),
  256.                 widget.CurrentLayoutIcon(
  257.                     fontsize=3,
  258.                     background="3c3744",
  259.                     **powerline_back_slash
  260.                 ),
  261.                 widget.CurrentLayout(
  262.                     background="0D2D6B",
  263.                     **powerline_back_slash
  264.                 ),
  265.                 widget.GroupBox(
  266.                     highlight_method="block",
  267.                     # background="21262E",
  268.                     background="00000000",
  269.                     **powerline_back_slash
  270.                 ),
  271.                 widget.TaskList(
  272.                     highlight_method="block",
  273.                     margin_y = 0,
  274.                     margin_x = 3,
  275.                     width = 250,
  276.                     icon_size = 0,
  277.                     padding_x = 3,
  278.                     rounded = False,
  279.                     txt_floating = "🗗 ",
  280.                     txt_maximized = "🗖 ",
  281.                     txt_minimized = "🗕 ",
  282.                     # font = "VictorMono Nerd Font",
  283.                     font = "Cascadiya Code Bold",
  284.                     fontsize = 12,
  285.                     parse_text=window_title_parser,
  286.                     foreground = "#b1c1fc",
  287.                     # background="293241",
  288.                     background="#00000000",
  289.                     border = "047d5d",
  290.                     **powerline_back_slash
  291.                 ),
  292.                 widget.CPU(
  293.                     mouse_callbacks = {"Button1": lazy.spawn("kitty -e htop")},
  294.                     format = "CPU {load_percent}%",
  295.                     # background = "d8315b",
  296.                     background = "#5c0424",
  297.                     # foreground = "1e1b18"
  298.                 ),
  299.                 widget.Memory(
  300.                     mouse_callbacks = {"Button1": lazy.spawn("kitty -e htop")},
  301.                     format = "|{MemUsed: .2f}{mm} of {MemTotal:.02}{mm}",
  302.                     measure_mem = "G",
  303.                     # foreground = "1e1b18",
  304.                     background = "#5c0424",
  305.                     **powerline_forward_slash
  306.                 ),
  307.                 widget.Spacer(
  308.                     # background="293241",
  309.                     background="#00000000",
  310.                     **powerline_forward_slash,
  311.                 ),
  312.                 # widget.Prompt(background="888888", **powerline),
  313.                 # widget.Chord(
  314.                 #     chords_colors={
  315.                 #         "launch": ("#ff0000", "#ffffff"),
  316.                 #     },
  317.                 #     name_transform=lambda name: name.upper(),
  318.                 # ),
  319.                 # widget.TextBox("default config", name="default"),
  320.                 # widget.TextBox("Press &lt;M-r&gt; to spawn", foreground="#d75f5f"),
  321.                 # NB Systray is incompatible with Wayland, consider using StatusNotifier instead
  322.                 # widget.StatusNotifier(),
  323.                 widget.Notify(
  324.                     action = True,
  325.                     audiofile = "/home/kunal/Music/notification.wav",
  326.                     background = "45394d",
  327.                     defualt_timout = 10,
  328.                     max_chars = 60,
  329.                     **powerline_forward_slash
  330.                 ),
  331.  
  332.                 widget.WidgetBox(
  333.                     widgets = [
  334.                         widget.PulseVolume(
  335.                             fmt=fa.icons["volume-up"]+" {}",
  336.                             volume_down_command="pactl set-sink-volume @DEFAULT_SINK@ -5%",
  337.                             volume_up_command="pactl set-sink-volume @DEFAULT_SINK@ +5%",
  338.                             update_interval=0.01,
  339.                             limit_max_volume=True,
  340.                             background = "228636",
  341.                             **powerline_forward_slash,
  342.                         ),
  343.                         widget.Backlight(
  344.                             backlight_name="amdgpu_bl0",
  345.                             change_command="light -S {0}",
  346.                             fmt=fa.icons["lightbulb"] + " {}",
  347.                             step = 1,
  348.                             background="693E00",
  349.                             **powerline_forward_slash,
  350.                         ),
  351.                         widget.Wlan(
  352.                             mouse_callbacks = {"Button1": lazy.spawn("kitty -e nmtui")},
  353.                             interface="wlo1",
  354.                             fmt=fa.icons["wifi"] + " {}",
  355.                             # format="{essid} {percent:2.0%}",
  356.                             format = "{essid}",
  357.                             background="6E40C9",
  358.                             **powerline_forward_slash,
  359.                         ),
  360.                         widget.Net(
  361.                             format = fa.icons["caret-down"] + "{down}",
  362.                             prefix = "k",
  363.                             # update_interval = 0.1,
  364.                             background="2f6473",
  365.                             **powerline_forward_slash,
  366.                         ),
  367.                         widget.Net(
  368.                             format = fa.icons["caret-up"] + "{up}",
  369.                             prefix = "k",
  370.                             # update_interval = 0.1,
  371.                             background="803651",
  372.                             **powerline_forward_slash,
  373.                         ),
  374.                     ],
  375.                     close_button_location = 'right',
  376.                     # text_closed = fa.icons["arrow-left"],
  377.                     text_closed = fa.icons["arrow-left"],
  378.                     text_open = " ",
  379.                     # background="293241",
  380.                     background="#00000000",
  381.                     **powerline_forward_slash,
  382.                 ),
  383.                 widget.Battery(
  384.                     battery = 0,
  385.                     format = "{percent:0.1%} {char}",
  386.                     update_interval = 5,
  387.                     low_percentage = 0.05,
  388.                     full_char = "",
  389.                     # charge_char = fa.icons["arrow-circle-up"],
  390.                     charge_char = fa.icons["angle-double-up"],
  391.                     # discharge_char = fa.icons["arrow-circle-down"],
  392.                     discharge_char = fa.icons["angle-double-down"],
  393.                     empty_char = "",
  394.                     fmt = fa.icons["battery-full"]+"  {}",
  395.                     background="80041a",
  396.                     **powerline_forward_slash,
  397.                     notify_below = 20,
  398.                 ),
  399.                 # widget.Systray(),
  400.                 # widget.Clock(format="%Y-%m-%d %a %I:%M %p"),
  401.                 # widget.Clock(format="%a %I:%M %p, %d/%m/%y", fmt="{}", background="45394d",**powerline_forward_slash,),
  402.                 widget.Clock(
  403.                     mouse_callbacks = {"Button1": lazy.spawn("gnome-calendar")},
  404.                     format="%a %I:%M %p",
  405.                     fmt="{}",
  406.                     background="45394d",
  407.                     **powerline_forward_slash,),
  408.                 widget.WidgetBox(
  409.                     widgets = [
  410.                         widget.Clock(
  411.                             mouse_callbacks = {"Button1": lazy.spawn("gnome-calendar")},
  412.                             format="%d %B-%m", fmt="{}",
  413.                             background="463a6d",
  414.                             **powerline_forward_slash,
  415.                         ),
  416.                     ],
  417.                     text_closed = fa.icons["arrow-right"],
  418.                     text_open = " ",
  419.                     # background="45394d",
  420.                     background="#00000000",
  421.                     **powerline_forward_slash,
  422.                 ),
  423.                 widget.QuickExit(
  424.                     default_text=fa.icons["power-off"] + "  ",
  425.                     background="047d5d",
  426.                     countdown_format = "[{}] ",
  427.                     countdown_start = 8,
  428.                 )
  429.                 # widget.QuickExit(default_text='[sayonara]')
  430.             ],
  431.             18,
  432.             # background = "#292d3e",
  433.             # foreground = "#A8A8A8",
  434.             background="#00000000",
  435.             opacity = 0.87,
  436.             # border_width=[2, 0,j2, 0],  # Draw top and bottom borders
  437.             # border_color=["ff00ff", "000000", "ff00ff", "000000"]  # Borders are magenta
  438.         ),
  439.         wallpaper=wallpaper_details[0],
  440.         wallpaper_mode=wallpaper_details[1],
  441.     ),
  442. ]
  443.  
  444. # Drag floating layouts.
  445. mouse = [
  446.     Drag([mod], "Button1", lazy.window.set_position_floating(), start=lazy.window.get_position()),
  447.     Drag([mod], "Button3", lazy.window.set_size_floating(), start=lazy.window.get_size()),
  448.     Click([mod], "Button2", lazy.window.bring_to_front()),
  449.     Click([alt], "Button3", lazy.spawn("/home/kunal/.config/rofi/scripts/launcher_t2")),
  450.     Click(["control"], "Button3", lazy.group["5"].toscreen()),
  451.     Click([mod], "Button4", lazy.screen.prev_group()),
  452.     Click([mod], "Button5", lazy.screen.next_group()),
  453. ]
  454. Group
  455. dgroups_key_binder = None
  456. dgroups_app_rules = []  # type: list
  457. # follow_mouse_focus = True # cbm
  458. follow_mouse_focus = False # cbm
  459. bring_front_click = False
  460. cursor_warp = False
  461. floating_layout = layout.Floating(
  462.     float_rules=[
  463.         # Run the utility of `xprop` to see the wm class and name of an X client.
  464.         *layout.Floating.default_float_rules,
  465.         Match(wm_class="confirmreset"),  # gitk
  466.         Match(wm_class="makebranch"),  # gitk
  467.         Match(wm_class="maketag"),  # gitk
  468.         Match(wm_class="ssh-askpass"),  # ssh-askpass
  469.         Match(title="branchdialog"),  # gitk
  470.         Match(title="pinentry"),  # GPG key password entry
  471.         Match(title="tilda"),
  472.         Match(title="Tilda"),
  473.         Match(title="Spotify"),
  474.         Match(wm_class="conky")
  475.     ]
  476. )
  477. auto_fullscreen = True
  478. focus_on_window_activation = "smart"
  479. reconfigure_screens = True
  480.  
  481.  
  482. # If things like steam games want to auto-minimize themselves when losing
  483. # focus, should we respect this or not?
  484. auto_minimize = True
  485.  
  486. # When using the Wayland backend, this can be used to configure input devices.
  487. wl_input_rules = None
  488.  
  489. # XXX: Gasp! We're lying here. In fact, nobody really uses or cares about this
  490. # string besides java UI toolkits; you can see several discussions on the
  491. # mailing lists, GitHub issues, and other WM documentation that suggest setting
  492. # this string if your java app doesn't work correctly. We may as well just lie
  493. # and say that we're a working one by default.
  494. # We choose LG3D to maximize irony: it is a 3D non-reparenting WM written in
  495. # java that happens to be on java's whitelist.
  496. wmname = "LG3D"
  497.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement