Skip to content

Instantly share code, notes, and snippets.

@neerajadhav
Last active January 2, 2023 03:41
Show Gist options
  • Save neerajadhav/17c6fb3ec6f856eb562c5c9a2f44b8af to your computer and use it in GitHub Desktop.
Save neerajadhav/17c6fb3ec6f856eb562c5c9a2f44b8af to your computer and use it in GitHub Desktop.
My Qtile Configuration Fille
# 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.
"""
---------
│Imports|
---------
"""
import os
import re
import socket
import subprocess
from typing import List # noqa: F401
from libqtile import layout, bar, widget, hook, extension
from libqtile.config import Click, Drag, Group, Key, Match, Screen, Rule
from libqtile.command import lazy
#import arcobattery
"""
-----------
|Variables|
-----------
"""
#mod4 or mod = super key
mod = "mod4"
mod1 = "alt"
mod2 = "control"
home = os.path.expanduser('~')
browser = "firefox"
terminal = "xfce4-terminal"
fileManager = "thunar"
"""
--------
|Colors|
--------
"""
def init_colors():
return[["#282c34", "#282c34"],
["#1c1f24", "#1c1f24"],
["#dfdfdf", "#dfdfdf"],
["#ff6c6b", "#ff6c6b"],
["#98be65", "#98be65"],
["#da8548", "#da8548"],
["#51afef", "#51afef"],
["#c678dd", "#c678dd"],
["#46d9ff", "#46d9ff"],
["#a9a1e1", "#a9a1e1"]]
colors = init_colors()
"""
----------------
|Lazy functions|
----------------
"""
@lazy.function
def window_to_prev_group(qtile):
if qtile.currentWindow is not None:
i = qtile.groups.index(qtile.currentGroup)
qtile.currentWindow.togroup(qtile.groups[i - 1].name)
@lazy.function
def window_to_next_group(qtile):
if qtile.currentWindow is not None:
i = qtile.groups.index(qtile.currentGroup)
qtile.currentWindow.togroup(qtile.groups[i + 1].name)
"""
--------------
|Key Bindings|
--------------
"""
keys = [
# SUPER + FUNCTION KEYS
Key([mod], "f", lazy.window.toggle_fullscreen()),
Key([mod], "q", lazy.window.kill()),
Key([mod], "f", lazy.spawn(browser)),
Key([mod], "return", lazy.spawn(terminal)),
Key([mod, "shift"], "return", lazy.spawn(fileManager)),
Key([mod], "x", lazy.spawn("archlinux-logout")),
Key([], "print", lazy.spawn("scrot 'ArcoLinux-%Y-%m-%d-%s_screenshot_$wx$h.jpg' -e 'mv $f $$(xdg-user-dir PICTURES)'")),
Key([mod], "a", lazy.spawn("xfce4-appfinder")),
# SUPER + SHIFT KEYS
Key([mod, "shift"], "q", lazy.window.kill()),
Key([mod, "shift"], "r", lazy.restart()),
# QTILE LAYOUT KEYS
Key([mod], "n", lazy.layout.normalize()),
Key([mod], "space", lazy.next_layout()),
# CHANGE FOCUS
Key([mod], "Up", lazy.layout.up()),
Key([mod], "Down", lazy.layout.down()),
Key([mod], "Left", lazy.layout.left()),
Key([mod], "Right", lazy.layout.right()),
Key([mod], "k", lazy.layout.up()),
Key([mod], "j", lazy.layout.down()),
Key([mod], "h", lazy.layout.left()),
Key([mod], "l", lazy.layout.right()),
# RESIZE UP, DOWN, LEFT, RIGHT
Key([mod, "control"], "l",
lazy.layout.grow_right(),
lazy.layout.grow(),
lazy.layout.increase_ratio(),
lazy.layout.delete(),
),
Key([mod, "control"], "Right",
lazy.layout.grow_right(),
lazy.layout.grow(),
lazy.layout.increase_ratio(),
lazy.layout.delete(),
),
Key([mod, "control"], "h",
lazy.layout.grow_left(),
lazy.layout.shrink(),
lazy.layout.decrease_ratio(),
lazy.layout.add(),
),
Key([mod, "control"], "Left",
lazy.layout.grow_left(),
lazy.layout.shrink(),
lazy.layout.decrease_ratio(),
lazy.layout.add(),
),
Key([mod, "control"], "k",
lazy.layout.grow_up(),
lazy.layout.grow(),
lazy.layout.decrease_nmaster(),
),
Key([mod, "control"], "Up",
lazy.layout.grow_up(),
lazy.layout.grow(),
lazy.layout.decrease_nmaster(),
),
Key([mod, "control"], "j",
lazy.layout.grow_down(),
lazy.layout.shrink(),
lazy.layout.increase_nmaster(),
),
Key([mod, "control"], "Down",
lazy.layout.grow_down(),
lazy.layout.shrink(),
lazy.layout.increase_nmaster(),
),
# FLIP LAYOUT FOR MONADTALL/MONADWIDE
Key([mod, "shift"], "f", lazy.layout.flip()),
# FLIP LAYOUT FOR BSP
Key([mod, "mod1"], "k", lazy.layout.flip_up()),
Key([mod, "mod1"], "j", lazy.layout.flip_down()),
Key([mod, "mod1"], "l", lazy.layout.flip_right()),
Key([mod, "mod1"], "h", lazy.layout.flip_left()),
# MOVE WINDOWS UP OR DOWN BSP LAYOUT
Key([mod, "shift"], "k", lazy.layout.shuffle_up()),
Key([mod, "shift"], "j", lazy.layout.shuffle_down()),
Key([mod, "shift"], "h", lazy.layout.shuffle_left()),
Key([mod, "shift"], "l", lazy.layout.shuffle_right()),
# MOVE WINDOWS UP OR DOWN MONADTALL/MONADWIDE LAYOUT
Key([mod, "shift"], "Up", lazy.layout.shuffle_up()),
Key([mod, "shift"], "Down", lazy.layout.shuffle_down()),
Key([mod, "shift"], "Left", lazy.layout.swap_left()),
Key([mod, "shift"], "Right", lazy.layout.swap_right()),
# TOGGLE FLOATING LAYOUT
Key([mod, "shift"], "space", lazy.window.toggle_floating()),
# Key([mod], "r", lazy.spawncmd(), desc="Spawn a command using a prompt widget"),
Key(['mod4'], 'd', lazy.run_extension(extension.DmenuRun(
dmenu_prompt="Run:",
dmenu_font="sans",
dmenu_lines=10,
))),
# Brightness controls
Key([], "XF86MonBrightnessUp", lazy.spawn(
'lux -a 10'), desc="Brightness Up"),
Key([], "XF86MonBrightnessDown", lazy.spawn(
'lux -s 10'), desc="Brightness Down"),
]
def window_to_previous_screen(qtile, switch_group=False, switch_screen=False):
i = qtile.screens.index(qtile.current_screen)
if i != 0:
group = qtile.screens[i - 1].group.name
qtile.current_window.togroup(group, switch_group=switch_group)
if switch_screen == True:
qtile.cmd_to_screen(i - 1)
def window_to_next_screen(qtile, switch_group=False, switch_screen=False):
i = qtile.screens.index(qtile.current_screen)
if i + 1 != len(qtile.screens):
group = qtile.screens[i + 1].group.name
qtile.current_window.togroup(group, switch_group=switch_group)
if switch_screen == True:
qtile.cmd_to_screen(i + 1)
keys.extend([
# MOVE WINDOW TO NEXT SCREEN
Key([mod,"shift"], "Right", lazy.function(window_to_next_screen, switch_screen=True)),
Key([mod,"shift"], "Left", lazy.function(window_to_previous_screen, switch_screen=True)),
])
"""
--------
|Groups|
--------
"""
groups = []
#["", "", "", "", "", "", "", "", "", "",]
groups = [
Group(name="1"),
Group(name="2"),
Group(name="3"),
Group(name="4"),
Group(name="5"),
Group(name="6"),
]
for i in groups:
keys.extend([
#CHANGE WORKSPACES
Key([mod], i.name, lazy.group[i.name].toscreen()),
Key([mod], "Tab", lazy.screen.next_group()),
Key([mod, "shift" ], "Tab", lazy.screen.prev_group()),
Key(["mod1"], "Tab", lazy.screen.next_group()),
Key(["mod1", "shift"], "Tab", lazy.screen.prev_group()),
# MOVE WINDOW TO SELECTED WORKSPACE 1-10 AND STAY ON WORKSPACE
#Key([mod, "shift"], i.name, lazy.window.togroup(i.name)),
# MOVE WINDOW TO SELECTED WORKSPACE 1-10 AND FOLLOW MOVED WINDOW TO WORKSPACE
Key([mod, "shift"], i.name, lazy.window.togroup(i.name) , lazy.group[i.name].toscreen()),
])
"""
---------
|Layouts|
---------
"""
def init_layout_theme():
return {"margin":10,
"border_width":2,
"border_focus": colors[8],
"border_normal": colors[9]
}
layout_theme = init_layout_theme()
layouts = [
# layout.MonadTall(margin=8, border_width=2, border_focus="#5e81ac", border_normal="#4c566a"),
layout.MonadTall(**layout_theme),
# layout.Columns(**layout_theme),
# layout.MonadWide(margin=8, border_width=2, border_focus="#5e81ac", border_normal="#4c566a"),
layout.MonadWide(**layout_theme),
layout.Matrix(**layout_theme),
# layout.Bsp(**layout_theme),
# layout.Floating(**layout_theme),
# layout.RatioTile(**layout_theme),
# layout.Max(**layout_theme)
]
"""
---------
|Widgets|
---------
"""
# WIDGETS FOR THE BAR
def init_widgets_defaults():
return dict(
font="sans",
fontsize=14,
padding=4,
background=colors[1])
widget_defaults = init_widgets_defaults()
def init_widgets_list():
widgets_list = [
widget.Sep(
linewidth=0,
padding=6,
foreground=colors[2],
background=colors[0],
),
widget.Image(
filename="~/.config/qtile/icons/.face",
scale="False",
margin=5,
foreground=colors[2],
background=colors[0],
mouse_callbacks={'Button1': lazy.spawn('dmenu_run')},
),
widget.Sep(
linewidth=0,
padding=6,
foreground=colors[2],
background=colors[0]
),
widget.GroupBox(
font="Ubuntu Bold",
fontsize=10,
margin_y=3,
margin_x=0,
padding_y=5,
padding_x=3,
borderwidth=3,
active=colors[8],
inactive=colors[2],
rounded=True,
highlight_color=colors[1],
highlight_method="line",
this_current_screen_border=colors[6],
this_screen_border=colors[4],
other_current_screen_border=colors[6],
other_screen_border=colors[4],
foreground=colors[2],
background=colors[0]
),
widget.TextBox(
text='|',
font="Ubuntu Mono",
background=colors[0],
foreground=colors[1],
padding=0,
fontsize=50
),
widget.CurrentLayoutIcon(
custom_icon_paths=[os.path.expanduser(
"~/.config/qtile/icons")],
foreground=colors[9],
background=colors[0],
padding=0,
scale=0.45,
),
widget.CurrentLayout(
foreground=colors[9],
background=colors[0],
padding=5,
),
widget.TextBox(
text='|',
font="Ubuntu Mono",
background=colors[0],
foreground=colors[1],
padding=2,
fontsize=50
),
widget.WindowName(
foreground=colors[2],
background=colors[0],
padding=0,
),
#####
widget.TextBox(
text='|',
font="Ubuntu Mono",
background=colors[0],
foreground=colors[1],
padding=0,
fontsize=50
),
widget.Net(
foreground=colors[2],
background=colors[0],
format = ' {down} {up} ',
),
#####
widget.TextBox(
text='',
background=colors[0],
foreground=colors[1],
padding=0,
fontsize=50,
),
widget.Systray(
foreground=colors[7],
background=colors[1],
padding=5,
icon_size=17,
),
widget.Volume(
foreground=colors[2],
background=colors[1],
fmt='{}',
padding=4,
fontsize=10,
),
widget.Sep(
linewidth=0,
padding=6,
background=colors[1]
),
#####
widget.TextBox(
text='',
background=colors[1],
foreground=colors[0],
padding=0,
fontsize=50,
),
widget.ThermalSensor(
foreground=colors[2],
background=colors[0],
format = ' {temp:.1f}{unit} ',
),
widget.Sep(
linewidth=0,
padding=6,
background=colors[0]
),
#####
widget.TextBox(
text='',
background=colors[0],
foreground=colors[1],
padding=0,
fontsize=50,
),
widget.Battery(
format = '  {percent:2.0%} {char} {hour:d}:{min:02d}',
charge_char='AC',
discharge_char='DC',
foreground=colors[4],
background=colors[1],
update_interval=1,
low_percentage=0.3,
low_foreground=colors[3]
),
widget.Sep(
linewidth=0,
padding=6,
background=colors[1]
),
#####
widget.TextBox(
text='',
background=colors[1],
foreground=colors[0],
padding=0,
fontsize=50,
),
widget.Clock(
foreground=colors[2],
background=colors[0],
format="  %d %b, %a %I:%M %p"
),
widget.Sep(
linewidth=0,
padding=6,
background=colors[0]
),
]
return widgets_list
widgets_list = init_widgets_list()
"""
---------
|Screens|
---------
"""
def init_widgets_screen1():
widgets_screen1 = init_widgets_list()
return widgets_screen1
def init_widgets_screen2():
widgets_screen2 = init_widgets_list()
return widgets_screen2
widgets_screen1 = init_widgets_screen1()
widgets_screen2 = init_widgets_screen2()
def init_screens():
return [
Screen(top=bar.Bar(widgets=init_widgets_screen1(), size=30, opacity=0.9)),
Screen(top=bar.Bar(widgets=init_widgets_screen2(), size=30, opacity=0.9))
]
screens = init_screens()
"""
---------
|Screens|
---------
"""
# MOUSE CONFIGURATION
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())
]
dgroups_key_binder = None
dgroups_app_rules = []
# ASSIGN APPLICATIONS TO A SPECIFIC GROUPNAME
# BEGIN
#########################################################
################ assgin apps to groups ##################
#########################################################
# @hook.subscribe.client_new
# def assign_app_group(client):
# d = {}
# #####################################################################################
# ### Use xprop fo find the value of WM_CLASS(STRING) -> First field is sufficient ###
# #####################################################################################
# d[group_names[0]] = ["Navigator", "Firefox", "Vivaldi-stable", "Vivaldi-snapshot", "Chromium", "Google-chrome", "Brave", "Brave-browser",
# "navigator", "firefox", "vivaldi-stable", "vivaldi-snapshot", "chromium", "google-chrome", "brave", "brave-browser", ]
# d[group_names[1]] = [ "Atom", "Subl", "Geany", "Brackets", "Code-oss", "Code", "TelegramDesktop", "Discord",
# "atom", "subl", "geany", "brackets", "code-oss", "code", "telegramDesktop", "discord", ]
# d[group_names[2]] = ["Inkscape", "Nomacs", "Ristretto", "Nitrogen", "Feh",
# "inkscape", "nomacs", "ristretto", "nitrogen", "feh", ]
# d[group_names[3]] = ["Gimp", "gimp" ]
# d[group_names[4]] = ["Meld", "meld", "org.gnome.meld" "org.gnome.Meld" ]
# d[group_names[5]] = ["Vlc","vlc", "Mpv", "mpv" ]
# d[group_names[6]] = ["VirtualBox Manager", "VirtualBox Machine", "Vmplayer",
# "virtualbox manager", "virtualbox machine", "vmplayer", ]
# d[group_names[7]] = ["Thunar", "Nemo", "Caja", "Nautilus", "org.gnome.Nautilus", "Pcmanfm", "Pcmanfm-qt",
# "thunar", "nemo", "caja", "nautilus", "org.gnome.nautilus", "pcmanfm", "pcmanfm-qt", ]
# d[group_names[8]] = ["Evolution", "Geary", "Mail", "Thunderbird",
# "evolution", "geary", "mail", "thunderbird" ]
# d[group_names[9]] = ["Spotify", "Pragha", "Clementine", "Deadbeef", "Audacious",
# "spotify", "pragha", "clementine", "deadbeef", "audacious" ]
# ######################################################################################
#
# wm_class = client.window.get_wm_class()[0]
#
# for i in range(len(d)):
# if wm_class in list(d.values())[i]:
# group = list(d.keys())[i]
# client.togroup(group)
# client.group.cmd_toscreen(toggle=False)
# END
# ASSIGN APPLICATIONS TO A SPECIFIC GROUPNAME
"""
-------
|Hooks|
-------
"""
main = None
@hook.subscribe.startup_once
def start_once():
home = os.path.expanduser('~')
subprocess.call([home + '/.config/qtile/scripts/autostart.sh'])
@hook.subscribe.startup
def start_always():
# Set the cursor to something sane in X
subprocess.Popen(['xsetroot', '-cursor_name', 'left_ptr'])
@hook.subscribe.client_new
def set_floating(window):
if (window.window.get_wm_transient_for()
or window.window.get_wm_type() in floating_types):
window.floating = True
"""
-----------------
|Floating Layout|
-----------------
"""
floating_types = ["notification", "toolbar", "splash", "dialog"]
follow_mouse_focus = True
bring_front_click = False
cursor_warp = False
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
Match(wm_class='Arcolinux-welcome-app.py'),
Match(wm_class='Arcolinux-calamares-tool.py'),
Match(wm_class='confirm'),
Match(wm_class='dialog'),
Match(wm_class='download'),
Match(wm_class='error'),
Match(wm_class='file_progress'),
Match(wm_class='notification'),
Match(wm_class='splash'),
Match(wm_class='toolbar'),
Match(wm_class='Arandr'),
Match(wm_class='feh'),
Match(wm_class='Galculator'),
Match(wm_class='archlinux-logout'),
], fullscreen_border_width = 0, border_width = 0)
auto_fullscreen = True
focus_on_window_activation = "focus" # or smart
wmname = "LG3D"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment