qtile/bar.py
2024-12-22 12:12:45 +01:00

166 lines
3.7 KiB
Python

from libqtile import bar, layout, widget, hook
from libqtile.config import Click, Drag, Group, Key, Match, Screen
from libqtile.lazy import lazy
from libqtile.utils import guess_terminal, send_notification
from qtile_extras import widget
from qtile_extras.widget.decorations import PowerLineDecoration
# Defaults
widget_defaults = dict(
font="sans",
fontsize=12,
padding=3,
)
extension_defaults = widget_defaults.copy()
colors = [["#293136", "#293136"], #bg_dim [0]
["#333C43", "#333C43"], #bg_0 [1]
["#3A464C", "#3A464C"], #bg_1 [2]
["#434F55", "#434F55"], #bg_2 [3]
["#4D5960", "#4D5960"], #bg_3 [4]
["#555F66", "#555F66"], #bg_4 [5]
["#7FBBB3", "#7FBBB3"], #blue [6]
["#A7C080", "#A7C080"], #green [7]
["#DBBC7F", "#DBBC7F"], #yellow [8]
["#E69875", "#E69875"], #orange [9]
['#ED8082', '#ED8080'], #red [10]
['#00000000', '#00000000'], #transparent [11]
]
# Eye candy widgets
rounded_left = {
"decorations": [
PowerLineDecoration(
path='rounded_left',
size=10,
)
]
}
rounded_right = {
"decorations": [
PowerLineDecoration(
path='rounded_right',
size=10,
)
]
}
# Funciton widgets
icon = widget.TextBox(
text='',
font="JetBrainsMono Nerd Font",
mouse_callbacks={"Button1":lazy.spawn("rofi -show drun -show-icons")},
fontsize=20,
margin=4,
padding=3,
**rounded_left,
background= colors[0],
)
group_box = widget.GroupBox(
font="JetBrainsMono Nerd Font Mono",
highlight_method='line',
highlight_color= colors[11],
background = colors[4],
other_current_screen_border = colors[6],
other_screen_border = colors[6],
**rounded_left,
)
spacer = widget.Spacer(
**rounded_right,
background = colors[11], #transparent
)
kb_layout = widget.KeyboardLayout(
configured_keyboards=['us', 'cz qwerty'],
display_map={'us':'US', 'cz qwerty':'CZ'},
font="JetBrainsMono Nerd Font",
fmt="{}",
background=colors[4],
**rounded_right,
)
ram = widget.Memory(
font="JetBrainsMono Nerd Font",
format = "{MemFree:.0f} 󰓡 {SwapFree:.0f}",
mouse_callbacks={"Button1":lazy.spawn("alacritty -e btop")},
background=colors[6],
mesure_mem="M",
mesure_swap="M",
**rounded_right,
)
battery = widget.Battery(
font="JetBrainsMono Nerd Font",
format="{char} {percent:2.0%} {hour:d}:{min:02d}",
background=colors[8],
full_background=colors[7],
low_background=colors[10],
charge_char = "󰂄",
discharge_char = "󰁼",
empty_char= "󱃍",
**rounded_right,
)
clock = widget.Clock(
format="%y-%m-%d %a %H:%M",
background=colors[0],
padding = 5,
)
# Screen definition
screens = [
Screen(
wallpaper='~/.config/qtile/wallpapers/theater_by_flaviobollo.jpg',
wallpaper_mode='fill',
left=bar.Gap(5),
right=bar.Gap(5),
bottom=bar.Gap(5),
top=bar.Bar([
icon,
group_box,
spacer,
kb_layout,
ram,
battery,
clock,
], 30,
margin=6,
),
),
Screen(
wallpaper='~/.config/qtile/wallpapers/theater_by_flaviobollo.jpg',
wallpaper_mode='fill',
left=bar.Gap(5),
right=bar.Gap(5),
bottom=bar.Gap(5),
top=bar.Bar([
icon,
group_box,
spacer,
kb_layout,
ram,
battery,
clock,
], 30,
margin=6,
),
)
]