From 6b6d6ec4f319f98b4882e43261580b029a557f93 Mon Sep 17 00:00:00 2001 From: paul-loedige Date: Tue, 9 Jan 2024 12:09:28 +0100 Subject: [PATCH] unified laptop and desktop qtile bar --- qtile/.config/qtile/Bars.py | 10 +- qtile/.config/qtile/Screens.py | 11 +- qtile/.config/qtile/Widgets.py | 155 ++++++------------ .../custom/plugins/zsh-syntax-highlighting | 2 +- zsh/.oh-my-zsh/custom/themes/powerlevel10k | 2 +- 5 files changed, 56 insertions(+), 124 deletions(-) diff --git a/qtile/.config/qtile/Bars.py b/qtile/.config/qtile/Bars.py index af4640c..3a51a9e 100644 --- a/qtile/.config/qtile/Bars.py +++ b/qtile/.config/qtile/Bars.py @@ -2,7 +2,7 @@ from libqtile import widget, bar from defines import base_color, blue_color from defines import ChassisType, chassis_type -from Widgets import Left_widgets, volume_widget, System_widgets, end_widgets, Laptop_widgets +from Widgets import Left_widgets, volume_widget, System_widgets, end_widgets widget_defaults = dict( background=base_color, @@ -25,14 +25,6 @@ main_bar = bar.Bar([ *end_widgets(blue_color,main_bar_height,main_bar_fontsize), ],main_bar_height) -laptop_bar = bar.Bar([ - *Left_widgets(main_bar_height,main_bar_fontsize,True), - widget.Systray(fontsize=main_bar_fontsize), - *volume_widget(base_color,blue_color,main_bar_height,main_bar_fontsize), - *Laptop_widgets(blue_color,blue_color,main_bar_height,main_bar_fontsize), - *end_widgets(blue_color,main_bar_height,main_bar_fontsize), -],main_bar_height) - left_bar = bar.Bar([ *Left_widgets(secondary_bar_height,secondary_bar_fontsize), *volume_widget(base_color,blue_color,secondary_bar_height,secondary_bar_fontsize), diff --git a/qtile/.config/qtile/Screens.py b/qtile/.config/qtile/Screens.py index c422869..6e87eb5 100644 --- a/qtile/.config/qtile/Screens.py +++ b/qtile/.config/qtile/Screens.py @@ -4,15 +4,10 @@ import numpy as np from libqtile.config import Screen -from Bars import top_bar, left_bar, main_bar,laptop_bar, secondary_bar +from Bars import top_bar, left_bar, main_bar, secondary_bar from defines import main_screen_res, top_screen_res -screens = [ - # Screen(bottom=top_bar), - # Screen(top=left_bar), - # Screen(top=main_bar), - # Screen(top=laptop_bar) -] +screens = [] cmd = ['xrandr'] @@ -32,7 +27,7 @@ for width, height in screen_resolutions: elif width < height: screens.append(Screen(top=left_bar)) elif width == max_width and not defined_main_window: - screens.append(Screen(top=laptop_bar)) + screens.append(Screen(top=main_bar)) defined_main_window = True else: screens.append(Screen(top=secondary_bar)) \ No newline at end of file diff --git a/qtile/.config/qtile/Widgets.py b/qtile/.config/qtile/Widgets.py index d00a5b4..1ebc5df 100644 --- a/qtile/.config/qtile/Widgets.py +++ b/qtile/.config/qtile/Widgets.py @@ -2,6 +2,7 @@ from libqtile import widget from defines import base_color, term from defines import blue_color, light_foreground_color, dark_foreground_color, red_color, light_purple_color, purple_color, green_color, orange_color, magenta_color, yellow_color +from defines import ChassisType, chassis_type from Custom_Widgets import MemoryC, Mic #region Powerline @@ -96,52 +97,70 @@ def volume_widget(prev_color,color,size,fontsize): #endregion #region System_widgets -def launch_htop(qtile): +def launch_htop(): qtile.cmd_spawn(term + ' -e htop') -launch_htop= {'Button1': launch_htop} def System_widgets(prev_color,last_color,size,fontsize): - return [ - *powerline_arrow('l',prev_color,orange_color,size), - widget.TextBox( - text='󰈸', - foreground=light_foreground_color, - background=orange_color, - fontsize=fontsize+6 - ), - widget.ThermalSensor( - foreground=light_foreground_color, - background=orange_color, - fontsize=fontsize, - tag_sensor='Tctl', - mouse_callbacks = launch_htop, - ), - *powerline_arrow('l',orange_color,green_color,size), + sys_widgets = [] + sys_widgets.append(*powerline_arrow('l',prev_color,orange_color,size)) + # first widget is battery for laptop and cpu temp otherwise + if chassis_type == ChassisType.LAPTOP: + sys_widgets.append( + widget.Battery( + foreground=light_foreground_color, + background=orange_color, + fontsize=fontsize, + update_interval=1, + format="{char} {percent:2.0%}", + low_percentage=0.2, + notify_below=True, + low_foreground=red_color, + ) + ) + else: + sys_widgets.extend([ + widget.TextBox( + text='󰈸', + foreground=light_foreground_color, + background=orange_color, + fontsize=fontsize+6 + ), + widget.ThermalSensor( + foreground=light_foreground_color, + background=orange_color, + fontsize=fontsize, + tag_sensor='Tctl', + mouse_callbacks = {"Button1": launch_htop}, + ) + ]) + sys_widgets.append(*powerline_arrow('l',orange_color,green_color,size)) + + sys_widgets.extend([ widget.TextBox( text=' ', foreground=light_foreground_color, background=green_color, - fontsize=fontsize+6 + fontsize=fontsize ), widget.CPU( foreground=light_foreground_color, background=green_color, fontsize=fontsize, - format='{load_percent}% @ {freq_current}GHz', + format='{load_percent}%' if chassis_type == ChassisType.LAPTOP else'{load_percent}% @ {freq_current}GHz', mouse_callbacks = launch_htop, ), *powerline_arrow('l',green_color,yellow_color,size), widget.TextBox( - text='󰍛 ', + text='', foreground=light_foreground_color, background=yellow_color, - fontsize=fontsize+6 + fontsize=fontsize ), MemoryC( foreground=light_foreground_color, background=yellow_color, fontsize=fontsize, - format=" {MemUsed}GB({MemPercent}%) | {SwapUsed}GB({SwapPercent}%)", + format='{MemUsed}GB|{SwapUsed}GB' if chassis_type == ChassisType.LAPTOP else'{MemUsed}GB({MemPercent}%) | {SwapUsed}GB({SwapPercent}%)', mouse_callbacks = launch_htop, ), *powerline_arrow('l',yellow_color,last_color,size), @@ -149,25 +168,19 @@ def System_widgets(prev_color,last_color,size,fontsize): text='󰈀 ', foreground=light_foreground_color, background=blue_color, - fontsize=fontsize+6 + fontsize=fontsize ), widget.Net( background=last_color, foreground=light_foreground_color, fontsize=fontsize, - fmt='{:.9}', - format='{down}↓', + prefix='M', + format='{down:6.2f}{down_suffix}↓{up:6.2f}{up_suffix}↑', mouse_callbacks = launch_htop, - ), - widget.Net( - background=last_color, - foreground=light_foreground_color, - fontsize=fontsize, - fmt='{:.9}', - format='{up}↑', - mouse_callbacks = launch_htop, - ), - ] + ) + ] + ) + return sys_widgets #endregion #region End_widgets @@ -175,7 +188,7 @@ def end_widgets(prev_color,size,fontsize): return [ *powerline_arrow('l',prev_color,purple_color,size), widget.TextBox( - text=' ', + text='󰸗 ', foreground=light_foreground_color, background=purple_color, fontsize=fontsize @@ -194,71 +207,3 @@ def end_widgets(prev_color,size,fontsize): ), ] #endregion - -#region Laptop widgets -def Laptop_widgets(prev_color,last_color,size,fontsize): - return [ - *powerline_arrow('l',prev_color,orange_color,size), - widget.Battery( - foreground=light_foreground_color, - background=orange_color, - fontsize=fontsize, - update_interval=1, - format="{char} {percent:2.0%}", - low_percentage=0.2, - notify_below=True, - low_foreground=red_color, - ), - *powerline_arrow('l',orange_color,green_color,size), - widget.TextBox( - text='', - foreground=light_foreground_color, - background=green_color, - fontsize=fontsize - ), - widget.CPU( - foreground=light_foreground_color, - background=green_color, - fontsize=fontsize, - format='{load_percent}%', - mouse_callbacks = launch_htop, - ), - *powerline_arrow('l',green_color,yellow_color,size), - widget.TextBox( - text='﬙', - foreground=light_foreground_color, - background=yellow_color, - fontsize=fontsize - ), - MemoryC( - foreground=light_foreground_color, - background=yellow_color, - fontsize=fontsize, - format="{MemUsed}GB|{SwapUsed}GB", - mouse_callbacks = launch_htop, - ), - *powerline_arrow('l',yellow_color,last_color,size), - widget.TextBox( - text='', - foreground=light_foreground_color, - background=blue_color, - fontsize=fontsize - ), - widget.Net( - background=last_color, - foreground=light_foreground_color, - fontsize=fontsize, - fmt='{:.9}', - format='{down}↓', - mouse_callbacks = launch_htop, - ), - widget.Net( - background=last_color, - foreground=light_foreground_color, - fontsize=fontsize, - fmt='{:.9}', - format='{up}↑', - mouse_callbacks = launch_htop, - ), - ] -#endregion diff --git a/zsh/.oh-my-zsh/custom/plugins/zsh-syntax-highlighting b/zsh/.oh-my-zsh/custom/plugins/zsh-syntax-highlighting index dcc99a8..e0165ea 160000 --- a/zsh/.oh-my-zsh/custom/plugins/zsh-syntax-highlighting +++ b/zsh/.oh-my-zsh/custom/plugins/zsh-syntax-highlighting @@ -1 +1 @@ -Subproject commit dcc99a86497491dfe41fb8b0d5f506033546a8c0 +Subproject commit e0165eaa730dd0fa321a6a6de74f092fe87630b0 diff --git a/zsh/.oh-my-zsh/custom/themes/powerlevel10k b/zsh/.oh-my-zsh/custom/themes/powerlevel10k index cc6ed4b..d804048 160000 --- a/zsh/.oh-my-zsh/custom/themes/powerlevel10k +++ b/zsh/.oh-my-zsh/custom/themes/powerlevel10k @@ -1 +1 @@ -Subproject commit cc6ed4be416b70fe4e3f97d17061c751abaca04f +Subproject commit d804048efc46b8b248693fa3a7bfc9f863bb1254