-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9ca3008
commit 8bd3c35
Showing
17 changed files
with
300 additions
and
458 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,157 @@ | ||
import colors | ||
|
||
from functools import partialmethod | ||
|
||
from libqtile import widget | ||
from libqtile.lazy import lazy | ||
|
||
import re | ||
import subprocess | ||
|
||
from libqtile import bar, widget | ||
|
||
|
||
widget_defaults = dict( | ||
font="JetBrainsMono Nerd Font", | ||
fontsize=12, | ||
padding=12, | ||
background=colors.BG_DARK.with_alpha(0.9), | ||
foreground=colors.TEXT_LIGHT, | ||
) | ||
|
||
|
||
def mk_overrides(cls, **conf): | ||
init_method = partialmethod(cls.__init__, **conf) | ||
return type(cls.__name__, (cls,), {"__init__": init_method}) | ||
|
||
|
||
Battery = mk_overrides( | ||
widget.Battery, | ||
format="⚡{percent:2.0%}", | ||
background=colors.BG_DARK.with_alpha(0.7), | ||
foreground=colors.TEXT_LIGHT, | ||
low_background=colors.RED_DARK.with_alpha(0.7), | ||
low_percentage=0.1, | ||
) | ||
|
||
CPUGraph = mk_overrides( | ||
widget.CPUGraph, type="line", line_width=1, border_width=0 | ||
) | ||
|
||
GroupBox = mk_overrides( | ||
widget.GroupBox, | ||
highlight_method="line", | ||
disable_drag=True, | ||
other_screen_border=colors.BLUE_VERY_DARK, | ||
other_current_screen_border=colors.BLUE_VERY_DARK, | ||
this_screen_border=colors.BLUE_DARK, | ||
this_current_screen_border=colors.BLUE_DARK, | ||
block_highlight_text_color=colors.TEXT_LIGHT, | ||
highlight_color=[colors.BG_LIGHT, colors.BG_LIGHT], | ||
inactive=colors.TEXT_INACTIVE, | ||
active=colors.TEXT_LIGHT, | ||
) | ||
|
||
Mpris2 = mk_overrides( | ||
widget.Mpris2, | ||
objname="org.mpris.MediaPlayer2.spotify", | ||
format='{xesam:title} - {xesam:artist}', | ||
) | ||
|
||
Memory = mk_overrides( | ||
widget.Memory, | ||
format="{MemUsed: .3f}Mb", | ||
mouse_callbacks={ | ||
"Button1": lazy.spawn( | ||
"kitty" | ||
" -o initial_window_width=1720" | ||
" -o initial_window_height=860" | ||
" -e btop" | ||
) | ||
}, | ||
) | ||
|
||
TaskList = mk_overrides( | ||
widget.TaskList, | ||
icon_size=0, | ||
fontsize=12, | ||
borderwidth=0, | ||
margin=0, | ||
padding=4, | ||
txt_floating="", | ||
highlight_method="block", | ||
title_width_method="uniform", | ||
spacing=8, | ||
foreground=colors.TEXT_LIGHT, | ||
background=colors.BG_DARK.with_alpha(0.8), | ||
border=colors.BG_DARK.with_alpha(0.9), | ||
) | ||
|
||
Separator = mk_overrides(widget.Spacer, length=4) | ||
Clock = mk_overrides(widget.Clock, format="%A, %b %-d %H:%M") | ||
|
||
|
||
QuickExit = mk_overrides( | ||
widget.QuickExit, default_text="⏻", countdown_format="{}" | ||
) | ||
|
||
Prompt = mk_overrides( | ||
widget.Prompt, | ||
prompt=">", | ||
bell_style="visual", | ||
background=colors.BG_DARK, | ||
foreground=colors.TEXT_LIGHT, | ||
padding=8, | ||
) | ||
|
||
Systray = mk_overrides( | ||
widget.Systray, | ||
icon_size=14, | ||
padding=8 | ||
) | ||
|
||
|
||
class Bar(bar.Bar): | ||
_widgets = [ | ||
GroupBox, | ||
Separator, | ||
TaskList, | ||
Separator, | ||
Prompt, | ||
Mpris2, | ||
Battery, | ||
Memory, | ||
CPUGraph, | ||
Separator, | ||
widget.Volume, | ||
Clock, | ||
Separator, | ||
QuickExit, | ||
] | ||
|
||
def __init__(self, id_): | ||
self.id = id_ | ||
super().__init__( | ||
widgets=self._build_widgets(), | ||
size=24, | ||
background=colors.BG_DARK, | ||
margin=[0, 0, 8, 0] | ||
) | ||
|
||
def is_desktop(self): | ||
machine_info = subprocess.check_output( | ||
["hostnamectl", "status"], universal_newlines=True) | ||
m = re.search(r"Chassis: (\w+)\s.*\n", machine_info) | ||
chassis_type = "desktop" if m is None else m.group(1) | ||
|
||
return chassis_type == "desktop" | ||
|
||
def _build_widgets(self): | ||
if self.is_desktop(): | ||
self._widgets = [w for w in self._widgets if w != Battery] | ||
|
||
widgets = [widget_cls() for widget_cls in self._widgets] | ||
if self.id == 0: | ||
widgets.insert(13, Systray()) | ||
|
||
return widgets |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
class Color(str): | ||
def with_alpha(self, alpha: float) -> str: | ||
return f"{self}{int(alpha * 255):02x}" | ||
|
||
|
||
BG_DARK = Color("#0F0F1C") | ||
BG_LIGHT = Color("#1A1C31") | ||
BG_LIGHTER = Color("#22263F") | ||
|
||
RED_DARK = Color("#D22942") | ||
RED_LIGHT = Color("#DE4259") | ||
|
||
GREEN_DARK = Color("#17B67C") | ||
GREEN_LIGHT = Color("#3FD7A0") | ||
|
||
YELLOW_DARK = Color("#F2A174") | ||
YELLOW_LIGHT = Color("#EED49F") | ||
|
||
BLUE_VERY_DARK = Color("#3F3D9E") | ||
BLUE_DARK = Color("#8B8AF1") | ||
BLUE_LIGHT = Color("#A7A5FB") | ||
|
||
PURPLE_DARK = Color("#D78AF1") | ||
PURPLE_LIGHT = Color("#E5A5FB") | ||
|
||
CYAN_DARK = Color("#8ADEF1") | ||
CYAN_LIGHT = Color("#A5EBFB") | ||
|
||
TEXT_INACTIVE = Color("#292C39") | ||
TEXT_DARK = Color("#A2B1E8") | ||
TEXT_LIGHT = Color("#CAD3F5") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,44 +1,109 @@ | ||
from core import ( | ||
autostart, | ||
floating_layout, | ||
groups, | ||
keys, | ||
layouts, | ||
mouse, | ||
screens | ||
) | ||
from functools import partial | ||
|
||
from widgets import widget_defaults | ||
import os | ||
from libqtile.bar import Gap | ||
from libqtile.config import DropDown, Group, Key, Match, Screen, ScratchPad | ||
from libqtile.layout.columns import Columns | ||
from libqtile.layout.floating import Floating | ||
from libqtile.lazy import lazy | ||
|
||
from bar import Bar, widget_defaults | ||
from controls import mod, keys | ||
|
||
@lambda f: globals().update(f()) | ||
def setup_qtile_globals(): | ||
return dict( | ||
extension_defaults = widget_defaults.copy(), | ||
import colors | ||
|
||
dgroups_key_binder = None, | ||
dgroups_app_rules = [], | ||
|
||
follow_mouse_focus = True, | ||
bring_front_click = False, | ||
cursor_warp = False, | ||
_gap = Gap(4) | ||
Screen = partial( | ||
Screen, | ||
bottom=_gap, left=_gap, right=_gap, | ||
wallpaper=os.path.expanduser("~/assets/wallpaper.png"), | ||
wallpaper_mode="fill" | ||
) | ||
|
||
auto_fullscreen = True, | ||
focus_on_window_activation = "smart", | ||
reconfigure_screens = True, | ||
screens = [Screen(top=Bar(i)) for i in range(2)] | ||
|
||
auto_minimize = False, | ||
wmname = "Qtile" | ||
layouts = [ | ||
Columns( | ||
border_width=2, | ||
margin=4, | ||
border_focus=colors.BLUE_DARK, | ||
border_normal=colors.BG_DARK | ||
) | ||
] | ||
|
||
floating_layout = Floating( | ||
border_width=2, | ||
border_focus=colors.BLUE_DARK, | ||
border_normal=colors.BG_DARK, | ||
float_rules=[ | ||
*Floating.default_float_rules, | ||
Match(wm_class="pavucontrol"), | ||
Match(wm_class="confirmreset"), | ||
Match(wm_class="ssh-askpass"), | ||
Match(title="pinentry"), | ||
Match(title="kitty"), | ||
], | ||
) | ||
|
||
class _Group(Group): | ||
|
||
def __init__(self, name: str, key: str): | ||
self.name = name | ||
self.key = key | ||
|
||
super().__init__(name) | ||
self.setup_keys() | ||
|
||
@classmethod | ||
def setup_single_keys(cls): | ||
toggle_term = Key( | ||
[mod, "shift"], "space", | ||
lazy.group["scratchpad"].dropdown_toggle("term"), | ||
) | ||
|
||
keys.append(toggle_term) | ||
|
||
def setup_keys(self): | ||
move = Key([mod], self.key, lazy.group[self.name].toscreen()) | ||
switch = Key( | ||
[mod, "shift"], self.key, | ||
lazy.window.togroup(self.name, switch_group=True), | ||
) | ||
|
||
__all__ = ( | ||
"autostart", | ||
"keys", | ||
"mouse", | ||
"groups", | ||
"layouts", | ||
"floating_layout", | ||
"screens", | ||
"widget_defaults", | ||
keys.extend((move, switch)) | ||
|
||
_scratchpad_defaults = dict( | ||
x=0.05, | ||
y=0.05, | ||
opacity=0.95, | ||
height=0.9, | ||
width=0.9, | ||
on_focus_lost_hide=False | ||
) | ||
|
||
_scratchpads = [ | ||
ScratchPad( | ||
"scratchpad", | ||
[DropDown("term", "kitty", **_scratchpad_defaults)] | ||
) | ||
] | ||
|
||
_Group.setup_single_keys() | ||
groups = _scratchpads + [_Group(lb, k) for lb, k in zip("ζπδωλσς", "1234567")] | ||
|
||
extension_defaults = widget_defaults.copy() | ||
|
||
dgroups_key_binder = None | ||
dgroups_app_rules = [] | ||
|
||
follow_mouse_focus = True | ||
bring_front_click = False | ||
cursor_warp = False | ||
|
||
auto_fullscreen = True | ||
focus_on_window_activation = "smart" | ||
reconfigure_screens = True | ||
|
||
auto_minimize = False | ||
wmname = "Qtile" |
Oops, something went wrong.