#+PROPERTY: header-args:python :tangle ./new_config.py * Qtile configuration * Table of Contents :PROPERTIES: :TOC: :include all :ignore this :END: :CONTENTS: - [[#imports][Imports]] - [[#colors][Colors]] - [[#keybindings][Keybindings]] - [[#keyboard][Keyboard]] - [[#mouse][Mouse]] - [[#panel][Panel]] - [[#groups][Groups]] - [[#layouts][Layouts]] - [[#widgets][Widgets]] - [[#defaults][Defaults]] - [[#custom-widgets][Custom Widgets]] - [[#widget-list][Widget List]] - [[#screens][Screens]] - [[#settings][Settings]] - [[#cursor-&-wname][Cursor & wname]] :END: ** Imports #+begin_src python import os import subprocess from libqtile import layout, bar, widget, hook from libqtile.config import Click, Drag, Group, Match, Screen, Rule, Key from libqtile.command import lazy from libqtile.dgroups import simple_key_binder from colors import gruvbox, nord_fox, my_colors, dracula from spotify_widget import Spotify #+end_src ** Colors #+begin_src python :tangle ./colors.py nord_fox = { 'bg': "#2e3440", 'fg': "#b9bfca", 'fg_gutter': "#4b5668", 'black': "#3b4252", 'red': "#bf616a", 'green': "#a3be8c", 'yellow': "#ebcb8b", 'blue': "#81a1c1", 'magenta': "#b48ead", 'cyan': "#88c0d0", 'white': "#e5e9f0", 'orange': "#c9826b", 'pink': "#bf88bc", } gruvbox = { 'bg': '#282828', 'fg': '#d4be98', 'dark-red': '#ea6962', 'red': '#ea6962', 'dark-green': '#a9b665', 'green': '#a9b665', 'dark-yellow': '#e78a4e', 'yellow': '#d8a657', 'dark-blue': '#7daea3', 'blue': '#7daea3', 'dark-magenta': '#d3869b', 'magenta': '#d3869b', 'dark-cyan': '#89b482', 'cyan': '#89b482', 'dark-gray': '#665c54', 'gray': '#928374', 'fg4': '#766f64', 'fg3': '#665c54', 'fg2': '#504945', 'fg1': '#3c3836', 'bg0': '#32302f', 'fg0': '#1d2021', 'fg9': '#ebdbb2' } my_colors = { "black" : "#000000", "black2": "#2F343F", "blue" : "#3384d0", "red" : "#ff0000", "grey" : "#a9a9a9", "grey2" : "#C0C5CE", "cyan" : "#6790EB", "green" : "#62FF00", "white" : "#F3F4F5", "orange": "#FBA922", } dracula = { "bg" : "#282a36" , "fg" : "#f8f8f2", "curr": "#44475a", "cyan": "#8be9fd", "green": "#50fa7b", "orange": "#ffb86c", "purple": "#bd93f9", "red" : "#ff5555", } #+end_src ** Keybindings *** Keyboard #+begin_src python mod = "mod4" browser = "qutebrowser" term = "alacritty" editor = "emacsclient -c -a 'emacs'" dgroups_key_binder = simple_key_binder("mod4") #Change groups keys = [ Key([mod], "Return", lazy.spawn(term), ), Key([mod, "shift"], "a", lazy.spawn('anki'), ), Key([mod, "shift"], "m", lazy.spawn("spotify"), ), Key([mod], "Tab", lazy.spawn("rofi -show drun"), ), Key([mod], "r", lazy.spawn("rofi -show run"), ), Key([mod], "w", lazy.spawn("rofi -show window"), ), Key([mod], "p", lazy.spawn("passmenu -p 'Password for: '"), ), Key([mod], "b", lazy.spawn(browser), ), Key([mod, "shift"], "c", lazy.next_layout(), ), Key([mod], "q", lazy.window.kill(), ), Key([mod, "shift"], "r", lazy.restart(), ), Key([mod, "shift"], "0", lazy.shutdown(), ), Key([mod, "shift"], "e", lazy.spawn(editor), ), ### Switch focus of monitors Key([mod], "period", lazy.next_screen(), ), ### Treetab controls Key([mod, "shift"], "h", lazy.layout.move_left(), ), Key([mod, "shift"], "l", lazy.layout.move_right(), ), ### Window controls Key([mod], "j", lazy.layout.down(), ), Key([mod], "k", lazy.layout.up(), ), Key([mod, "shift"], "j", lazy.layout.shuffle_down(), lazy.layout.section_down(), ), Key([mod, "shift"], "k", lazy.layout.shuffle_up(), lazy.layout.section_up(), ), Key([mod], "h", lazy.layout.shrink(), lazy.layout.decrease_nmaster(), ), Key([mod], "l", lazy.layout.grow(), lazy.layout.increase_nmaster(), ), Key([mod], "n", lazy.layout.normalize(), ), Key([mod], "m", lazy.layout.maximize(), ), Key([mod, "shift"], "f", lazy.window.toggle_floating(), ), Key([mod], "f", lazy.window.toggle_fullscreen(), ), ### Stack controls Key([mod, "shift"], "Tab", lazy.layout.rotate(), lazy.layout.flip(), ), Key([mod, "shift"], "space", lazy.layout.toggle_split(), ), ### Volume controls Key([], "XF86AudioLowerVolume", lazy.spawn('amixer sset Master 5%-'), ), Key([], "XF86AudioRaiseVolume", lazy.spawn('amixer sset Master 5%+'), ), ### Spotify Key([mod, "shift"], "p", lazy.spawn("spotify-control play-pause"), ), Key([mod, "shift"], "n", lazy.spawn("spotify-control next"), ), Key([mod, "shift"], "b", lazy.spawn("spotify-control previous"), ), ### Change languages Key([mod], "F1", lazy.spawn("setxkbmap us -option caps:swapescape"), ), Key([mod],"F2", lazy.spawn("setxkbmap gr"), ), ] #+end_src *** Mouse #+begin_src python 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()), Click([mod], "Button2", lazy.window.bring_to_front()), ] #+end_src ** Panel *** Groups #+begin_src python groups = [] group_names = ["1", "2", "3", "4", "5", "6", "7", "8", "9", "0",] group_labels = ["Ⅰ", "Ⅱ", "Ⅲ", "Ⅳ", "Ⅴ", "Ⅵ", "Ⅶ", "Ⅷ", "Ⅸ", "Ⅹ",] group_layouts = ["monadtall", "monadtall", "monadtall", "monadtall", "monadtall", "monadtall", "monadtall", "monadtall", "monadtall", "monadtall",] for i in range(len(group_names)): groups.append( Group( name=group_names[i], layout=group_layouts[i].lower(), label=group_labels[i], )) #+end_src *** Layouts #+begin_src python def init_layout_theme(): return {"margin":5, "border_width":2, "border_focus": dracula["cyan"], "border_normal": dracula["bg"], } layout_theme = init_layout_theme() layouts = [ layout.MonadTall(**layout_theme), #layout.MonadWide(**layout_theme), #layout.Matrix(**layout_theme), #layout.Bsp(**layout_theme), layout.Floating(**layout_theme), # layout.RatioTile(**layout_theme), layout.Max(**layout_theme) ] #+end_src *** Widgets **** Defaults #+begin_src python def init_widgets_defaults(): return dict(font="Noto Sans", fontsize = 12, padding = 2, foreground =dracula["fg"], background = dracula["bg"] ) widget_defaults = init_widgets_defaults() #+end_src **** Custom Widgets ***** Spotify - A custom widget, pulls metadata via dbus, displaying song and artist of current playing song through spotify - Qtile provides a similar widget named *Mpris2* - /I wanted to play around with dbus, so I made this one/ #+begin_src python :tangle ./spotify_widget.py import dbus import subprocess from functools import partial from libqtile.widget import base class Spotify(base.ThreadPoolText): """A simple Spotify widget, made using dbus-python. Show the song and artist of now listening song and allow basic mouse control from the bar using spotify-control( Github: https://github.com/J00LZ/spotify-control AUR: https://aur.archlinux.org/packages/spotify-control ): - toggle pause (or play if stopped) on left click; - skip forward in playlist on scroll up; - skip backward in playlist on scroll down. """ defaults = [ ("color", "00ff00", "Text"), ("update_interval", 0.5, "Update Time in seconds."), ] def __init__(self, **config): base.ThreadPoolText.__init__(self, "", **config) self.add_defaults(Spotify.defaults) self.local = None self.add_callbacks( { "Button1": partial(subprocess.Popen, ["spotify-control", "play-pause"]), "Button4": partial(subprocess.Popen, ["spotify-control", "next"]), "Button5": partial(subprocess.Popen, ["spotify-control", "previous"]), } ) def now_playing(self): """Return current song""" session_bus = dbus.SessionBus() bus_data = ("org.mpris.MediaPlayer2.spotify", "/org/mpris/MediaPlayer2") spotify_bus = session_bus.get_object(*bus_data) interface = dbus.Interface(spotify_bus, "org.freedesktop.DBus.Properties") metadata = interface.Get("org.mpris.MediaPlayer2.Player", "Metadata") data = { "artist" : next(iter(metadata.get("xesam:albumArtist"))), "song" : metadata.get("xesam:title") } song = data["song"] + " ♫ " + data["artist"] self.layout.colour = self.color return song def poll(self): """Poll content for the text box.""" try: return self.now_playing() except : return "Spotify is not responding" #+end_src **** Widget List #+begin_src python def init_widgets_list(): widgets_list = [ widget.Spacer( length=7, ), widget.Image( filename = "~/.config/qtile/rms.png", scale = "True", margin = 2, ), widget.Spacer( length=7, ), widget.GroupBox( font="FontAwesome", fontsize = 20, padding = 3, margin = 4, borderwidth = 1, active = dracula["cyan"], inactive = dracula["curr"], rounded = False, highlight_method = "line", this_current_screen_border = dracula["red"], other_current_screen_border = dracula["curr"], ), widget.CurrentLayout( font = "Noto Sans Bold", foreground = dracula["fg"], background = "#5B4B8A", ), widget.Spacer( length=5 ), widget.WindowName( font="JetBrains Mono Bold", fontsize = 12, foreground = dracula["green"], background = dracula["bg"], ), # widget.Image( # filename = "~/.config/qtile/spotify2.png", # scale = True, # ), # Spotify( # fontsize = 12, # background = dracula["bg"], # color = dracula["green"], # fmt = '{}', # font = "JetBrains Mono Bold" # ), # widget.Moc( # font = "JetBrains Mono", # fontsize= 13, # play_color=dracula["green"], # paddig = 10, # ), widget.Spacer( length=10, ), widget.Image( filename = "~/.config/qtile/volume1.png", scale = True, ), widget.Spacer( length=7, padding = 10, ), widget.Volume( fontsize = 15, fmt = '{} ' , background = dracula["bg"], foreground = dracula['orange'], font = "JetBrains Mono", margin = 10, ), # widget.Mpris2( # fontsize= 16, # background = my_colors["red"], # objname="org.mpris.MediaPlayer2.spotify" # ), widget.Spacer( length=7, padding = 10, ), widget.Image( filename = "~/.config/qtile/ram2.png", scale = True, ), widget.Memory( measure_mem="G", fontsize=15, foreground = dracula["cyan"], background = dracula["bg"], font='JetBrains Mono Bold', ), widget.MemoryGraph( type='box', graph_color = dracula["cyan"], foreground = dracula["fg"], background = dracula["bg"], ), widget.Spacer( length=7 ), widget.Image( filename = "~/.config/qtile/cpu1.png", scale = True, ), widget.ThermalSensor( threshold=50, fontsize=15, font='JetBrains Mono Bold', foreground = dracula["cyan"], background = dracula["bg"], ), widget.CPUGraph( type='box', graph_color = dracula["cyan"], background = dracula["bg"], ), widget.Spacer( length=5 ), widget.TextBox( font="FontAwesome", text="  ", foreground=dracula["orange"], background=dracula["bg"], padding = 2, fontsize=18 ), widget.Clock( font='JetBrains Mono Bold', foreground = dracula["cyan"], background = dracula["bg"], fontsize = 18, format="%d-%m-%Y | %H:%M" ), widget.Spacer( length=6 ), widget.Systray( background= dracula["bg"], icon_size=20, padding = 10, margin = 10, ), widget.Spacer( length=5 ), ] return widgets_list #+end_src ** Screens #+begin_src python widgets_screen1 = init_widgets_screen1() widgets_screen2 = init_widgets_screen2() def init_screens(): return [Screen(top=bar.Bar(widgets=init_widgets_screen1(), size=33, margin = [6,20,3,20]),), Screen(top=bar.Bar(widgets=init_widgets_screen2(), size=28, margin = 7))] screens = init_screens() #+end_src ** Settings *** Cursor & wname #+begin_src python follow_mouse_focus = True bring_front_click = False cursor_warp = True auto_fullscreen = True focus_on_window_activation = "smart" # or smart wmname = "Qtile-Apo11o" #+end_src