Add new widget and only show thermal widget if setting is set

This commit is contained in:
Kevin Alberts 2019-05-27 23:43:25 +02:00
parent 5c19e442fa
commit 99d4919539
Signed by: Kurocon
GPG key ID: BCD496FEBA0C6BC1
4 changed files with 246 additions and 63 deletions

View file

@ -2,16 +2,27 @@ import json
import os
import random
# Initialize logging
from libqtile.log_utils import logger
logger.error("Importing qtile theme requirements...")
from libqtile.config import Key, Screen, Group, Drag, Click
from libqtile.command import lazy
from libqtile import layout, bar, widget
logger.error("Importing theme util functions...")
# Import theme util functions
from xcffib.xproto import WindowError
logger.error("Importing kuro utils...")
import kuro.utils.widgets
from kuro.utils import general as utils
logger.error("Importing variables and other utils...")
# Import variables
from kuro.base import BaseTheme
from kuro.utils.general import display_wm_class, test_popups
@ -19,6 +30,8 @@ from kuro.utils.kb_backlight import handle_focus_change as kb_handle_focus_chang
from kuro.utils import layouts as kuro_layouts
from kuro.utils.windows import KuroStatic
logger.error("Importing configuration...")
try:
from kuro.config import Config
except ImportError:
@ -28,9 +41,7 @@ except ImportError:
Config = None
raise ImportError("Could not load theme Config or BaseConfig!")
# Initialize logging
from libqtile.log_utils import logger
logger.error("Imports done")
class Kuro(BaseTheme):
# Shorthand for modifier key
@ -84,7 +95,8 @@ class Kuro(BaseTheme):
for field in self.debug_textfields:
field.text = text
for bar in self.debug_bars:
bar.draw()
if self.qtile is not None:
bar.draw()
def log_debug(self, text):
if Config.get('verbose', False):
@ -96,6 +108,7 @@ class Kuro(BaseTheme):
logger.info(text)
def initialize(self):
logger.error("Initializing Kuro theme...")
self.log_debug("Initializing Kuro Theme...")
# Update color scheme
@ -313,18 +326,23 @@ class Kuro(BaseTheme):
kuro.utils.widgets.MediaWidget(),
kuro.utils.widgets.SeparatorWidget(),
])
kuro.utils.widgets.ThermalSensorWidget(
font=Config.get('font_topbar', 'Arial'),
fontsize=Config.get('fontsize_topbar', 16),
foreground=Config.get('thermal_colour', '#ffffff'),
foreground_alert=Config.get('thermal_colour_alert', '#ff0000'),
tag_sensor=Config.get('thermal_sensor', 'temp1'),
chip=Config.get('thermal_chip', None),
threshold=Config.get('thermal_threshold', 70),
update_interval=5,
),
if Config.get('show_temperature', False):
widgets.append(
kuro.utils.widgets.ThermalSensorWidget(
font=Config.get('font_topbar', 'Arial'),
fontsize=Config.get('fontsize_topbar', 16),
foreground=Config.get('thermal_colour', '#ffffff'),
foreground_alert=Config.get('thermal_colour_alert', '#ff0000'),
tag_sensor=Config.get('thermal_sensor', 'temp1'),
chip=Config.get('thermal_chip', None),
threshold=Config.get('thermal_threshold', 70),
update_interval=5,
)
)
widgets.extend([
widget.CPUGraph(
width=Config.get('cpu_width', 25),
border_color=Config.get('cpu_border_colour', "#000000"),
@ -374,6 +392,11 @@ class Kuro(BaseTheme):
update_delay=Config.get('battery_update_delay', 30)
),
kuro.utils.widgets.GPUStatusWidget(
theme_path=Config.get('gpu_theme_path', '/home/docs/checkouts/readthedocs.org/user_builds/qtile'
'/checkouts/latest/libqtile/resources/battery-icons'),
),
kuro.utils.widgets.WifiIconWidget(
interface=Config.get('wifi_interface', 'wlp4s0'),
theme_path=Config.get('wifi_theme_path', '/home/docs/checkouts/readthedocs.org/user_builds/qtile'
@ -519,12 +542,25 @@ class Kuro(BaseTheme):
@staticmethod
def update_screens(qtile):
out = utils.call_process(["xrandr", "--current"])
mode_out = utils.call_process(["optimus-manager", "--print-mode"])
if "nvidia" in mode_out:
video_mode = "nvidia"
elif "intel" in mode_out:
video_mode = "intel"
else:
video_mode = "unknown"
laptop_screen = None
screens = []
for x in out.split("\n"):
if " connected " in x:
if Config.get("laptop_screen", None) is not None and Config.get("laptop_screen", None) in x:
laptop_screen = x
if Config.get("laptop_screen_nvidia", None) is not None \
and Config.get("laptop_screen_intel", None) is not None:
if video_mode == "nvidia" and Config.get("laptop_screen_nvidia", None) in x:
laptop_screen = x
elif video_mode == "intel" and Config.get("laptop_screen_intel", None) in x:
laptop_screen = x
else:
screens.append(x)
else:
screens.append(x)
@ -534,7 +570,7 @@ class Kuro(BaseTheme):
other = screens[0].split()[0]
utils.call_process(["xrandr", "--output", laptop, "--below", other])
qtile.cmd_restart()
elif laptop_screen is not None and len(screens) > 1:
else:
utils.execute("arandr")
def reinitialize_visualizers(self, qtile=None):